mippy 2.22.6__tar.gz → 2.22.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {mippy-2.22.6 → mippy-2.22.7}/PKG-INFO +1 -1
  2. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/implementations.py +3 -0
  3. mippy-2.22.7/mippy/mdicom/miners/syngo_mr_xa50a.py +437 -0
  4. mippy-2.22.7/mippy/mdicom/miners/syngo_mr_xa60.py +437 -0
  5. mippy-2.22.7/mippy/mdicom/miners/syngo_mr_xa61a.py +437 -0
  6. {mippy-2.22.6 → mippy-2.22.7}/mippy.egg-info/PKG-INFO +1 -1
  7. {mippy-2.22.6 → mippy-2.22.7}/mippy.egg-info/SOURCES.txt +3 -0
  8. {mippy-2.22.6 → mippy-2.22.7}/LICENSE +0 -0
  9. {mippy-2.22.6 → mippy-2.22.7}/README.md +0 -0
  10. {mippy-2.22.6 → mippy-2.22.7}/mippy/__init__.py +0 -0
  11. {mippy-2.22.6 → mippy-2.22.7}/mippy/application.py +0 -0
  12. {mippy-2.22.6 → mippy-2.22.7}/mippy/fileio.py +0 -0
  13. {mippy-2.22.6 → mippy-2.22.7}/mippy/html.py +0 -0
  14. {mippy-2.22.6 → mippy-2.22.7}/mippy/improcess.py +0 -0
  15. {mippy-2.22.6 → mippy-2.22.7}/mippy/launcher.py +0 -0
  16. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/16_colors.csv +0 -0
  17. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/blue.csv +0 -0
  18. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/colours_roman.csv +0 -0
  19. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/cyan.csv +0 -0
  20. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/fire.csv +0 -0
  21. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/green.csv +0 -0
  22. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/green_fire_blue.csv +0 -0
  23. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/hi_lo.csv +0 -0
  24. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/ice.csv +0 -0
  25. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/magenta.csv +0 -0
  26. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/phase.csv +0 -0
  27. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/physics.csv +0 -0
  28. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/rainbow.csv +0 -0
  29. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/red.csv +0 -0
  30. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/red_green.csv +0 -0
  31. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/red_grey_green.csv +0 -0
  32. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/red_grey_green_clipped.csv +0 -0
  33. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/spectrum.csv +0 -0
  34. {mippy-2.22.6 → mippy-2.22.7}/mippy/luts/yellow.csv +0 -0
  35. {mippy-2.22.6 → mippy-2.22.7}/mippy/math.py +0 -0
  36. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/__init__.py +0 -0
  37. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/anon.py +0 -0
  38. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/io.py +0 -0
  39. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/SIEMENS.py +0 -0
  40. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/__init__.py +0 -0
  41. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/ge_fallback.py +0 -0
  42. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/philips_fallback.py +0 -0
  43. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/siemens_fallback.py +0 -0
  44. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/syngo_mr_xa20a.py +0 -0
  45. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/miners/syngo_mr_xa31a.py +0 -0
  46. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/mrenhanced.py +0 -0
  47. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/mrspectroscopy.py +0 -0
  48. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/pixel.py +0 -0
  49. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/reading.py +0 -0
  50. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/siemens.py +0 -0
  51. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/sorting.py +0 -0
  52. {mippy-2.22.6 → mippy-2.22.7}/mippy/mdicom/xml.py +0 -0
  53. {mippy-2.22.6 → mippy-2.22.7}/mippy/misc.py +0 -0
  54. {mippy-2.22.6 → mippy-2.22.7}/mippy/mlogging.py +0 -0
  55. {mippy-2.22.6 → mippy-2.22.7}/mippy/mviewer/__init__.py +0 -0
  56. {mippy-2.22.6 → mippy-2.22.7}/mippy/mviewer/config +0 -0
  57. {mippy-2.22.6 → mippy-2.22.7}/mippy/mviewer/module_main.py +0 -0
  58. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/add.png +0 -0
  59. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/brain_bw.xbm +0 -0
  60. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/brain_orange.ico +0 -0
  61. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/common.png +0 -0
  62. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/dcmdjpeg_linux +0 -0
  63. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/dcmdjpeg_mac +0 -0
  64. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/dcmdjpeg_win.exe +0 -0
  65. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/ellipse_roi.png +0 -0
  66. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/freehand_roi.png +0 -0
  67. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/line_roi.png +0 -0
  68. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/mrs.png +0 -0
  69. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_circle.png +0 -0
  70. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_ellipse.png +0 -0
  71. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_freehand.png +0 -0
  72. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_line.png +0 -0
  73. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_rectangular.png +0 -0
  74. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/roi_rectangular_ab.png +0 -0
  75. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/splash11.jpg +0 -0
  76. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/splash20.bmp +0 -0
  77. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/splash20.jpg +0 -0
  78. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/splash3.jpg +0 -0
  79. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/square_roi.png +0 -0
  80. {mippy-2.22.6 → mippy-2.22.7}/mippy/resources/subtract.png +0 -0
  81. {mippy-2.22.6 → mippy-2.22.7}/mippy/splash.py +0 -0
  82. {mippy-2.22.6 → mippy-2.22.7}/mippy/threading.py +0 -0
  83. {mippy-2.22.6 → mippy-2.22.7}/mippy/viewing.py +0 -0
  84. {mippy-2.22.6 → mippy-2.22.7}/mippy.egg-info/dependency_links.txt +0 -0
  85. {mippy-2.22.6 → mippy-2.22.7}/mippy.egg-info/requires.txt +0 -0
  86. {mippy-2.22.6 → mippy-2.22.7}/mippy.egg-info/top_level.txt +0 -0
  87. {mippy-2.22.6 → mippy-2.22.7}/scripts/_mippy.py +0 -0
  88. {mippy-2.22.6 → mippy-2.22.7}/scripts/mippy.bat +0 -0
  89. {mippy-2.22.6 → mippy-2.22.7}/scripts/setup_mippy.bat +0 -0
  90. {mippy-2.22.6 → mippy-2.22.7}/scripts/setup_mippy.py +0 -0
  91. {mippy-2.22.6 → mippy-2.22.7}/setup.cfg +0 -0
  92. {mippy-2.22.6 → mippy-2.22.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mippy
3
- Version: 2.22.6
3
+ Version: 2.22.7
4
4
  Summary: Modular Image Processing in Python
5
5
  Home-page: https://gitlab.com/rbf906/mippy
6
6
  Author: Robert Flintham
@@ -1,5 +1,8 @@
1
1
  IMPLEMENTATIONS_AVAILABLE = [
2
2
  'syngo_mr_xa20a',
3
3
  'syngo_mr_xa31a',
4
+ 'syngo_mr_xa50a',
5
+ 'syngo_mr_xa60a',
6
+ 'syngo_mr_xa61a',
4
7
  'SIEMENS'
5
8
  ]
@@ -0,0 +1,437 @@
1
+ from mippy.mdicom.siemens import get_ascconv
2
+ import pydicom
3
+ import numpy as np
4
+ from nibabel.nicom import csareader as csar
5
+ import json
6
+
7
+ def get_ascii_value(dicom_ds,searchterm):
8
+ if not ascii in dir(dicom_ds):
9
+ asc = get_ascconv(dicom_ds)
10
+ setattr(dicom_ds,'ascii',asc)
11
+ else:
12
+ print("Using saved ASCII")
13
+ return_value = None
14
+ #~ header = self.get_ascconv()
15
+ found = False
16
+ for s in dicom_ds.ascii:
17
+ if searchterm in s[0]:
18
+ return_value = s[1]
19
+ found = True
20
+ break
21
+ if not found:
22
+ return None
23
+ else:
24
+ try:
25
+ return_value = float(return_value)
26
+ except:
27
+ pass
28
+ return return_value
29
+
30
+ def is_number(s):
31
+ """
32
+ Tests if a string is readable as a number
33
+ """
34
+ try:
35
+ float(s)
36
+ except ValueError:
37
+ return False
38
+ return True
39
+
40
+ def get_serial_number(dicom_ds):
41
+ return str(dicom_ds.DeviceSerialNumber)
42
+
43
+ def get_patient_name(dicom_ds):
44
+ return str(dicom_ds.PatientName)
45
+
46
+ def get_image_orientation(dicom_ds):
47
+ orient = dicom_ds.ImageOrientationPatient
48
+ # Check TRA
49
+ if ( abs(orient[0])>abs(orient[1]) and abs(orient[0])>abs(orient[2])
50
+ and abs(orient[4])>abs(orient[3]) and abs(orient[4])>abs(orient[5])):
51
+ return "TRA"
52
+ # Check SAG
53
+ elif ( abs(orient[1])>abs(orient[0]) and abs(orient[1])>abs(orient[2])
54
+ and abs(orient[5])>abs(orient[3]) and abs(orient[5])>abs(orient[4])):
55
+ return "SAG"
56
+ # Check COR
57
+ elif ( abs(orient[0])>abs(orient[1]) and abs(orient[0])>abs(orient[2])
58
+ and abs(orient[5])>abs(orient[3]) and abs(orient[5])>abs(orient[4])):
59
+ return "COR"
60
+ else:
61
+ print("ORIENTATION NOT DETECTED", orient)
62
+ return "UNKNOWN"
63
+
64
+ def get_sequence_type(dicom_ds):
65
+ try:
66
+ seq = dicom_ds[0x18,0x9005].value
67
+ except:
68
+ seq = ""
69
+ if "se2d" in seq:
70
+ return "SE 2D"
71
+ elif "epfid2d" in seq:
72
+ return "EPI GRE 2D"
73
+ elif "ep2d_diff" in seq:
74
+ return "EPI DIFF 2D"
75
+ elif "ep2d_se" in seq:
76
+ return "EPI SE 2D"
77
+ elif "fl2d" in seq:
78
+ return "GRE 2D"
79
+ elif "fl3d" in seq:
80
+ return "GRE 3D"
81
+ elif "tse2d" in seq:
82
+ return "TSE 2D"
83
+ elif "tse3d" in seq:
84
+ return "TSE 3D"
85
+ elif "tfl2d" in seq:
86
+ return "TGRE 2D"
87
+ elif "tfl3d" in seq:
88
+ return "TGRE 3D"
89
+ else:
90
+ print("SEQUENCE NOT DETECTED", seq)
91
+ return "UNKNOWN"
92
+
93
+ def get_fov(dicom_ds):
94
+ pxspc_x = dicom_ds.PixelSpacing[0]
95
+ pxspc_y = dicom_ds.PixelSpacing[1]
96
+ rows = dicom_ds.Rows
97
+ cols = dicom_ds.Columns
98
+ fov = str(int(np.round(pxspc_x*cols,0)))+","+str(int(np.round(pxspc_y*rows,0)))
99
+ return fov
100
+
101
+ def get_acq_matrix(dicom_ds):
102
+ # This does not take account of partial fourier. I don't know whether the
103
+ # effects of partial fourier are already included in phase encode lines, or
104
+ # if this is number of lines before applying PF ???
105
+ base_resolution = int(np.round(get_ascii_value(dicom_ds,'sKSpace.lBaseResolution'),0))
106
+ phase_encode_lines = int(np.round(get_ascii_value(dicom_ds,'sKSpace.lPhaseEncodingLines'),0))
107
+ phase = dicom_ds.InPlanePhaseEncodingDirection
108
+ if phase=='ROW':
109
+ matrix = str(phase_encode_lines)+','+str(base_resolution)
110
+ return matrix
111
+ elif phase=='COLUMN':
112
+ matrix = str(base_resolution)+','+str(phase_encode_lines)
113
+ return matrix
114
+
115
+ def get_recon_matrix(dicom_ds):
116
+ rows = dicom_ds.Rows
117
+ cols = dicom_ds.Columns
118
+ return str(cols)+','+str(rows)
119
+
120
+ def get_acq_slice_thickness(dicom_ds):
121
+ if dicom_ds.MRAcquisitionType=='2D':
122
+ return float(dicom_ds.SliceThickness)
123
+ elif dicom_ds.MRAcquisitionType=='3D':
124
+ slice_resolution = get_ascii_value(dicom_ds,'sKSpace.dSliceResolution')
125
+ slice_thickness = dicom_ds.SliceThickness
126
+ if slice_resolution<1.:
127
+ acq_slice_thickness = slice_thickness / slice_resolution
128
+ return float(acq_slice_thickness)
129
+ else:
130
+ return float(slice_thickness)
131
+ else:
132
+ print("Do not understand acquisition acquisition type")
133
+ return "UNKNOWN"
134
+
135
+ def get_oversampling(dicom_ds):
136
+ # Do not know how this tag actually presents. Expect errors if you have
137
+ # images with oversampling on.
138
+ oversampling = dicom_ds.OversamplingPhase
139
+ if oversampling=='NONE':
140
+ oversampling = None
141
+
142
+ if not oversampling is None:
143
+ return float(oversampling)
144
+ else:
145
+ # Assume no oversampling if tag not written
146
+ return 0.
147
+
148
+ def get_recon_slice_thickness(dicom_ds):
149
+ return float(dicom_ds.SliceThickness)
150
+
151
+ def get_phase_encode_direction(dicom_ds):
152
+ orient = get_image_orientation(dicom_ds)
153
+ phase = dicom_ds.InPlanePhaseEncodingDirection
154
+ if orient=='TRA':
155
+ if 'ROW' in phase:
156
+ return 'RL'
157
+ elif 'COL' in phase:
158
+ return 'AP'
159
+ else:
160
+ print("Do not understand phase encode direction")
161
+ return "UNKNOWN"
162
+ elif orient=='SAG':
163
+ if 'ROW' in phase:
164
+ return 'AP'
165
+ elif 'COL' in phase:
166
+ return 'FH'
167
+ else:
168
+ print("Do not understand phase encode direction")
169
+ return "UNKNOWN"
170
+ elif orient=='COR':
171
+ if 'ROW' in phase:
172
+ return 'RL'
173
+ elif 'COL' in phase:
174
+ return 'FH'
175
+ else:
176
+ print("Do not understand phase encode direction")
177
+ return "UNKNOWN"
178
+ else:
179
+ print("Do not understand orientation")
180
+ return "UNKNOWN"
181
+
182
+ def get_nsa(dicom_ds):
183
+ return float(dicom_ds.NumberOfAverages)
184
+
185
+ def get_TR(dicom_ds):
186
+ return float(dicom_ds.RepetitionTime)
187
+
188
+ def get_TE(dicom_ds):
189
+ try:
190
+ return np.round(float(dicom_ds.EchoTime),3)
191
+ except:
192
+ # Use effective echo time (copied from from per-frame group to create single slice)
193
+ # XA20 seems to write this instead of actual echo time...
194
+ return np.round(dicom_ds.EffectiveEchoTime,3)
195
+
196
+ def get_TI(dicom_ds):
197
+ try:
198
+ return float(dicom_ds.InversionTime)
199
+ except AttributeError:
200
+ # print("No inversion time found")
201
+ return "None"
202
+
203
+ def get_flip_angle(dicom_ds):
204
+ return float(dicom_ds.FlipAngle)
205
+
206
+ def get_pat_type(dicom_ds):
207
+ # print("PAT NOT YET SUPPORTED")
208
+ return "UNKNOWN"
209
+
210
+ def get_pat_2d(dicom_ds):
211
+ # print("PAT NOT YET SUPPORTED")
212
+ return "UNKNOWN"
213
+
214
+ def get_pat_3d(dicom_ds):
215
+ # print("PAT NOT YET SUPPORTED")
216
+ return "UNKNOWN"
217
+
218
+ def get_partial_fourier_phase(dicom_ds):
219
+ # print("PARTIAL FOURIER NOT YET SUPPORTED")
220
+ phase_partial_fourier = get_ascii_value(dicom_ds,'sKSpace.ucPhasePartialFourier')/16
221
+ return phase_partial_fourier
222
+
223
+ def get_partial_fourier_slice(dicom_ds):
224
+ # print("PARTIAL FOURIER NOT YET SUPPORTED")
225
+ slice_partial_fourier = get_ascii_value(dicom_ds,'sKSpace.ucSlicePartialFourier')/16
226
+ return slice_partial_fourier
227
+
228
+ def get_coil_elements(dicom_ds):
229
+ try:
230
+ coilstring = str(dicom_ds[0x51,0x100f].value)
231
+ except KeyError:
232
+ # Attempt alternative DICOM tag for newer scanners
233
+ try:
234
+ coilstring = str(dicom_ds[0x21,0x114f].value)
235
+ except KeyError:
236
+ # Still didn't work
237
+ print("Unable to get coil information")
238
+ return "UNKNOWN"
239
+
240
+ coils = read_coil_string(coilstring)
241
+ return ';'.join(coils)
242
+
243
+
244
+
245
+ # Some comprehension of coil string required.
246
+ # Assume something of the fashion C:HE1-4;SP3;SP5
247
+ def read_coil_string(coilstring):
248
+ coils = coilstring.replace('b\'C:','').replace('C:','').replace('\'','').strip().split(';')
249
+ active_coils = []
250
+ for coil in coils:
251
+ if '-' in coil:
252
+ # Convert range into list of individual elements
253
+ # Get prefix
254
+ prefix = ''
255
+ for char in coil:
256
+ if not is_number(char):
257
+ prefix=prefix+char
258
+ else:
259
+ break
260
+ # Remove prefx and split at dash
261
+ coil_range = coil.replace(prefix,'').split('-')
262
+ for i in range(int(coil_range[0]),int(coil_range[1])+1):
263
+ active_coils.append(prefix+str(i))
264
+ elif ',' in coil:
265
+ # Convert range into list of individual elements
266
+ # Get prefix
267
+ prefix = ''
268
+ for char in coil:
269
+ if not is_number(char):
270
+ prefix=prefix+char
271
+ else:
272
+ break
273
+ # Remove prefix and split at comma
274
+ coil_range = coil.replace(prefix,'').split(',')
275
+ for num in coil_range:
276
+ active_coils.append(prefix+num)
277
+ else:
278
+ active_coils.append(coil)
279
+ return active_coils
280
+
281
+ def get_bandwidth(dicom_ds):
282
+ return float(dicom_ds.PixelBandwidth)
283
+
284
+ def get_image_filter(dicom_ds):
285
+ filters = []
286
+ imfilter_on = get_ascii_value(dicom_ds,'sImageFilter.ucOn')
287
+ rawfilter_on = get_ascii_value(dicom_ds,'sRawFilter.ucOn')
288
+ ellipticalfilter_on = get_ascii_value(dicom_ds,'sEllipticalFilter.ucOn')
289
+ b1filter_on = get_ascii_value(dicom_ds,'sBiFiCFilter.ucOn')
290
+ if imfilter_on =='0x1':
291
+ filters.append("ImageFilter")
292
+ if rawfilter_on == '0x1':
293
+ rawfilter_value = int(np.round(get_ascii_value(dicom_ds,'sRawFilter.lSlope_256'),0))
294
+ filters.append(f"RawFilter{rawfilter_value}")
295
+ if ellipticalfilter_on == '0x1':
296
+ ellipticalfilter_mode = get_ascii_value(dicom_ds,'sEllipticalFilter.ucMode')
297
+ if ellipticalfilter_mode == 1:
298
+ filters.append("EllipticalFilter2D")
299
+ elif ellipticalfilter_mode == 2:
300
+ filters.append("EllipticalFilter3D")
301
+ if b1filter_on == '0x1':
302
+ # B1 filter mode available, but not understood so not included yet
303
+ filters.append("B1Filter")
304
+ if len(filters)>0:
305
+ return ';'.join(filters)
306
+ else:
307
+ return 'None'
308
+
309
+ def get_uniformity_correction(dicom_ds):
310
+ imtype = dicom_ds[0x21,0x1175].value
311
+ # Appears to be a private version of legacy ImageType tag. Will do the job for now
312
+ # and actually appears to be only difference between filtered and unfiltered images
313
+ if 'NORM' in imtype:
314
+ this_image_norm = True
315
+ else:
316
+ this_image_norm = False
317
+ prescan = get_ascii_value(dicom_ds,'sPreScanNormalizeFilter.ucOn')
318
+ norm_filt = get_ascii_value(dicom_ds,'sNormalizeFilter.ucOn')
319
+ prescan_mode = get_ascii_value(dicom_ds,'sPreScanNormalizeFilter.ucMode')
320
+ if prescan is None:
321
+ prescan_on = False
322
+ elif prescan == '0x1':
323
+ prescan_on = True
324
+ else:
325
+ # Assume if tag exists, it's on.
326
+ prescan = True
327
+ if norm_filt is None:
328
+ norm_on = False
329
+ elif norm_filt == '0x1':
330
+ norm_on = True
331
+ else:
332
+ # Assume if tag exists, it's on
333
+ norm_filt = True
334
+
335
+ filters = ""
336
+ if prescan_on:
337
+ filters+="PreScanNormalize"
338
+ if prescan_mode==1: # Moderate mode
339
+ filters+="-Moderate"
340
+ elif prescan_mode==2: # Normal mode
341
+ filters+="-Normal"
342
+ elif prescan_mode==4: # Broad mode
343
+ filters+="-Broad"
344
+ if not this_image_norm:
345
+ filters+="-Unfiltered"
346
+ elif norm_on:
347
+ filters+="Normalize"
348
+ # Lots of potential modes/settings for this but not sure what they are
349
+ if not this_image_norm:
350
+ filters+="-Unfiltered"
351
+ else:
352
+ filters+='None'
353
+ return filters
354
+
355
+ def get_distortion_correction(dicom_ds):
356
+ imtype = dicom_ds[0x21,0x1175].value
357
+ # Appears to be a private version of legacy ImageType tag. Will do the job for now
358
+ # and actually appears to be only difference between filtered and unfiltered images
359
+ if 'DIS2D' in imtype:
360
+ this_image_dc = '2D'
361
+ elif 'DIS3D' in imtype:
362
+ this_image_dc = '3D'
363
+ else:
364
+ this_image_dc = False
365
+
366
+ try:
367
+ # Fudge for XA data - tags unfiltered images as DISTORTED
368
+ if dicom_ds[0x8,0x9206].value=='DISTORTED':
369
+ this_image_dc = False
370
+ else:
371
+ this_image_dc = True
372
+ except:
373
+ pass
374
+
375
+ dc_filter = get_ascii_value(dicom_ds,'sDistortionCorrFilter.ucMode')
376
+ if dc_filter == '0x2':
377
+ dc_filter_type = '2D'
378
+ elif dc_filter == '0x4':
379
+ dc_filter_type = '3D'
380
+ elif dc_filter == 2:
381
+ dc_filter_type = '2D'
382
+ elif dc_filter == 3 or dc_filter == 4:
383
+ dc_filter_type = '3D'
384
+ else:
385
+ dc_filter_type = False
386
+
387
+ if dc_filter_type and this_image_dc:
388
+ return dc_filter_type
389
+ elif dc_filter_type and not this_image_dc:
390
+ return dc_filter_type+'-Unfiltered'
391
+ else:
392
+ return "None"
393
+
394
+ def get_study_uid(dicom_ds):
395
+ return str(dicom_ds.StudyInstanceUID)
396
+
397
+ def get_series_number(dicom_ds):
398
+ return dicom_ds.SeriesNumber
399
+
400
+ def get_series_uid(dicom_ds):
401
+ return str(dicom_ds.SeriesInstanceUID)
402
+
403
+ def get_instance_number(dicom_ds):
404
+ return dicom_ds.InstanceNumber
405
+
406
+ def get_sop_uid(dicom_ds):
407
+ return str(dicom_ds.SOPInstanceUID)
408
+
409
+ def get_study_date(dicom_ds):
410
+ return str(dicom_ds.StudyDate)
411
+
412
+ def get_study_time(dicom_ds):
413
+ return str(dicom_ds.StudyTime)
414
+
415
+ def get_institution_name(dicom_ds):
416
+ try:
417
+ return str(dicom_ds.InstitutionName)
418
+ except:
419
+ return "UNKNOWN"
420
+
421
+ def get_scanner_model(dicom_ds):
422
+ return str(dicom_ds.Manufacturer)+' '+str(dicom_ds.ManufacturerModelName)
423
+
424
+ def get_institution_address(dicom_ds):
425
+ return str(dicom_ds.InstitutionAddress)
426
+
427
+ def get_department(dicom_ds):
428
+ try:
429
+ return str(dicom_ds.InstitutionalDepartmentName)
430
+ except AttributeError:
431
+ return "UNKNOWN"
432
+
433
+ def get_station_name(dicom_ds):
434
+ return str(dicom_ds.StationName)
435
+
436
+ def get_field_strength(dicom_ds):
437
+ return float(dicom_ds.MagneticFieldStrength)