Commit 7f9956549b19837f11f10b899f07b8ae2bd9b6df
1 parent
32eb467e
Exists in
master
Using black and isort in some python files
Showing
3 changed files
with
413 additions
and
415 deletions
Show diff stats
invesalius/data/converters.py
1 | -#-------------------------------------------------------------------------- | 1 | +# -------------------------------------------------------------------------- |
2 | # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | 2 | # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas |
3 | # Copyright: (C) 2001 Centro de Pesquisas Renato Archer | 3 | # Copyright: (C) 2001 Centro de Pesquisas Renato Archer |
4 | # Homepage: http://www.softwarepublico.gov.br | 4 | # Homepage: http://www.softwarepublico.gov.br |
5 | # Contact: invesalius@cti.gov.br | 5 | # Contact: invesalius@cti.gov.br |
6 | # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | 6 | # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) |
7 | -#-------------------------------------------------------------------------- | 7 | +# -------------------------------------------------------------------------- |
8 | # Este programa e software livre; voce pode redistribui-lo e/ou | 8 | # Este programa e software livre; voce pode redistribui-lo e/ou |
9 | # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | 9 | # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme |
10 | # publicada pela Free Software Foundation; de acordo com a versao 2 | 10 | # publicada pela Free Software Foundation; de acordo com a versao 2 |
@@ -15,16 +15,22 @@ | @@ -15,16 +15,22 @@ | ||
15 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | 15 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM |
16 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | 16 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais |
17 | # detalhes. | 17 | # detalhes. |
18 | -#-------------------------------------------------------------------------- | 18 | +# -------------------------------------------------------------------------- |
19 | 19 | ||
20 | import gdcm | 20 | import gdcm |
21 | import numpy as np | 21 | import numpy as np |
22 | import vtk | 22 | import vtk |
23 | - | ||
24 | from vtk.util import numpy_support | 23 | from vtk.util import numpy_support |
25 | 24 | ||
26 | 25 | ||
27 | -def to_vtk(n_array, spacing=(1.0, 1.0, 1.0), slice_number=0, orientation='AXIAL', origin=(0, 0, 0), padding=(0, 0, 0)): | 26 | +def to_vtk( |
27 | + n_array, | ||
28 | + spacing=(1.0, 1.0, 1.0), | ||
29 | + slice_number=0, | ||
30 | + orientation="AXIAL", | ||
31 | + origin=(0, 0, 0), | ||
32 | + padding=(0, 0, 0), | ||
33 | +): | ||
28 | if orientation == "SAGITTAL": | 34 | if orientation == "SAGITTAL": |
29 | orientation = "SAGITAL" | 35 | orientation = "SAGITAL" |
30 | 36 | ||
@@ -38,14 +44,35 @@ def to_vtk(n_array, spacing=(1.0, 1.0, 1.0), slice_number=0, orientation='AXIAL' | @@ -38,14 +44,35 @@ def to_vtk(n_array, spacing=(1.0, 1.0, 1.0), slice_number=0, orientation='AXIAL' | ||
38 | 44 | ||
39 | v_image = numpy_support.numpy_to_vtk(n_array.flat) | 45 | v_image = numpy_support.numpy_to_vtk(n_array.flat) |
40 | 46 | ||
41 | - if orientation == 'AXIAL': | ||
42 | - extent = (0 - px , dx -1 - px, 0 - py, dy - 1 - py, slice_number - pz, slice_number + dz - 1 - pz) | ||
43 | - elif orientation == 'SAGITAL': | 47 | + if orientation == "AXIAL": |
48 | + extent = ( | ||
49 | + 0 - px, | ||
50 | + dx - 1 - px, | ||
51 | + 0 - py, | ||
52 | + dy - 1 - py, | ||
53 | + slice_number - pz, | ||
54 | + slice_number + dz - 1 - pz, | ||
55 | + ) | ||
56 | + elif orientation == "SAGITAL": | ||
44 | dx, dy, dz = dz, dx, dy | 57 | dx, dy, dz = dz, dx, dy |
45 | - extent = (slice_number - px, slice_number + dx - 1 - px, 0 - py, dy - 1 - py, 0 - pz, dz - 1 - pz) | ||
46 | - elif orientation == 'CORONAL': | 58 | + extent = ( |
59 | + slice_number - px, | ||
60 | + slice_number + dx - 1 - px, | ||
61 | + 0 - py, | ||
62 | + dy - 1 - py, | ||
63 | + 0 - pz, | ||
64 | + dz - 1 - pz, | ||
65 | + ) | ||
66 | + elif orientation == "CORONAL": | ||
47 | dx, dy, dz = dx, dz, dy | 67 | dx, dy, dz = dx, dz, dy |
48 | - extent = (0 - px, dx - 1 - px, slice_number - py, slice_number + dy - 1 - py, 0 - pz, dz - 1 - pz) | 68 | + extent = ( |
69 | + 0 - px, | ||
70 | + dx - 1 - px, | ||
71 | + slice_number - py, | ||
72 | + slice_number + dy - 1 - py, | ||
73 | + 0 - pz, | ||
74 | + dz - 1 - pz, | ||
75 | + ) | ||
49 | 76 | ||
50 | # Generating the vtkImageData | 77 | # Generating the vtkImageData |
51 | image = vtk.vtkImageData() | 78 | image = vtk.vtkImageData() |
@@ -76,7 +103,7 @@ def to_vtk_mask(n_array, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)): | @@ -76,7 +103,7 @@ def to_vtk_mask(n_array, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)): | ||
76 | oz -= sz | 103 | oz -= sz |
77 | 104 | ||
78 | v_image = numpy_support.numpy_to_vtk(n_array.flat) | 105 | v_image = numpy_support.numpy_to_vtk(n_array.flat) |
79 | - extent = (0, dx - 1, 0, dy - 1, 0, dz - 1) | 106 | + extent = (0, dx - 1, 0, dy - 1, 0, dz - 1) |
80 | 107 | ||
81 | # Generating the vtkImageData | 108 | # Generating the vtkImageData |
82 | image = vtk.vtkImageData() | 109 | image = vtk.vtkImageData() |
@@ -99,9 +126,9 @@ def to_vtk_mask(n_array, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)): | @@ -99,9 +126,9 @@ def to_vtk_mask(n_array, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)): | ||
99 | 126 | ||
100 | def np_rgba_to_vtk(n_array, spacing=(1.0, 1.0, 1.0)): | 127 | def np_rgba_to_vtk(n_array, spacing=(1.0, 1.0, 1.0)): |
101 | dy, dx, dc = n_array.shape | 128 | dy, dx, dc = n_array.shape |
102 | - v_image = numpy_support.numpy_to_vtk(n_array.reshape(dy*dx, dc)) | 129 | + v_image = numpy_support.numpy_to_vtk(n_array.reshape(dy * dx, dc)) |
103 | 130 | ||
104 | - extent = (0, dx -1, 0, dy -1, 0, 0) | 131 | + extent = (0, dx - 1, 0, dy - 1, 0, 0) |
105 | 132 | ||
106 | # Generating the vtkImageData | 133 | # Generating the vtkImageData |
107 | image = vtk.vtkImageData() | 134 | image = vtk.vtkImageData() |
@@ -122,27 +149,34 @@ def np_rgba_to_vtk(n_array, spacing=(1.0, 1.0, 1.0)): | @@ -122,27 +149,34 @@ def np_rgba_to_vtk(n_array, spacing=(1.0, 1.0, 1.0)): | ||
122 | # Based on http://gdcm.sourceforge.net/html/ConvertNumpy_8py-example.html | 149 | # Based on http://gdcm.sourceforge.net/html/ConvertNumpy_8py-example.html |
123 | def gdcm_to_numpy(image, apply_intercep_scale=True): | 150 | def gdcm_to_numpy(image, apply_intercep_scale=True): |
124 | map_gdcm_np = { | 151 | map_gdcm_np = { |
125 | - gdcm.PixelFormat.UINT8 :np.uint8, | ||
126 | - gdcm.PixelFormat.INT8 :np.int8, | ||
127 | - gdcm.PixelFormat.UINT12 :np.uint16, | ||
128 | - gdcm.PixelFormat.INT12 :np.int16, | ||
129 | - gdcm.PixelFormat.UINT16 :np.uint16, | ||
130 | - gdcm.PixelFormat.INT16 :np.int16, | ||
131 | - gdcm.PixelFormat.UINT32 :np.uint32, | ||
132 | - gdcm.PixelFormat.INT32 :np.int32, | ||
133 | - #gdcm.PixelFormat.FLOAT16:np.float16, | ||
134 | - gdcm.PixelFormat.FLOAT32:np.float32, | ||
135 | - gdcm.PixelFormat.FLOAT64:np.float64, | 152 | + gdcm.PixelFormat.UINT8: np.uint8, |
153 | + gdcm.PixelFormat.INT8: np.int8, | ||
154 | + gdcm.PixelFormat.UINT12: np.uint16, | ||
155 | + gdcm.PixelFormat.INT12: np.int16, | ||
156 | + gdcm.PixelFormat.UINT16: np.uint16, | ||
157 | + gdcm.PixelFormat.INT16: np.int16, | ||
158 | + gdcm.PixelFormat.UINT32: np.uint32, | ||
159 | + gdcm.PixelFormat.INT32: np.int32, | ||
160 | + # gdcm.PixelFormat.FLOAT16:np.float16, | ||
161 | + gdcm.PixelFormat.FLOAT32: np.float32, | ||
162 | + gdcm.PixelFormat.FLOAT64: np.float64, | ||
136 | } | 163 | } |
137 | 164 | ||
138 | pf = image.GetPixelFormat() | 165 | pf = image.GetPixelFormat() |
139 | if image.GetNumberOfDimensions() == 3: | 166 | if image.GetNumberOfDimensions() == 3: |
140 | - shape = image.GetDimension(2), image.GetDimension(1), image.GetDimension(0), pf.GetSamplesPerPixel() | 167 | + shape = ( |
168 | + image.GetDimension(2), | ||
169 | + image.GetDimension(1), | ||
170 | + image.GetDimension(0), | ||
171 | + pf.GetSamplesPerPixel(), | ||
172 | + ) | ||
141 | else: | 173 | else: |
142 | shape = image.GetDimension(1), image.GetDimension(0), pf.GetSamplesPerPixel() | 174 | shape = image.GetDimension(1), image.GetDimension(0), pf.GetSamplesPerPixel() |
143 | dtype = map_gdcm_np[pf.GetScalarType()] | 175 | dtype = map_gdcm_np[pf.GetScalarType()] |
144 | gdcm_array = image.GetBuffer() | 176 | gdcm_array = image.GetBuffer() |
145 | - np_array = np.frombuffer(gdcm_array.encode('utf-8', errors="surrogateescape"), dtype=dtype) | 177 | + np_array = np.frombuffer( |
178 | + gdcm_array.encode("utf-8", errors="surrogateescape"), dtype=dtype | ||
179 | + ) | ||
146 | np_array.shape = shape | 180 | np_array.shape = shape |
147 | np_array = np_array.squeeze() | 181 | np_array = np_array.squeeze() |
148 | 182 |
invesalius/reader/dicom.py
1 | -#--------------------------------------------------------------------- | 1 | +# --------------------------------------------------------------------- |
2 | # Software: InVesalius Software de Reconstrucao 3D de Imagens Medicas | 2 | # Software: InVesalius Software de Reconstrucao 3D de Imagens Medicas |
3 | # Copyright: (c) 2001 Centro de Pesquisas Renato Archer | 3 | # Copyright: (c) 2001 Centro de Pesquisas Renato Archer |
4 | # Homepage: http://www.softwarepublico.gov.br | 4 | # Homepage: http://www.softwarepublico.gov.br |
@@ -16,12 +16,14 @@ | @@ -16,12 +16,14 @@ | ||
16 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | 16 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM |
17 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | 17 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais |
18 | # detalhes. | 18 | # detalhes. |
19 | -#--------------------------------------------------------------------- | ||
20 | -import time | ||
21 | -#import gdcm | 19 | +# --------------------------------------------------------------------- |
20 | +# import gdcm | ||
22 | import sys | 21 | import sys |
23 | -import invesalius.utils as utils | 22 | +import time |
23 | + | ||
24 | import invesalius.constants as const | 24 | import invesalius.constants as const |
25 | +import invesalius.utils as utils | ||
26 | + | ||
25 | # In DICOM file format, if multiple values are present for the | 27 | # In DICOM file format, if multiple values are present for the |
26 | # "Window Center" (Level) and "Window Width", both attributes | 28 | # "Window Center" (Level) and "Window Width", both attributes |
27 | # shall have the same number of values and shall be considered as | 29 | # shall have the same number of values and shall be considered as |
@@ -30,48 +32,49 @@ import invesalius.constants as const | @@ -30,48 +32,49 @@ import invesalius.constants as const | ||
30 | # one pair per time. This pair is determined by WL_PRESET | 32 | # one pair per time. This pair is determined by WL_PRESET |
31 | # constant or might be set by the user when calling GetWindowWidth | 33 | # constant or might be set by the user when calling GetWindowWidth |
32 | # and GetWindowLevel. | 34 | # and GetWindowLevel. |
33 | -WL_PRESET = 0 # index of selected window and level tuple (if multiple) | ||
34 | -WL_MULT = 0 # allow selection of multiple window and level tuples if 1 | 35 | +WL_PRESET = 0 # index of selected window and level tuple (if multiple) |
36 | +WL_MULT = 0 # allow selection of multiple window and level tuples if 1 | ||
35 | 37 | ||
36 | # dictionary to be used by module functions | 38 | # dictionary to be used by module functions |
37 | info = {} | 39 | info = {} |
38 | # keys to be used to generate dictionary info | 40 | # keys to be used to generate dictionary info |
39 | -INFO_KEYS = \ | ||
40 | -['AcquisitionDate', | ||
41 | - 'AcquisitionGantryTilt', | ||
42 | - 'AcquisitionModality', | ||
43 | - 'AcquisitionNumber', | ||
44 | - 'AcquisionSequence', | ||
45 | - 'AcquisitionTime', | ||
46 | - 'EquipmentKVP', | ||
47 | - 'EquipmentInstitutionName', | ||
48 | - 'EquipmentManufacturer', | ||
49 | - 'EquipmentXRayTubeCurrent', | ||
50 | - 'ImageColumnOrientation', | ||
51 | - 'ImageConvolutionKernel', | ||
52 | - 'ImageDataType', | ||
53 | - 'ImageLocation', | ||
54 | - 'ImageNumber', | ||
55 | - 'ImagePixelSpacingX', | ||
56 | - 'ImagePixelSpacingY', | ||
57 | - 'ImagePosition', | ||
58 | - 'ImageRowOrientation', | ||
59 | - 'ImageSamplesPerPixel', | ||
60 | - 'ImageSeriesNumber', | ||
61 | - 'ImageThickness', | ||
62 | - 'ImageWindowLevel', | ||
63 | - 'ImageWindowWidth', | ||
64 | - 'PatientAge', | ||
65 | - 'PatientBirthDate', | ||
66 | - 'PatientGender', | ||
67 | - 'PatientName', | ||
68 | - 'PhysicianName', | ||
69 | - 'StudyID', | ||
70 | - 'StudyInstanceUID', | ||
71 | - 'StudyAdmittingDiagnosis', | ||
72 | - ] | ||
73 | - | ||
74 | -class Parser(): | 41 | +INFO_KEYS = [ |
42 | + "AcquisitionDate", | ||
43 | + "AcquisitionGantryTilt", | ||
44 | + "AcquisitionModality", | ||
45 | + "AcquisitionNumber", | ||
46 | + "AcquisionSequence", | ||
47 | + "AcquisitionTime", | ||
48 | + "EquipmentKVP", | ||
49 | + "EquipmentInstitutionName", | ||
50 | + "EquipmentManufacturer", | ||
51 | + "EquipmentXRayTubeCurrent", | ||
52 | + "ImageColumnOrientation", | ||
53 | + "ImageConvolutionKernel", | ||
54 | + "ImageDataType", | ||
55 | + "ImageLocation", | ||
56 | + "ImageNumber", | ||
57 | + "ImagePixelSpacingX", | ||
58 | + "ImagePixelSpacingY", | ||
59 | + "ImagePosition", | ||
60 | + "ImageRowOrientation", | ||
61 | + "ImageSamplesPerPixel", | ||
62 | + "ImageSeriesNumber", | ||
63 | + "ImageThickness", | ||
64 | + "ImageWindowLevel", | ||
65 | + "ImageWindowWidth", | ||
66 | + "PatientAge", | ||
67 | + "PatientBirthDate", | ||
68 | + "PatientGender", | ||
69 | + "PatientName", | ||
70 | + "PhysicianName", | ||
71 | + "StudyID", | ||
72 | + "StudyInstanceUID", | ||
73 | + "StudyAdmittingDiagnosis", | ||
74 | +] | ||
75 | + | ||
76 | + | ||
77 | +class Parser: | ||
75 | """ | 78 | """ |
76 | Medical image parser. Used to parse medical image tags. | 79 | Medical image parser. Used to parse medical image tags. |
77 | It supports: | 80 | It supports: |
@@ -92,13 +95,13 @@ class Parser(): | @@ -92,13 +95,13 @@ class Parser(): | ||
92 | self.encoding = "" | 95 | self.encoding = "" |
93 | self.filepath = "" | 96 | self.filepath = "" |
94 | 97 | ||
95 | - #def SetFileName(self, filename): | 98 | + # def SetFileName(self, filename): |
96 | """ | 99 | """ |
97 | Set file name to be parsed given its filename (this should | 100 | Set file name to be parsed given its filename (this should |
98 | include the full path of the file of interest). | 101 | include the full path of the file of interest). |
99 | 102 | ||
100 | Return True/False if file could be read. | 103 | Return True/False if file could be read. |
101 | - | 104 | + |
102 | import os.path as path | 105 | import os.path as path |
103 | 106 | ||
104 | 107 | ||
@@ -134,28 +137,26 @@ class Parser(): | @@ -134,28 +137,26 @@ class Parser(): | ||
134 | 137 | ||
135 | return False""" | 138 | return False""" |
136 | 139 | ||
137 | - #def GetImageData(self): | 140 | + # def GetImageData(self): |
138 | # return None#self.vtkgdcm_reader.GetOutput() | 141 | # return None#self.vtkgdcm_reader.GetOutput() |
139 | 142 | ||
140 | - | ||
141 | def SetDataImage(self, data_image, filename, thumbnail_path): | 143 | def SetDataImage(self, data_image, filename, thumbnail_path): |
142 | self.data_image = data_image | 144 | self.data_image = data_image |
143 | self.filename = self.filepath = filename | 145 | self.filename = self.filepath = filename |
144 | self.thumbnail_path = thumbnail_path | 146 | self.thumbnail_path = thumbnail_path |
145 | 147 | ||
146 | - def __format_time(self,value): | 148 | + def __format_time(self, value): |
147 | sp1 = value.split(".") | 149 | sp1 = value.split(".") |
148 | sp2 = value.split(":") | 150 | sp2 = value.split(":") |
149 | 151 | ||
150 | - if (len(sp1) == 2) and (len(sp2) == 3): | ||
151 | - new_value = str(sp2[0]+sp2[1]+ | ||
152 | - str(int(float(sp2[2])))) | 152 | + if (len(sp1) == 2) and (len(sp2) == 3): |
153 | + new_value = str(sp2[0] + sp2[1] + str(int(float(sp2[2])))) | ||
153 | data = time.strptime(new_value, "%H%M%S") | 154 | data = time.strptime(new_value, "%H%M%S") |
154 | - elif (len(sp1) == 2): | 155 | + elif len(sp1) == 2: |
155 | data = time.gmtime(float(value)) | 156 | data = time.gmtime(float(value)) |
156 | - elif (len(sp1) > 2): | 157 | + elif len(sp1) > 2: |
157 | data = time.strptime(value, "%H.%M.%S") | 158 | data = time.strptime(value, "%H.%M.%S") |
158 | - elif(len(sp2) > 1): | 159 | + elif len(sp2) > 1: |
159 | data = time.strptime(value, "%H:%M:%S") | 160 | data = time.strptime(value, "%H:%M:%S") |
160 | else: | 161 | else: |
161 | try: | 162 | try: |
@@ -163,26 +164,26 @@ class Parser(): | @@ -163,26 +164,26 @@ class Parser(): | ||
163 | # If the time is not in a bad format only return it. | 164 | # If the time is not in a bad format only return it. |
164 | except ValueError: | 165 | except ValueError: |
165 | return value | 166 | return value |
166 | - return time.strftime("%H:%M:%S",data) | 167 | + return time.strftime("%H:%M:%S", data) |
167 | 168 | ||
168 | def __format_date(self, value): | 169 | def __format_date(self, value): |
169 | 170 | ||
170 | sp1 = value.split(".") | 171 | sp1 = value.split(".") |
171 | try: | 172 | try: |
172 | 173 | ||
173 | - if (len(sp1) > 1): | ||
174 | - if (len(sp1[0]) <= 2): | 174 | + if len(sp1) > 1: |
175 | + if len(sp1[0]) <= 2: | ||
175 | data = time.strptime(value, "%D.%M.%Y") | 176 | data = time.strptime(value, "%D.%M.%Y") |
176 | else: | 177 | else: |
177 | data = time.strptime(value, "%Y.%M.%d") | 178 | data = time.strptime(value, "%Y.%M.%d") |
178 | - elif(len(value.split("//")) > 1): | 179 | + elif len(value.split("//")) > 1: |
179 | data = time.strptime(value, "%D/%M/%Y") | 180 | data = time.strptime(value, "%D/%M/%Y") |
180 | else: | 181 | else: |
181 | data = time.strptime(value, "%Y%M%d") | 182 | data = time.strptime(value, "%Y%M%d") |
182 | - return time.strftime("%d/%M/%Y",data) | 183 | + return time.strftime("%d/%M/%Y", data) |
183 | 184 | ||
184 | - except(ValueError): | ||
185 | - return "" | 185 | + except (ValueError): |
186 | + return "" | ||
186 | 187 | ||
187 | def GetImageOrientationLabel(self): | 188 | def GetImageOrientationLabel(self): |
188 | """ | 189 | """ |
@@ -190,9 +191,9 @@ class Parser(): | @@ -190,9 +191,9 @@ class Parser(): | ||
190 | an image. (AXIAL, SAGITTAL, CORONAL, | 191 | an image. (AXIAL, SAGITTAL, CORONAL, |
191 | OBLIQUE or UNKNOWN) | 192 | OBLIQUE or UNKNOWN) |
192 | """ | 193 | """ |
193 | - label = self.data_image['invesalius']['orientation_label'] | 194 | + label = self.data_image["invesalius"]["orientation_label"] |
194 | 195 | ||
195 | - if (label): | 196 | + if label: |
196 | return label | 197 | return label |
197 | else: | 198 | else: |
198 | return "" | 199 | return "" |
@@ -204,11 +205,10 @@ class Parser(): | @@ -204,11 +205,10 @@ class Parser(): | ||
204 | Return "" if not defined. | 205 | Return "" if not defined. |
205 | """ | 206 | """ |
206 | data = self.data_image[str(0x028)][str(0x011)] | 207 | data = self.data_image[str(0x028)][str(0x011)] |
207 | - if (data): | 208 | + if data: |
208 | return int(str(data)) | 209 | return int(str(data)) |
209 | return "" | 210 | return "" |
210 | 211 | ||
211 | - | ||
212 | def GetDimensionY(self): | 212 | def GetDimensionY(self): |
213 | """ | 213 | """ |
214 | Return integer associated to Y dimension. This is related | 214 | Return integer associated to Y dimension. This is related |
@@ -216,12 +216,11 @@ class Parser(): | @@ -216,12 +216,11 @@ class Parser(): | ||
216 | Return "" if not defined. | 216 | Return "" if not defined. |
217 | """ | 217 | """ |
218 | data = self.data_image[str(0x028)][str(0x010)] | 218 | data = self.data_image[str(0x028)][str(0x010)] |
219 | - if (data): | 219 | + if data: |
220 | return int(str(data)) | 220 | return int(str(data)) |
221 | return "" | 221 | return "" |
222 | 222 | ||
223 | - | ||
224 | - #def GetDimensionZ(self): | 223 | + # def GetDimensionZ(self): |
225 | # """ | 224 | # """ |
226 | # Return float value associated to Z dimension. | 225 | # Return float value associated to Z dimension. |
227 | # Return "" if not defined. | 226 | # Return "" if not defined. |
@@ -291,7 +290,6 @@ class Parser(): | @@ -291,7 +290,6 @@ class Parser(): | ||
291 | return spacing[0] | 290 | return spacing[0] |
292 | return "" | 291 | return "" |
293 | 292 | ||
294 | - | ||
295 | def GetAcquisitionDate(self): | 293 | def GetAcquisitionDate(self): |
296 | """ | 294 | """ |
297 | Return string containing the acquisition date using the | 295 | Return string containing the acquisition date using the |
@@ -302,11 +300,11 @@ class Parser(): | @@ -302,11 +300,11 @@ class Parser(): | ||
302 | """ | 300 | """ |
303 | # TODO: internationalize data | 301 | # TODO: internationalize data |
304 | try: | 302 | try: |
305 | - date = self.data_image[str(0x0008)][str(0x0022)] | ||
306 | - except(KeyError): | 303 | + date = self.data_image[str(0x0008)][str(0x0022)] |
304 | + except (KeyError): | ||
307 | return "" | 305 | return "" |
308 | 306 | ||
309 | - if (date) and (date != ''): | 307 | + if (date) and (date != ""): |
310 | return self.__format_date(str(date)) | 308 | return self.__format_date(str(date)) |
311 | return "" | 309 | return "" |
312 | 310 | ||
@@ -317,8 +315,8 @@ class Parser(): | @@ -317,8 +315,8 @@ class Parser(): | ||
317 | 315 | ||
318 | DICOM standard tag (0x0020, 0x0012) was used. | 316 | DICOM standard tag (0x0020, 0x0012) was used. |
319 | """ | 317 | """ |
320 | - data = self.data_image[str(0x0020)][str(0x0012)] | ||
321 | - if (data): | 318 | + data = self.data_image[str(0x0020)][str(0x0012)] |
319 | + if data: | ||
322 | return int(str(data)) | 320 | return int(str(data)) |
323 | return "" | 321 | return "" |
324 | 322 | ||
@@ -328,12 +326,12 @@ class Parser(): | @@ -328,12 +326,12 @@ class Parser(): | ||
328 | 326 | ||
329 | DICOM standard tag (0x0008, 0x0050) was used. | 327 | DICOM standard tag (0x0008, 0x0050) was used. |
330 | """ | 328 | """ |
331 | - #data = self.data_image[0x008][0x050] | 329 | + # data = self.data_image[0x008][0x050] |
332 | return "" | 330 | return "" |
333 | - if (data): | 331 | + if data: |
334 | try: | 332 | try: |
335 | value = int(str(data)) | 333 | value = int(str(data)) |
336 | - except(ValueError): #Problem in the other\iCatDanielaProjeto | 334 | + except (ValueError): # Problem in the other\iCatDanielaProjeto |
337 | value = 0 | 335 | value = 0 |
338 | return value | 336 | return value |
339 | return "" | 337 | return "" |
@@ -347,7 +345,7 @@ class Parser(): | @@ -347,7 +345,7 @@ class Parser(): | ||
347 | DICOM standard tag (0x0008,0x0032) was used. | 345 | DICOM standard tag (0x0008,0x0032) was used. |
348 | """ | 346 | """ |
349 | data = self.data_image[str(0x008)][str(0x032)] | 347 | data = self.data_image[str(0x008)][str(0x032)] |
350 | - if (data) and (data != ''): | 348 | + if (data) and (data != ""): |
351 | return self.__format_time(str(data)) | 349 | return self.__format_time(str(data)) |
352 | return "" | 350 | return "" |
353 | 351 | ||
@@ -363,11 +361,10 @@ class Parser(): | @@ -363,11 +361,10 @@ class Parser(): | ||
363 | sf.SetFile(self.gdcm_reader.GetFile()) | 361 | sf.SetFile(self.gdcm_reader.GetFile()) |
364 | res = sf.ToStringPair(tag) | 362 | res = sf.ToStringPair(tag) |
365 | 363 | ||
366 | - if (res[1]): | 364 | + if res[1]: |
367 | return int(res[1]) | 365 | return int(res[1]) |
368 | return "" | 366 | return "" |
369 | 367 | ||
370 | - | ||
371 | def GetImageWindowLevel(self, preset=WL_PRESET, multiple=WL_MULT): | 368 | def GetImageWindowLevel(self, preset=WL_PRESET, multiple=WL_MULT): |
372 | """ | 369 | """ |
373 | Return image window center / level (related to brightness). | 370 | Return image window center / level (related to brightness). |
@@ -382,15 +379,15 @@ class Parser(): | @@ -382,15 +379,15 @@ class Parser(): | ||
382 | """ | 379 | """ |
383 | try: | 380 | try: |
384 | data = self.data_image[str(0x028)][str(0x1050)] | 381 | data = self.data_image[str(0x028)][str(0x1050)] |
385 | - except(KeyError): | 382 | + except (KeyError): |
386 | return "300" | 383 | return "300" |
387 | - if (data): | 384 | + if data: |
388 | # Usually 'data' is a number. However, in some DICOM | 385 | # Usually 'data' is a number. However, in some DICOM |
389 | # files, there are several values separated by '\'. | 386 | # files, there are several values separated by '\'. |
390 | # If multiple values are present for the "Window Center" | 387 | # If multiple values are present for the "Window Center" |
391 | # we choose only one. As this should be paired to "Window | 388 | # we choose only one. As this should be paired to "Window |
392 | # Width", it is set based on WL_PRESET | 389 | # Width", it is set based on WL_PRESET |
393 | - value_list = [float(value) for value in data.split('\\')] | 390 | + value_list = [float(value) for value in data.split("\\")] |
394 | if multiple: | 391 | if multiple: |
395 | return value_list | 392 | return value_list |
396 | else: | 393 | else: |
@@ -414,16 +411,16 @@ class Parser(): | @@ -414,16 +411,16 @@ class Parser(): | ||
414 | """ | 411 | """ |
415 | try: | 412 | try: |
416 | data = self.data_image[str(0x028)][str(0x1051)] | 413 | data = self.data_image[str(0x028)][str(0x1051)] |
417 | - except(KeyError): | 414 | + except (KeyError): |
418 | return "2000" | 415 | return "2000" |
419 | 416 | ||
420 | - if (data): | 417 | + if data: |
421 | # Usually 'data' is a number. However, in some DICOM | 418 | # Usually 'data' is a number. However, in some DICOM |
422 | # files, there are several values separated by '\'. | 419 | # files, there are several values separated by '\'. |
423 | # If multiple values are present for the "Window Center" | 420 | # If multiple values are present for the "Window Center" |
424 | # we choose only one. As this should be paired to "Window | 421 | # we choose only one. As this should be paired to "Window |
425 | # Width", it is set based on WL_PRESET | 422 | # Width", it is set based on WL_PRESET |
426 | - value_list = [float(value) for value in data.split('\\')] | 423 | + value_list = [float(value) for value in data.split("\\")] |
427 | 424 | ||
428 | if multiple: | 425 | if multiple: |
429 | return str(value_list) | 426 | return str(value_list) |
@@ -443,10 +440,10 @@ class Parser(): | @@ -443,10 +440,10 @@ class Parser(): | ||
443 | """ | 440 | """ |
444 | try: | 441 | try: |
445 | data = self.data_image[str(0x020)][str(0x032)].replace(",", ".") | 442 | data = self.data_image[str(0x020)][str(0x032)].replace(",", ".") |
446 | - except(KeyError): | 443 | + except (KeyError): |
447 | return "" | 444 | return "" |
448 | - if (data): | ||
449 | - return [eval(value) for value in data.split('\\')] | 445 | + if data: |
446 | + return [eval(value) for value in data.split("\\")] | ||
450 | return "" | 447 | return "" |
451 | 448 | ||
452 | def GetImageLocation(self): | 449 | def GetImageLocation(self): |
@@ -458,7 +455,7 @@ class Parser(): | @@ -458,7 +455,7 @@ class Parser(): | ||
458 | DICOM standard tag (0x0020, 0x0032) was used. | 455 | DICOM standard tag (0x0020, 0x0032) was used. |
459 | """ | 456 | """ |
460 | data = self.data_image[str(0x020)][str(0x1041)] | 457 | data = self.data_image[str(0x020)][str(0x1041)] |
461 | - if (data): | 458 | + if data: |
462 | return eval(data) | 459 | return eval(data) |
463 | return "" | 460 | return "" |
464 | 461 | ||
@@ -470,15 +467,14 @@ class Parser(): | @@ -470,15 +467,14 @@ class Parser(): | ||
470 | DICOM standard tag (0x7fe0, 0x0010) was used. | 467 | DICOM standard tag (0x7fe0, 0x0010) was used. |
471 | """ | 468 | """ |
472 | try: | 469 | try: |
473 | - data = self.data_image[str(0x7fe0)][str(0x0010)] | ||
474 | - except(KeyError): | 470 | + data = self.data_image[str(0x7FE0)][str(0x0010)] |
471 | + except (KeyError): | ||
475 | return "" | 472 | return "" |
476 | 473 | ||
477 | - if (data): | ||
478 | - return int(data.split(':')[1]) | 474 | + if data: |
475 | + return int(data.split(":")[1]) | ||
479 | return "" | 476 | return "" |
480 | 477 | ||
481 | - | ||
482 | def GetImageSeriesNumber(self): | 478 | def GetImageSeriesNumber(self): |
483 | """ | 479 | """ |
484 | Return integer related to acquisition series where this | 480 | Return integer related to acquisition series where this |
@@ -489,14 +485,13 @@ class Parser(): | @@ -489,14 +485,13 @@ class Parser(): | ||
489 | """ | 485 | """ |
490 | try: | 486 | try: |
491 | data = self.data_image[str(0x020)][str(0x011)] | 487 | data = self.data_image[str(0x020)][str(0x011)] |
492 | - except(KeyError): | 488 | + except (KeyError): |
493 | return "" | 489 | return "" |
494 | 490 | ||
495 | if (data) and (data != '""') and (data != "None"): | 491 | if (data) and (data != '""') and (data != "None"): |
496 | return int(data) | 492 | return int(data) |
497 | return "" | 493 | return "" |
498 | 494 | ||
499 | - | ||
500 | def GetPixelSpacing(self): | 495 | def GetPixelSpacing(self): |
501 | """ | 496 | """ |
502 | Return [x, y] (number list) related to the distance between | 497 | Return [x, y] (number list) related to the distance between |
@@ -508,7 +503,7 @@ class Parser(): | @@ -508,7 +503,7 @@ class Parser(): | ||
508 | DICOM standard tag (0x0028, 0x0030) was used. | 503 | DICOM standard tag (0x0028, 0x0030) was used. |
509 | """ | 504 | """ |
510 | try: | 505 | try: |
511 | - image_helper_spacing = self.data_image["spacing"] | 506 | + image_helper_spacing = self.data_image["spacing"] |
512 | except KeyError: | 507 | except KeyError: |
513 | image_helper_spacing = None | 508 | image_helper_spacing = None |
514 | try: | 509 | try: |
@@ -516,7 +511,9 @@ class Parser(): | @@ -516,7 +511,9 @@ class Parser(): | ||
516 | except KeyError: | 511 | except KeyError: |
517 | tag_spacing = "" | 512 | tag_spacing = "" |
518 | 513 | ||
519 | - # Some dicom images have comma (,) as decimal separation. In this case InVesalius is not using the spacing given by gdcm.ImageHelper but using direct from the tag and replacing the comma with dot. | 514 | + # Some dicom images have comma (,) as decimal separation. In this case |
515 | + # InVesalius is not using the spacing given by gdcm.ImageHelper but | ||
516 | + # using direct from the tag and replacing the comma with dot. | ||
520 | if image_helper_spacing is not None and "," not in tag_spacing: | 517 | if image_helper_spacing is not None and "," not in tag_spacing: |
521 | return image_helper_spacing[:2] | 518 | return image_helper_spacing[:2] |
522 | else: | 519 | else: |
@@ -531,10 +528,10 @@ class Parser(): | @@ -531,10 +528,10 @@ class Parser(): | ||
531 | """ | 528 | """ |
532 | try: | 529 | try: |
533 | data = self.data_image[str(0x0010)][str(0x1030)] | 530 | data = self.data_image[str(0x0010)][str(0x1030)] |
534 | - except(KeyError): | 531 | + except (KeyError): |
535 | return "" | 532 | return "" |
536 | 533 | ||
537 | - if (data): | 534 | + if data: |
538 | return float(data) | 535 | return float(data) |
539 | return "" | 536 | return "" |
540 | 537 | ||
@@ -547,10 +544,10 @@ class Parser(): | @@ -547,10 +544,10 @@ class Parser(): | ||
547 | """ | 544 | """ |
548 | try: | 545 | try: |
549 | data = self.data_image[str(0x010)][str(0x1020)] | 546 | data = self.data_image[str(0x010)][str(0x1020)] |
550 | - except(KeyError): | 547 | + except (KeyError): |
551 | return "" | 548 | return "" |
552 | 549 | ||
553 | - if (data): | 550 | + if data: |
554 | return float(data) | 551 | return float(data) |
555 | return "" | 552 | return "" |
556 | 553 | ||
@@ -562,9 +559,9 @@ class Parser(): | @@ -562,9 +559,9 @@ class Parser(): | ||
562 | """ | 559 | """ |
563 | try: | 560 | try: |
564 | data = self.data_image[str(0x010)][str(0x1040)] | 561 | data = self.data_image[str(0x010)][str(0x1040)] |
565 | - except(KeyError): | 562 | + except (KeyError): |
566 | return "" | 563 | return "" |
567 | - if (data): | 564 | + if data: |
568 | return data | 565 | return data |
569 | return "" | 566 | return "" |
570 | 567 | ||
@@ -577,9 +574,9 @@ class Parser(): | @@ -577,9 +574,9 @@ class Parser(): | ||
577 | """ | 574 | """ |
578 | try: | 575 | try: |
579 | data = self.data_image[str(0x010)][str(0x1080)] | 576 | data = self.data_image[str(0x010)][str(0x1080)] |
580 | - except(KeyError): | 577 | + except (KeyError): |
581 | return "" | 578 | return "" |
582 | - if (data): | 579 | + if data: |
583 | return data | 580 | return data |
584 | return "" | 581 | return "" |
585 | 582 | ||
@@ -594,9 +591,9 @@ class Parser(): | @@ -594,9 +591,9 @@ class Parser(): | ||
594 | """ | 591 | """ |
595 | try: | 592 | try: |
596 | data = self.data_image[str(0x010)][str(0x1081)] | 593 | data = self.data_image[str(0x010)][str(0x1081)] |
597 | - except(KeyError): | 594 | + except (KeyError): |
598 | return "" | 595 | return "" |
599 | - if (data): | 596 | + if data: |
600 | return data | 597 | return data |
601 | return "" | 598 | return "" |
602 | 599 | ||
@@ -610,10 +607,10 @@ class Parser(): | @@ -610,10 +607,10 @@ class Parser(): | ||
610 | """ | 607 | """ |
611 | try: | 608 | try: |
612 | data = self.data_image[str(0x0010)][str(0x2150)] | 609 | data = self.data_image[str(0x0010)][str(0x2150)] |
613 | - except(KeyError): | 610 | + except (KeyError): |
614 | return "" | 611 | return "" |
615 | 612 | ||
616 | - if (data): | 613 | + if data: |
617 | return data | 614 | return data |
618 | return "" | 615 | return "" |
619 | 616 | ||
@@ -627,10 +624,10 @@ class Parser(): | @@ -627,10 +624,10 @@ class Parser(): | ||
627 | """ | 624 | """ |
628 | try: | 625 | try: |
629 | data = self.data_image[str(0x0010)][str(0x2152)] | 626 | data = self.data_image[str(0x0010)][str(0x2152)] |
630 | - except(KeyError): | 627 | + except (KeyError): |
631 | return "" | 628 | return "" |
632 | 629 | ||
633 | - if (data): | 630 | + if data: |
634 | return data | 631 | return data |
635 | return "" | 632 | return "" |
636 | 633 | ||
@@ -643,10 +640,10 @@ class Parser(): | @@ -643,10 +640,10 @@ class Parser(): | ||
643 | """ | 640 | """ |
644 | try: | 641 | try: |
645 | data = self.data_image[str(0x0010)][str(0x2154)] | 642 | data = self.data_image[str(0x0010)][str(0x2154)] |
646 | - except(KeyError): | 643 | + except (KeyError): |
647 | return "" | 644 | return "" |
648 | 645 | ||
649 | - if (data): | 646 | + if data: |
650 | return data | 647 | return data |
651 | return "" | 648 | return "" |
652 | 649 | ||
@@ -660,10 +657,10 @@ class Parser(): | @@ -660,10 +657,10 @@ class Parser(): | ||
660 | """ | 657 | """ |
661 | try: | 658 | try: |
662 | data = self.data_image[str(0x0010)][str(0x2297)] | 659 | data = self.data_image[str(0x0010)][str(0x2297)] |
663 | - except(KeyError): | 660 | + except (KeyError): |
664 | return "" | 661 | return "" |
665 | 662 | ||
666 | - if (data): | 663 | + if data: |
667 | return data | 664 | return data |
668 | return "" | 665 | return "" |
669 | 666 | ||
@@ -676,11 +673,11 @@ class Parser(): | @@ -676,11 +673,11 @@ class Parser(): | ||
676 | DICOM standard tag (0x0010, 0x2298) was used. | 673 | DICOM standard tag (0x0010, 0x2298) was used. |
677 | """ | 674 | """ |
678 | try: | 675 | try: |
679 | - data = self.data_image[str(0x0010)][str(0x2298)] | ||
680 | - except(KeyError): | 676 | + data = self.data_image[str(0x0010)][str(0x2298)] |
677 | + except (KeyError): | ||
681 | return "" | 678 | return "" |
682 | 679 | ||
683 | - if (data): | 680 | + if data: |
684 | return data | 681 | return data |
685 | return "" | 682 | return "" |
686 | 683 | ||
@@ -694,10 +691,10 @@ class Parser(): | @@ -694,10 +691,10 @@ class Parser(): | ||
694 | """ | 691 | """ |
695 | try: | 692 | try: |
696 | data = self.data_image[str(0x0010)][str(0x2299)] | 693 | data = self.data_image[str(0x0010)][str(0x2299)] |
697 | - except(KeyError): | 694 | + except (KeyError): |
698 | return "" | 695 | return "" |
699 | 696 | ||
700 | - if (data): | 697 | + if data: |
701 | return data | 698 | return data |
702 | return "" | 699 | return "" |
703 | 700 | ||
@@ -711,10 +708,10 @@ class Parser(): | @@ -711,10 +708,10 @@ class Parser(): | ||
711 | """ | 708 | """ |
712 | try: | 709 | try: |
713 | data = self.data_image[str(0x0010)][str(0x2000)] | 710 | data = self.data_image[str(0x0010)][str(0x2000)] |
714 | - except(KeyError): | 711 | + except (KeyError): |
715 | return "" | 712 | return "" |
716 | 713 | ||
717 | - if (data): | 714 | + if data: |
718 | return data | 715 | return data |
719 | return "" | 716 | return "" |
720 | 717 | ||
@@ -727,15 +724,14 @@ class Parser(): | @@ -727,15 +724,14 @@ class Parser(): | ||
727 | DICOM standard tag (0x0008, 0x2110) was used. | 724 | DICOM standard tag (0x0008, 0x2110) was used. |
728 | """ | 725 | """ |
729 | try: | 726 | try: |
730 | - data = self.data_image[str(0x0008)][str(0x2110)] | ||
731 | - except(KeyError): | 727 | + data = self.data_image[str(0x0008)][str(0x2110)] |
728 | + except (KeyError): | ||
732 | return "" | 729 | return "" |
733 | 730 | ||
734 | - if (data): | 731 | + if data: |
735 | return data | 732 | return data |
736 | return "" | 733 | return "" |
737 | 734 | ||
738 | - | ||
739 | def GetPhysicianReferringName(self): | 735 | def GetPhysicianReferringName(self): |
740 | """ | 736 | """ |
741 | Return string containing physician | 737 | Return string containing physician |
@@ -746,16 +742,15 @@ class Parser(): | @@ -746,16 +742,15 @@ class Parser(): | ||
746 | """ | 742 | """ |
747 | try: | 743 | try: |
748 | data = self.data_image[str(0x0008)][str(0x0090)] | 744 | data = self.data_image[str(0x0008)][str(0x0090)] |
749 | - except(KeyError): | 745 | + except (KeyError): |
750 | return "" | 746 | return "" |
751 | 747 | ||
752 | if data == "None": | 748 | if data == "None": |
753 | return "" | 749 | return "" |
754 | - if (data): | 750 | + if data: |
755 | return data | 751 | return data |
756 | return "" | 752 | return "" |
757 | 753 | ||
758 | - | ||
759 | def GetPhysicianReferringAddress(self): | 754 | def GetPhysicianReferringAddress(self): |
760 | """ | 755 | """ |
761 | Return string containing physician's address. | 756 | Return string containing physician's address. |
@@ -765,10 +760,10 @@ class Parser(): | @@ -765,10 +760,10 @@ class Parser(): | ||
765 | """ | 760 | """ |
766 | try: | 761 | try: |
767 | data = self.data_image[str(0x0008)][str(0x0092)] | 762 | data = self.data_image[str(0x0008)][str(0x0092)] |
768 | - except(KeyError): | 763 | + except (KeyError): |
769 | return "" | 764 | return "" |
770 | 765 | ||
771 | - if (data): | 766 | + if data: |
772 | return data | 767 | return data |
773 | return "" | 768 | return "" |
774 | 769 | ||
@@ -781,10 +776,10 @@ class Parser(): | @@ -781,10 +776,10 @@ class Parser(): | ||
781 | """ | 776 | """ |
782 | try: | 777 | try: |
783 | data = self.data_image[str(0x0008)][str(0x0094)] | 778 | data = self.data_image[str(0x0008)][str(0x0094)] |
784 | - except(KeyError): | 779 | + except (KeyError): |
785 | return "" | 780 | return "" |
786 | - | ||
787 | - if (data): | 781 | + |
782 | + if data: | ||
788 | return data | 783 | return data |
789 | return "" | 784 | return "" |
790 | 785 | ||
@@ -797,10 +792,10 @@ class Parser(): | @@ -797,10 +792,10 @@ class Parser(): | ||
797 | """ | 792 | """ |
798 | try: | 793 | try: |
799 | data = self.data_image[str(0x0018)][str(0x1030)] | 794 | data = self.data_image[str(0x0018)][str(0x1030)] |
800 | - except(KeyError): | 795 | + except (KeyError): |
801 | return None | 796 | return None |
802 | 797 | ||
803 | - if (data): | 798 | + if data: |
804 | return data | 799 | return data |
805 | return None | 800 | return None |
806 | 801 | ||
@@ -815,17 +810,17 @@ class Parser(): | @@ -815,17 +810,17 @@ class Parser(): | ||
815 | """ | 810 | """ |
816 | try: | 811 | try: |
817 | data = self.data_image[str(0x008)][str(0x008)] | 812 | data = self.data_image[str(0x008)][str(0x008)] |
818 | - except(IndexError): | 813 | + except (IndexError): |
819 | return [] | 814 | return [] |
820 | # TODO: Check if set image type to empty is the right way of handling | 815 | # TODO: Check if set image type to empty is the right way of handling |
821 | # the cases where there is not this tag. | 816 | # the cases where there is not this tag. |
822 | except KeyError: | 817 | except KeyError: |
823 | return [] | 818 | return [] |
824 | 819 | ||
825 | - if (data): | 820 | + if data: |
826 | try: | 821 | try: |
827 | - return data.split('\\') | ||
828 | - except(IndexError): | 822 | + return data.split("\\") |
823 | + except (IndexError): | ||
829 | return [] | 824 | return [] |
830 | return [] | 825 | return [] |
831 | 826 | ||
@@ -839,10 +834,10 @@ class Parser(): | @@ -839,10 +834,10 @@ class Parser(): | ||
839 | """ | 834 | """ |
840 | try: | 835 | try: |
841 | data = self.data_image[str(0x0008)][str(0x0016)] | 836 | data = self.data_image[str(0x0008)][str(0x0016)] |
842 | - except(KeyError): | 837 | + except (KeyError): |
843 | return "" | 838 | return "" |
844 | 839 | ||
845 | - if (data): | 840 | + if data: |
846 | return data | 841 | return data |
847 | return "" | 842 | return "" |
848 | 843 | ||
@@ -856,10 +851,10 @@ class Parser(): | @@ -856,10 +851,10 @@ class Parser(): | ||
856 | """ | 851 | """ |
857 | try: | 852 | try: |
858 | data = self.data_image[str(0x0008)][str(0x0018)] | 853 | data = self.data_image[str(0x0008)][str(0x0018)] |
859 | - except(KeyError): | 854 | + except (KeyError): |
860 | return "" | 855 | return "" |
861 | 856 | ||
862 | - if (data): | 857 | + if data: |
863 | return data | 858 | return data |
864 | return "" | 859 | return "" |
865 | 860 | ||
@@ -872,11 +867,11 @@ class Parser(): | @@ -872,11 +867,11 @@ class Parser(): | ||
872 | Critical DICOM Tag (0x0020,0x000D). Cannot be edited. | 867 | Critical DICOM Tag (0x0020,0x000D). Cannot be edited. |
873 | """ | 868 | """ |
874 | try: | 869 | try: |
875 | - data = self.data_image[str(0x0020)][str(0x000D)] | ||
876 | - except(KeyError): | 870 | + data = self.data_image[str(0x0020)][str(0x000D)] |
871 | + except (KeyError): | ||
877 | return "" | 872 | return "" |
878 | 873 | ||
879 | - if (data): | 874 | + if data: |
880 | return data | 875 | return data |
881 | return "" | 876 | return "" |
882 | 877 | ||
@@ -893,11 +888,11 @@ class Parser(): | @@ -893,11 +888,11 @@ class Parser(): | ||
893 | """ | 888 | """ |
894 | try: | 889 | try: |
895 | data = self.data_image[str(0x0020)][str(0x0037)].replace(",", ".") | 890 | data = self.data_image[str(0x0020)][str(0x0037)].replace(",", ".") |
896 | - except(KeyError): | 891 | + except (KeyError): |
897 | return [1.0, 0.0, 0.0, 0.0, 1.0, 0.0] | 892 | return [1.0, 0.0, 0.0, 0.0, 1.0, 0.0] |
898 | 893 | ||
899 | - if (data): | ||
900 | - return [float(value) for value in data.split('\\')] | 894 | + if data: |
895 | + return [float(value) for value in data.split("\\")] | ||
901 | return [1.0, 0.0, 0.0, 0.0, 1.0, 0.0] | 896 | return [1.0, 0.0, 0.0, 0.0, 1.0, 0.0] |
902 | 897 | ||
903 | def GetImageColumnOrientation(self): | 898 | def GetImageColumnOrientation(self): |
@@ -911,11 +906,11 @@ class Parser(): | @@ -911,11 +906,11 @@ class Parser(): | ||
911 | """ | 906 | """ |
912 | try: | 907 | try: |
913 | data = self.data_image[str(0x0020)][str(0x0037)] | 908 | data = self.data_image[str(0x0020)][str(0x0037)] |
914 | - except(KeyError): | 909 | + except (KeyError): |
915 | return [0.0, 1.0, 0.0] | 910 | return [0.0, 1.0, 0.0] |
916 | 911 | ||
917 | - if (data): | ||
918 | - return [float(value) for value in data.split('\\')[3:6]] | 912 | + if data: |
913 | + return [float(value) for value in data.split("\\")[3:6]] | ||
919 | return [0.0, 1.0, 0.0] | 914 | return [0.0, 1.0, 0.0] |
920 | 915 | ||
921 | def GetImageRowOrientation(self): | 916 | def GetImageRowOrientation(self): |
@@ -929,11 +924,11 @@ class Parser(): | @@ -929,11 +924,11 @@ class Parser(): | ||
929 | """ | 924 | """ |
930 | try: | 925 | try: |
931 | data = self.data_image[str(0x0020)][str(0x0037)] | 926 | data = self.data_image[str(0x0020)][str(0x0037)] |
932 | - except(KeyError): | 927 | + except (KeyError): |
933 | return [1.0, 0.0, 0.0] | 928 | return [1.0, 0.0, 0.0] |
934 | 929 | ||
935 | - if (data): | ||
936 | - return [float(value) for value in data.split('\\')[0:3]] | 930 | + if data: |
931 | + return [float(value) for value in data.split("\\")[0:3]] | ||
937 | return [1.0, 0.0, 0.0] | 932 | return [1.0, 0.0, 0.0] |
938 | 933 | ||
939 | def GetFrameReferenceUID(self): | 934 | def GetFrameReferenceUID(self): |
@@ -945,10 +940,10 @@ class Parser(): | @@ -945,10 +940,10 @@ class Parser(): | ||
945 | """ | 940 | """ |
946 | try: | 941 | try: |
947 | data = self.data_image[str(0x0020)][str(0x0052)] | 942 | data = self.data_image[str(0x0020)][str(0x0052)] |
948 | - except(KeyError): | 943 | + except (KeyError): |
949 | return "" | 944 | return "" |
950 | 945 | ||
951 | - if (data): | 946 | + if data: |
952 | return data | 947 | return data |
953 | return "" | 948 | return "" |
954 | 949 | ||
@@ -980,7 +975,7 @@ class Parser(): | @@ -980,7 +975,7 @@ class Parser(): | ||
980 | sf = gdcm.StringFilter() | 975 | sf = gdcm.StringFilter() |
981 | sf.SetFile(self.gdcm_reader.GetFile()) | 976 | sf.SetFile(self.gdcm_reader.GetFile()) |
982 | res = sf.ToStringPair(tag) | 977 | res = sf.ToStringPair(tag) |
983 | - if (res[1]): | 978 | + if res[1]: |
984 | return res[1] | 979 | return res[1] |
985 | return "" | 980 | return "" |
986 | 981 | ||
@@ -996,7 +991,7 @@ class Parser(): | @@ -996,7 +991,7 @@ class Parser(): | ||
996 | sf = gdcm.StringFilter() | 991 | sf = gdcm.StringFilter() |
997 | sf.SetFile(self.gdcm_reader.GetFile()) | 992 | sf.SetFile(self.gdcm_reader.GetFile()) |
998 | res = sf.ToStringPair(tag) | 993 | res = sf.ToStringPair(tag) |
999 | - if (res[1]): | 994 | + if res[1]: |
1000 | return int(res[1]) | 995 | return int(res[1]) |
1001 | return "" | 996 | return "" |
1002 | 997 | ||
@@ -1011,7 +1006,7 @@ class Parser(): | @@ -1011,7 +1006,7 @@ class Parser(): | ||
1011 | sf = gdcm.StringFilter() | 1006 | sf = gdcm.StringFilter() |
1012 | sf.SetFile(self.gdcm_reader.GetFile()) | 1007 | sf.SetFile(self.gdcm_reader.GetFile()) |
1013 | res = sf.ToStringPair(tag) | 1008 | res = sf.ToStringPair(tag) |
1014 | - if (res[1]): | 1009 | + if res[1]: |
1015 | return int(res[1]) | 1010 | return int(res[1]) |
1016 | return "" | 1011 | return "" |
1017 | 1012 | ||
@@ -1026,9 +1021,9 @@ class Parser(): | @@ -1026,9 +1021,9 @@ class Parser(): | ||
1026 | """ | 1021 | """ |
1027 | try: | 1022 | try: |
1028 | data = self.data_image[str(0x0018)][str(0x1030)] | 1023 | data = self.data_image[str(0x0018)][str(0x1030)] |
1029 | - if (data): | 1024 | + if data: |
1030 | return data | 1025 | return data |
1031 | - except(KeyError): | 1026 | + except (KeyError): |
1032 | return "" | 1027 | return "" |
1033 | return "" | 1028 | return "" |
1034 | 1029 | ||
@@ -1050,10 +1045,10 @@ class Parser(): | @@ -1050,10 +1045,10 @@ class Parser(): | ||
1050 | """ | 1045 | """ |
1051 | try: | 1046 | try: |
1052 | data = self.data_image[str(0x0018)][str(0x0020)] | 1047 | data = self.data_image[str(0x0018)][str(0x0020)] |
1053 | - except(KeyError): | 1048 | + except (KeyError): |
1054 | return "" | 1049 | return "" |
1055 | 1050 | ||
1056 | - if (data): | 1051 | + if data: |
1057 | return data | 1052 | return data |
1058 | return "" | 1053 | return "" |
1059 | 1054 | ||
@@ -1065,12 +1060,12 @@ class Parser(): | @@ -1065,12 +1060,12 @@ class Parser(): | ||
1065 | DICOM standard tag (0x0008, 0x0080) was used. | 1060 | DICOM standard tag (0x0008, 0x0080) was used. |
1066 | """ | 1061 | """ |
1067 | try: | 1062 | try: |
1068 | - data = self.data_image[str(0x0008)][str(0x0080)] | ||
1069 | - except(KeyError): | 1063 | + data = self.data_image[str(0x0008)][str(0x0080)] |
1064 | + except (KeyError): | ||
1070 | return "" | 1065 | return "" |
1071 | 1066 | ||
1072 | - if (data): | ||
1073 | - return data | 1067 | + if data: |
1068 | + return data | ||
1074 | return "" | 1069 | return "" |
1075 | 1070 | ||
1076 | def GetInstitutionAddress(self): | 1071 | def GetInstitutionAddress(self): |
@@ -1084,10 +1079,10 @@ class Parser(): | @@ -1084,10 +1079,10 @@ class Parser(): | ||
1084 | """ | 1079 | """ |
1085 | try: | 1080 | try: |
1086 | data = self.data_image[str(0x0008)][str(0x0081)] | 1081 | data = self.data_image[str(0x0008)][str(0x0081)] |
1087 | - except(KeyError): | 1082 | + except (KeyError): |
1088 | return "" | 1083 | return "" |
1089 | 1084 | ||
1090 | - if (data): | 1085 | + if data: |
1091 | return data | 1086 | return data |
1092 | return "" | 1087 | return "" |
1093 | 1088 | ||
@@ -1101,10 +1096,10 @@ class Parser(): | @@ -1101,10 +1096,10 @@ class Parser(): | ||
1101 | """ | 1096 | """ |
1102 | try: | 1097 | try: |
1103 | data = self.data_image[str(0x0020)][str(0x000D)] | 1098 | data = self.data_image[str(0x0020)][str(0x000D)] |
1104 | - except(KeyError): | 1099 | + except (KeyError): |
1105 | return "" | 1100 | return "" |
1106 | 1101 | ||
1107 | - if (data): | 1102 | + if data: |
1108 | return data | 1103 | return data |
1109 | return "" | 1104 | return "" |
1110 | 1105 | ||
@@ -1117,10 +1112,10 @@ class Parser(): | @@ -1117,10 +1112,10 @@ class Parser(): | ||
1117 | """ | 1112 | """ |
1118 | try: | 1113 | try: |
1119 | data = self.data_image[str(0x0010)][str(0x2180)] | 1114 | data = self.data_image[str(0x0010)][str(0x2180)] |
1120 | - except(KeyError): | 1115 | + except (KeyError): |
1121 | return "" | 1116 | return "" |
1122 | 1117 | ||
1123 | - if (data): | 1118 | + if data: |
1124 | return data | 1119 | return data |
1125 | return "" | 1120 | return "" |
1126 | 1121 | ||
@@ -1137,7 +1132,7 @@ class Parser(): | @@ -1137,7 +1132,7 @@ class Parser(): | ||
1137 | sf = gdcm.StringFilter() | 1132 | sf = gdcm.StringFilter() |
1138 | sf.SetFile(self.gdcm_reader.GetFile()) | 1133 | sf.SetFile(self.gdcm_reader.GetFile()) |
1139 | res = sf.ToStringPair(tag) | 1134 | res = sf.ToStringPair(tag) |
1140 | - if (res[1]): | 1135 | + if res[1]: |
1141 | return int(res[1]) | 1136 | return int(res[1]) |
1142 | return "" | 1137 | return "" |
1143 | 1138 | ||
@@ -1149,16 +1144,16 @@ class Parser(): | @@ -1149,16 +1144,16 @@ class Parser(): | ||
1149 | 1144 | ||
1150 | DICOM standard tag (0x0028, 0x0100) was used. | 1145 | DICOM standard tag (0x0028, 0x0100) was used. |
1151 | """ | 1146 | """ |
1152 | - #tag = gdcm.Tag(0x0028, 0x0100) | ||
1153 | - #sf = gdcm.StringFilter() | ||
1154 | - #sf.SetFile(self.gdcm_reader.GetFile()) | ||
1155 | - #res = sf.ToStringPair(tag) | 1147 | + # tag = gdcm.Tag(0x0028, 0x0100) |
1148 | + # sf = gdcm.StringFilter() | ||
1149 | + # sf.SetFile(self.gdcm_reader.GetFile()) | ||
1150 | + # res = sf.ToStringPair(tag) | ||
1156 | try: | 1151 | try: |
1157 | data = self.data_image[str(0x0028)][str(0x0100)] | 1152 | data = self.data_image[str(0x0028)][str(0x0100)] |
1158 | - except(KeyError): | 1153 | + except (KeyError): |
1159 | return "" | 1154 | return "" |
1160 | 1155 | ||
1161 | - if (data): | 1156 | + if data: |
1162 | return int(data) | 1157 | return int(data) |
1163 | return "" | 1158 | return "" |
1164 | 1159 | ||
@@ -1174,7 +1169,6 @@ class Parser(): | @@ -1174,7 +1169,6 @@ class Parser(): | ||
1174 | return 1 | 1169 | return 1 |
1175 | return int(data) | 1170 | return int(data) |
1176 | 1171 | ||
1177 | - | ||
1178 | def GetPatientBirthDate(self): | 1172 | def GetPatientBirthDate(self): |
1179 | """ | 1173 | """ |
1180 | Return string containing the patient's birth date using the | 1174 | Return string containing the patient's birth date using the |
@@ -1186,14 +1180,13 @@ class Parser(): | @@ -1186,14 +1180,13 @@ class Parser(): | ||
1186 | # TODO: internationalize data | 1180 | # TODO: internationalize data |
1187 | try: | 1181 | try: |
1188 | data = self.data_image[str(0x0010)][str(0x0030)] | 1182 | data = self.data_image[str(0x0010)][str(0x0030)] |
1189 | - except(KeyError): | 1183 | + except (KeyError): |
1190 | return "" | 1184 | return "" |
1191 | 1185 | ||
1192 | - if (data) and (data != 'None'): | 1186 | + if (data) and (data != "None"): |
1193 | return self.__format_date(str(data)) | 1187 | return self.__format_date(str(data)) |
1194 | return "" | 1188 | return "" |
1195 | 1189 | ||
1196 | - | ||
1197 | def GetStudyID(self): | 1190 | def GetStudyID(self): |
1198 | """ | 1191 | """ |
1199 | Return string containing the Study ID. | 1192 | Return string containing the Study ID. |
@@ -1203,13 +1196,13 @@ class Parser(): | @@ -1203,13 +1196,13 @@ class Parser(): | ||
1203 | """ | 1196 | """ |
1204 | try: | 1197 | try: |
1205 | data = self.data_image[str(0x0020)][str(0x0010)] | 1198 | data = self.data_image[str(0x0020)][str(0x0010)] |
1206 | - except(KeyError): | 1199 | + except (KeyError): |
1207 | return "" | 1200 | return "" |
1208 | 1201 | ||
1209 | - if (data): | 1202 | + if data: |
1210 | return str(data) | 1203 | return str(data) |
1211 | return "" | 1204 | return "" |
1212 | - | 1205 | + |
1213 | def GetAcquisitionGantryTilt(self): | 1206 | def GetAcquisitionGantryTilt(self): |
1214 | """ | 1207 | """ |
1215 | Return floating point containing nominal angle of | 1208 | Return floating point containing nominal angle of |
@@ -1220,10 +1213,10 @@ class Parser(): | @@ -1220,10 +1213,10 @@ class Parser(): | ||
1220 | """ | 1213 | """ |
1221 | try: | 1214 | try: |
1222 | data = self.data_image[str(0x0018)][str(0x1120)] | 1215 | data = self.data_image[str(0x0018)][str(0x1120)] |
1223 | - except(KeyError): | 1216 | + except (KeyError): |
1224 | return 0.0 | 1217 | return 0.0 |
1225 | 1218 | ||
1226 | - if (data): | 1219 | + if data: |
1227 | return float(str(data)) | 1220 | return float(str(data)) |
1228 | return 0.0 | 1221 | return 0.0 |
1229 | 1222 | ||
@@ -1239,16 +1232,16 @@ class Parser(): | @@ -1239,16 +1232,16 @@ class Parser(): | ||
1239 | """ | 1232 | """ |
1240 | try: | 1233 | try: |
1241 | data = self.data_image[str(0x0010)][str(0x0040)] | 1234 | data = self.data_image[str(0x0010)][str(0x0040)] |
1242 | - except(KeyError): | 1235 | + except (KeyError): |
1243 | return "" | 1236 | return "" |
1244 | 1237 | ||
1245 | - if (data): | 1238 | + if data: |
1246 | name = data.strip() | 1239 | name = data.strip() |
1247 | encoding = self.GetEncoding() | 1240 | encoding = self.GetEncoding() |
1248 | try: | 1241 | try: |
1249 | # Returns a unicode decoded in the own dicom encoding | 1242 | # Returns a unicode decoded in the own dicom encoding |
1250 | - return utils.decode(name, encoding, 'replace') | ||
1251 | - except(UnicodeEncodeError): | 1243 | + return utils.decode(name, encoding, "replace") |
1244 | + except (UnicodeEncodeError): | ||
1252 | return name | 1245 | return name |
1253 | 1246 | ||
1254 | return "" | 1247 | return "" |
@@ -1263,11 +1256,11 @@ class Parser(): | @@ -1263,11 +1256,11 @@ class Parser(): | ||
1263 | """ | 1256 | """ |
1264 | try: | 1257 | try: |
1265 | data = self.data_image[str(0x0010)][str(0x1010)] | 1258 | data = self.data_image[str(0x0010)][str(0x1010)] |
1266 | - except(KeyError): | 1259 | + except (KeyError): |
1267 | return "" | 1260 | return "" |
1268 | 1261 | ||
1269 | - if (data): | ||
1270 | - age = (data.split('Y')[0]) | 1262 | + if data: |
1263 | + age = data.split("Y")[0] | ||
1271 | try: | 1264 | try: |
1272 | return int(age) | 1265 | return int(age) |
1273 | except ValueError: | 1266 | except ValueError: |
@@ -1283,7 +1276,7 @@ class Parser(): | @@ -1283,7 +1276,7 @@ class Parser(): | ||
1283 | """ | 1276 | """ |
1284 | try: | 1277 | try: |
1285 | data = self.data_image[str(0x0010)][str(0x0010)] | 1278 | data = self.data_image[str(0x0010)][str(0x0010)] |
1286 | - except(KeyError): | 1279 | + except (KeyError): |
1287 | return "" | 1280 | return "" |
1288 | 1281 | ||
1289 | encoding = self.GetEncoding() | 1282 | encoding = self.GetEncoding() |
@@ -1303,19 +1296,18 @@ class Parser(): | @@ -1303,19 +1296,18 @@ class Parser(): | ||
1303 | """ | 1296 | """ |
1304 | try: | 1297 | try: |
1305 | data = self.data_image[str(0x0010)][str(0x0020)] | 1298 | data = self.data_image[str(0x0010)][str(0x0020)] |
1306 | - except(KeyError): | 1299 | + except (KeyError): |
1307 | return "" | 1300 | return "" |
1308 | 1301 | ||
1309 | - if (data): | 1302 | + if data: |
1310 | encoding = self.GetEncoding() | 1303 | encoding = self.GetEncoding() |
1311 | # Returns a unicode decoded in the own dicom encoding | 1304 | # Returns a unicode decoded in the own dicom encoding |
1312 | try: | 1305 | try: |
1313 | - return utils.decode(data, encoding, 'replace') | ||
1314 | - except(UnicodeEncodeError): | 1306 | + return utils.decode(data, encoding, "replace") |
1307 | + except (UnicodeEncodeError): | ||
1315 | return data | 1308 | return data |
1316 | return "" | 1309 | return "" |
1317 | 1310 | ||
1318 | - | ||
1319 | def GetEquipmentXRayTubeCurrent(self): | 1311 | def GetEquipmentXRayTubeCurrent(self): |
1320 | """ | 1312 | """ |
1321 | Return float value associated to the X-ray tube current | 1313 | Return float value associated to the X-ray tube current |
@@ -1326,10 +1318,10 @@ class Parser(): | @@ -1326,10 +1318,10 @@ class Parser(): | ||
1326 | """ | 1318 | """ |
1327 | try: | 1319 | try: |
1328 | data = self.data_image[str(0x0018)][str(0x1151)] | 1320 | data = self.data_image[str(0x0018)][str(0x1151)] |
1329 | - except(KeyError): | 1321 | + except (KeyError): |
1330 | return "" | 1322 | return "" |
1331 | 1323 | ||
1332 | - if (data): | 1324 | + if data: |
1333 | return data | 1325 | return data |
1334 | return "" | 1326 | return "" |
1335 | 1327 | ||
@@ -1343,10 +1335,10 @@ class Parser(): | @@ -1343,10 +1335,10 @@ class Parser(): | ||
1343 | """ | 1335 | """ |
1344 | try: | 1336 | try: |
1345 | data = self.data_image[str(0x0018)][str(0x1152)] | 1337 | data = self.data_image[str(0x0018)][str(0x1152)] |
1346 | - except(KeyError): | 1338 | + except (KeyError): |
1347 | return "" | 1339 | return "" |
1348 | 1340 | ||
1349 | - if (data): | 1341 | + if data: |
1350 | return float(data) | 1342 | return float(data) |
1351 | return "" | 1343 | return "" |
1352 | 1344 | ||
@@ -1360,10 +1352,10 @@ class Parser(): | @@ -1360,10 +1352,10 @@ class Parser(): | ||
1360 | """ | 1352 | """ |
1361 | try: | 1353 | try: |
1362 | data = self.data_image[str(0x0018)][str(0x0060)] | 1354 | data = self.data_image[str(0x0018)][str(0x0060)] |
1363 | - except(KeyError): | 1355 | + except (KeyError): |
1364 | return "" | 1356 | return "" |
1365 | 1357 | ||
1366 | - if (data): | 1358 | + if data: |
1367 | return float(data) | 1359 | return float(data) |
1368 | return "" | 1360 | return "" |
1369 | 1361 | ||
@@ -1377,9 +1369,9 @@ class Parser(): | @@ -1377,9 +1369,9 @@ class Parser(): | ||
1377 | """ | 1369 | """ |
1378 | try: | 1370 | try: |
1379 | data = self.data_image[str(0x0018)][str(0x0050)].replace(",", ".") | 1371 | data = self.data_image[str(0x0018)][str(0x0050)].replace(",", ".") |
1380 | - except(KeyError): | 1372 | + except (KeyError): |
1381 | return 0 | 1373 | return 0 |
1382 | - if (data): | 1374 | + if data: |
1383 | return float(data) | 1375 | return float(data) |
1384 | return 0 | 1376 | return 0 |
1385 | 1377 | ||
@@ -1395,10 +1387,10 @@ class Parser(): | @@ -1395,10 +1387,10 @@ class Parser(): | ||
1395 | """ | 1387 | """ |
1396 | try: | 1388 | try: |
1397 | data = self.data_image[str(0x0018)][str(0x1210)] | 1389 | data = self.data_image[str(0x0018)][str(0x1210)] |
1398 | - except(KeyError): | 1390 | + except (KeyError): |
1399 | return "" | 1391 | return "" |
1400 | 1392 | ||
1401 | - if (data): | 1393 | + if data: |
1402 | return data | 1394 | return data |
1403 | return "" | 1395 | return "" |
1404 | 1396 | ||
@@ -1412,10 +1404,10 @@ class Parser(): | @@ -1412,10 +1404,10 @@ class Parser(): | ||
1412 | """ | 1404 | """ |
1413 | try: | 1405 | try: |
1414 | data = self.data_image[str(0x0008)][str(0x0080)] | 1406 | data = self.data_image[str(0x0008)][str(0x0080)] |
1415 | - except(KeyError): | 1407 | + except (KeyError): |
1416 | return "" | 1408 | return "" |
1417 | 1409 | ||
1418 | - if (data): | 1410 | + if data: |
1419 | return data | 1411 | return data |
1420 | return "" | 1412 | return "" |
1421 | 1413 | ||
@@ -1429,10 +1421,10 @@ class Parser(): | @@ -1429,10 +1421,10 @@ class Parser(): | ||
1429 | """ | 1421 | """ |
1430 | try: | 1422 | try: |
1431 | data = self.data_image[str(0x0008)][str(0x1010)] | 1423 | data = self.data_image[str(0x0008)][str(0x1010)] |
1432 | - except(KeyError): | 1424 | + except (KeyError): |
1433 | return "" | 1425 | return "" |
1434 | 1426 | ||
1435 | - if (data): | 1427 | + if data: |
1436 | return data | 1428 | return data |
1437 | return "" | 1429 | return "" |
1438 | 1430 | ||
@@ -1446,24 +1438,24 @@ class Parser(): | @@ -1446,24 +1438,24 @@ class Parser(): | ||
1446 | """ | 1438 | """ |
1447 | try: | 1439 | try: |
1448 | data = self.data_image[str(0x0008)][str(0x1090)] | 1440 | data = self.data_image[str(0x0008)][str(0x1090)] |
1449 | - except(KeyError): | 1441 | + except (KeyError): |
1450 | return "" | 1442 | return "" |
1451 | 1443 | ||
1452 | - if (data): | 1444 | + if data: |
1453 | return data | 1445 | return data |
1454 | return "" | 1446 | return "" |
1455 | 1447 | ||
1456 | def GetManufacturerName(self): | 1448 | def GetManufacturerName(self): |
1457 | """ | 1449 | """ |
1458 | - Return Manufacturer of the equipment that produced | 1450 | + Return Manufacturer of the equipment that produced |
1459 | the composite instances. | 1451 | the composite instances. |
1460 | """ | 1452 | """ |
1461 | try: | 1453 | try: |
1462 | data = self.data_image[str(0x0008)][str(0x0070)] | 1454 | data = self.data_image[str(0x0008)][str(0x0070)] |
1463 | - except(KeyError): | 1455 | + except (KeyError): |
1464 | return "" | 1456 | return "" |
1465 | 1457 | ||
1466 | - if (data): | 1458 | + if data: |
1467 | return data | 1459 | return data |
1468 | return "" | 1460 | return "" |
1469 | 1461 | ||
@@ -1476,10 +1468,10 @@ class Parser(): | @@ -1476,10 +1468,10 @@ class Parser(): | ||
1476 | """ | 1468 | """ |
1477 | try: | 1469 | try: |
1478 | data = self.data_image[str(0x0008)][str(0x1010)] | 1470 | data = self.data_image[str(0x0008)][str(0x1010)] |
1479 | - except(KeyError): | 1471 | + except (KeyError): |
1480 | return "" | 1472 | return "" |
1481 | 1473 | ||
1482 | - if (data): | 1474 | + if data: |
1483 | return data | 1475 | return data |
1484 | return "" | 1476 | return "" |
1485 | 1477 | ||
@@ -1494,14 +1486,13 @@ class Parser(): | @@ -1494,14 +1486,13 @@ class Parser(): | ||
1494 | """ | 1486 | """ |
1495 | try: | 1487 | try: |
1496 | data = self.data_image[str(0x0008)][str(0x0060)] | 1488 | data = self.data_image[str(0x0008)][str(0x0060)] |
1497 | - except(KeyError): | 1489 | + except (KeyError): |
1498 | return "" | 1490 | return "" |
1499 | 1491 | ||
1500 | - if (data): | 1492 | + if data: |
1501 | return data | 1493 | return data |
1502 | return "" | 1494 | return "" |
1503 | 1495 | ||
1504 | - | ||
1505 | def GetImageNumber(self): | 1496 | def GetImageNumber(self): |
1506 | """ | 1497 | """ |
1507 | Return slice number (integer). | 1498 | Return slice number (integer). |
@@ -1511,10 +1502,10 @@ class Parser(): | @@ -1511,10 +1502,10 @@ class Parser(): | ||
1511 | """ | 1502 | """ |
1512 | try: | 1503 | try: |
1513 | data = self.data_image[str(0x0020)][str(0x0013)] | 1504 | data = self.data_image[str(0x0020)][str(0x0013)] |
1514 | - except(KeyError): | 1505 | + except (KeyError): |
1515 | return 0 | 1506 | return 0 |
1516 | 1507 | ||
1517 | - if (data): | 1508 | + if data: |
1518 | return int(data) | 1509 | return int(data) |
1519 | return 0 | 1510 | return 0 |
1520 | 1511 | ||
@@ -1527,10 +1518,10 @@ class Parser(): | @@ -1527,10 +1518,10 @@ class Parser(): | ||
1527 | """ | 1518 | """ |
1528 | try: | 1519 | try: |
1529 | data = self.data_image[str(0x0008)][str(0x1030)] | 1520 | data = self.data_image[str(0x0008)][str(0x1030)] |
1530 | - if (data): | 1521 | + if data: |
1531 | encoding = self.GetEncoding() | 1522 | encoding = self.GetEncoding() |
1532 | - return utils.decode(data, encoding, 'replace') | ||
1533 | - except(KeyError): | 1523 | + return utils.decode(data, encoding, "replace") |
1524 | + except (KeyError): | ||
1534 | return "" | 1525 | return "" |
1535 | 1526 | ||
1536 | def GetStudyAdmittingDiagnosis(self): | 1527 | def GetStudyAdmittingDiagnosis(self): |
@@ -1546,11 +1537,10 @@ class Parser(): | @@ -1546,11 +1537,10 @@ class Parser(): | ||
1546 | sf.SetFile(self.gdcm_reader.GetFile()) | 1537 | sf.SetFile(self.gdcm_reader.GetFile()) |
1547 | res = sf.ToStringPair(tag) | 1538 | res = sf.ToStringPair(tag) |
1548 | 1539 | ||
1549 | - if (res[1]): | 1540 | + if res[1]: |
1550 | return str(res[1]) | 1541 | return str(res[1]) |
1551 | return "" | 1542 | return "" |
1552 | 1543 | ||
1553 | - | ||
1554 | def GetSeriesDescription(self): | 1544 | def GetSeriesDescription(self): |
1555 | """ | 1545 | """ |
1556 | Return a string with a description of the series. | 1546 | Return a string with a description of the series. |
@@ -1558,7 +1548,7 @@ class Parser(): | @@ -1558,7 +1548,7 @@ class Parser(): | ||
1558 | """ | 1548 | """ |
1559 | try: | 1549 | try: |
1560 | data = self.data_image[str(0x0008)][str(0x103E)] | 1550 | data = self.data_image[str(0x0008)][str(0x103E)] |
1561 | - except(KeyError): | 1551 | + except (KeyError): |
1562 | return _("unnamed") | 1552 | return _("unnamed") |
1563 | 1553 | ||
1564 | encoding = self.GetEncoding() | 1554 | encoding = self.GetEncoding() |
@@ -1581,11 +1571,11 @@ class Parser(): | @@ -1581,11 +1571,11 @@ class Parser(): | ||
1581 | """ | 1571 | """ |
1582 | try: | 1572 | try: |
1583 | data = self.data_image[str(0x0008)][str(0x0033)] | 1573 | data = self.data_image[str(0x0008)][str(0x0033)] |
1584 | - except(KeyError): | 1574 | + except (KeyError): |
1585 | return "" | 1575 | return "" |
1586 | 1576 | ||
1587 | - if (data) and (data != 'None'): | ||
1588 | - return self.__format_time(data) | 1577 | + if (data) and (data != "None"): |
1578 | + return self.__format_time(data) | ||
1589 | return "" | 1579 | return "" |
1590 | 1580 | ||
1591 | def GetAcquisitionTime(self): | 1581 | def GetAcquisitionTime(self): |
@@ -1595,10 +1585,10 @@ class Parser(): | @@ -1595,10 +1585,10 @@ class Parser(): | ||
1595 | """ | 1585 | """ |
1596 | try: | 1586 | try: |
1597 | data = self.data_image[str(0x0008)][str(0x0032)] | 1587 | data = self.data_image[str(0x0008)][str(0x0032)] |
1598 | - except(KeyError): | 1588 | + except (KeyError): |
1599 | return "" | 1589 | return "" |
1600 | 1590 | ||
1601 | - if (data): | 1591 | + if data: |
1602 | return self.__format_time(data) | 1592 | return self.__format_time(data) |
1603 | return "" | 1593 | return "" |
1604 | 1594 | ||
@@ -1609,10 +1599,10 @@ class Parser(): | @@ -1609,10 +1599,10 @@ class Parser(): | ||
1609 | """ | 1599 | """ |
1610 | try: | 1600 | try: |
1611 | data = self.data_image[str(0x0020)][str(0x0011)] | 1601 | data = self.data_image[str(0x0020)][str(0x0011)] |
1612 | - except(KeyError): | 1602 | + except (KeyError): |
1613 | return "" | 1603 | return "" |
1614 | - | ||
1615 | - if (data): | 1604 | + |
1605 | + if data: | ||
1616 | return data | 1606 | return data |
1617 | return "" | 1607 | return "" |
1618 | 1608 | ||
@@ -1624,8 +1614,8 @@ class Parser(): | @@ -1624,8 +1614,8 @@ class Parser(): | ||
1624 | try: | 1614 | try: |
1625 | encoding_value = self.data_image[str(0x0008)][str(0x0005)] | 1615 | encoding_value = self.data_image[str(0x0008)][str(0x0005)] |
1626 | return const.DICOM_ENCODING_TO_PYTHON[encoding_value] | 1616 | return const.DICOM_ENCODING_TO_PYTHON[encoding_value] |
1627 | - except(KeyError): | ||
1628 | - return 'ISO_IR_100' | 1617 | + except (KeyError): |
1618 | + return "ISO_IR_100" | ||
1629 | 1619 | ||
1630 | 1620 | ||
1631 | class DicomWriter: | 1621 | class DicomWriter: |
@@ -1665,7 +1655,6 @@ class DicomWriter: | @@ -1665,7 +1655,6 @@ class DicomWriter: | ||
1665 | self.new_dicom = vtkgdcm.vtkGDCMImageWriter() | 1655 | self.new_dicom = vtkgdcm.vtkGDCMImageWriter() |
1666 | reader = self.reader = gdcm.Reader() | 1656 | reader = self.reader = gdcm.Reader() |
1667 | 1657 | ||
1668 | - | ||
1669 | def SetFileName(self, path): | 1658 | def SetFileName(self, path): |
1670 | """ | 1659 | """ |
1671 | Set Dicom File Name | 1660 | Set Dicom File Name |
@@ -1674,19 +1663,16 @@ class DicomWriter: | @@ -1674,19 +1663,16 @@ class DicomWriter: | ||
1674 | 1663 | ||
1675 | self.reader.SetFileName(path) | 1664 | self.reader.SetFileName(path) |
1676 | 1665 | ||
1677 | - if (self.reader.Read()): | 1666 | + if self.reader.Read(): |
1678 | 1667 | ||
1679 | self.anony.SetFile(self.reader.GetFile()) | 1668 | self.anony.SetFile(self.reader.GetFile()) |
1680 | 1669 | ||
1681 | - | ||
1682 | - | ||
1683 | def SetInput(self, img_data): | 1670 | def SetInput(self, img_data): |
1684 | """ | 1671 | """ |
1685 | Input vtkImageData | 1672 | Input vtkImageData |
1686 | """ | 1673 | """ |
1687 | self.img_data = img_data | 1674 | self.img_data = img_data |
1688 | 1675 | ||
1689 | - | ||
1690 | def __CreateNewDicom(self, img_data): | 1676 | def __CreateNewDicom(self, img_data): |
1691 | """ | 1677 | """ |
1692 | Create New Dicom File, input is | 1678 | Create New Dicom File, input is |
@@ -1697,7 +1683,6 @@ class DicomWriter: | @@ -1697,7 +1683,6 @@ class DicomWriter: | ||
1697 | new_dicom.SetInput(img_data) | 1683 | new_dicom.SetInput(img_data) |
1698 | new_dicom.Write() | 1684 | new_dicom.Write() |
1699 | 1685 | ||
1700 | - | ||
1701 | def SaveIsNew(self, img_data): | 1686 | def SaveIsNew(self, img_data): |
1702 | """ | 1687 | """ |
1703 | Write Changes in Dicom file or Create | 1688 | Write Changes in Dicom file or Create |
@@ -1706,12 +1691,11 @@ class DicomWriter: | @@ -1706,12 +1691,11 @@ class DicomWriter: | ||
1706 | 1691 | ||
1707 | self.__CreateNewDicom(img_data) | 1692 | self.__CreateNewDicom(img_data) |
1708 | 1693 | ||
1709 | - #Is necessary to create and add | ||
1710 | - #information in the dicom tag | 1694 | + # Is necessary to create and add |
1695 | + # information in the dicom tag | ||
1711 | self.SetFileName(self.path) | 1696 | self.SetFileName(self.path) |
1712 | self.anony.SetFile(self.reader.GetFile()) | 1697 | self.anony.SetFile(self.reader.GetFile()) |
1713 | 1698 | ||
1714 | - | ||
1715 | def Save(self): | 1699 | def Save(self): |
1716 | 1700 | ||
1717 | reader = self.reader | 1701 | reader = self.reader |
@@ -1721,84 +1705,63 @@ class DicomWriter: | @@ -1721,84 +1705,63 @@ class DicomWriter: | ||
1721 | writer.SetFileName(self.path) | 1705 | writer.SetFileName(self.path) |
1722 | writer.Write() | 1706 | writer.Write() |
1723 | 1707 | ||
1724 | - | ||
1725 | def SetPatientName(self, patient): | 1708 | def SetPatientName(self, patient): |
1726 | """ | 1709 | """ |
1727 | Set Patient Name requeries string type | 1710 | Set Patient Name requeries string type |
1728 | """ | 1711 | """ |
1729 | - self.anony.Replace(gdcm.Tag(0x0010,0x0010), \ | ||
1730 | - str(patient)) | ||
1731 | - | 1712 | + self.anony.Replace(gdcm.Tag(0x0010, 0x0010), str(patient)) |
1732 | 1713 | ||
1733 | def SetImageThickness(self, thickness): | 1714 | def SetImageThickness(self, thickness): |
1734 | """ | 1715 | """ |
1735 | Set thickness value requeries float type | 1716 | Set thickness value requeries float type |
1736 | """ | 1717 | """ |
1737 | - self.anony.Replace(gdcm.Tag(0x0018,0x0050), \ | ||
1738 | - str(thickness)) | ||
1739 | - | 1718 | + self.anony.Replace(gdcm.Tag(0x0018, 0x0050), str(thickness)) |
1740 | 1719 | ||
1741 | def SetImageSeriesNumber(self, number): | 1720 | def SetImageSeriesNumber(self, number): |
1742 | """ | 1721 | """ |
1743 | Set Serie Number value requeries int type | 1722 | Set Serie Number value requeries int type |
1744 | """ | 1723 | """ |
1745 | - self.anony.Replace(gdcm.Tag(0x0020,0x0011), \ | ||
1746 | - str(number)) | ||
1747 | - | 1724 | + self.anony.Replace(gdcm.Tag(0x0020, 0x0011), str(number)) |
1748 | 1725 | ||
1749 | def SetImageNumber(self, number): | 1726 | def SetImageNumber(self, number): |
1750 | """ | 1727 | """ |
1751 | Set image Number value requeries int type | 1728 | Set image Number value requeries int type |
1752 | """ | 1729 | """ |
1753 | - self.anony.Replace(gdcm.Tag(0x0020,0x0013), | ||
1754 | - str(number)) | ||
1755 | - | 1730 | + self.anony.Replace(gdcm.Tag(0x0020, 0x0013), str(number)) |
1756 | 1731 | ||
1757 | def SetImageLocation(self, location): | 1732 | def SetImageLocation(self, location): |
1758 | """ | 1733 | """ |
1759 | Set slice location value requeries float type | 1734 | Set slice location value requeries float type |
1760 | """ | 1735 | """ |
1761 | - self.anony.Replace(gdcm.Tag(0x0020,0x1041),\ | ||
1762 | - str(number)) | ||
1763 | - | 1736 | + self.anony.Replace(gdcm.Tag(0x0020, 0x1041), str(number)) |
1764 | 1737 | ||
1765 | def SetImagePosition(self, position): | 1738 | def SetImagePosition(self, position): |
1766 | """ | 1739 | """ |
1767 | Set slice position value requeries list | 1740 | Set slice position value requeries list |
1768 | with three values x, y and z | 1741 | with three values x, y and z |
1769 | """ | 1742 | """ |
1770 | - self.anony.Replace(gdcm.Tag(0x0020,0x0032), \ | ||
1771 | - str(position[0]) + \ | ||
1772 | - "\\" + str(position[1]) + \ | ||
1773 | - "\\" + str(position[2])) | ||
1774 | - | 1743 | + self.anony.Replace( |
1744 | + gdcm.Tag(0x0020, 0x0032), | ||
1745 | + str(position[0]) + "\\" + str(position[1]) + "\\" + str(position[2]), | ||
1746 | + ) | ||
1775 | 1747 | ||
1776 | def SetAcquisitionModality(self, modality): | 1748 | def SetAcquisitionModality(self, modality): |
1777 | """ | 1749 | """ |
1778 | Set modality study CT or RM | 1750 | Set modality study CT or RM |
1779 | """ | 1751 | """ |
1780 | - self.anony.Replace(gdcm.Tag(0x0008,0x0060), \ | ||
1781 | - str(modality)) | ||
1782 | - | 1752 | + self.anony.Replace(gdcm.Tag(0x0008, 0x0060), str(modality)) |
1783 | 1753 | ||
1784 | def SetPixelSpacing(self, spacing): | 1754 | def SetPixelSpacing(self, spacing): |
1785 | """ | 1755 | """ |
1786 | Set pixel spacing x and y | 1756 | Set pixel spacing x and y |
1787 | """ | 1757 | """ |
1788 | - self.anony.Replace(gdcm.Tag(0x0028,0x0030), \ | ||
1789 | - str(spacing)) | ||
1790 | - | 1758 | + self.anony.Replace(gdcm.Tag(0x0028, 0x0030), str(spacing)) |
1791 | 1759 | ||
1792 | def SetInstitutionName(self, institution): | 1760 | def SetInstitutionName(self, institution): |
1793 | """ | 1761 | """ |
1794 | Set institution name | 1762 | Set institution name |
1795 | """ | 1763 | """ |
1796 | - self.anony.Replace(gdcm.Tag(0x0008, 0x0080), \ | ||
1797 | - str(institution)) | ||
1798 | - | ||
1799 | - | ||
1800 | - | ||
1801 | - | 1764 | + self.anony.Replace(gdcm.Tag(0x0008, 0x0080), str(institution)) |
1802 | 1765 | ||
1803 | 1766 | ||
1804 | def BuildDictionary(filename): | 1767 | def BuildDictionary(filename): |
@@ -1816,10 +1779,11 @@ def BuildDictionary(filename): | @@ -1816,10 +1779,11 @@ def BuildDictionary(filename): | ||
1816 | # file, given keys in info_keys list. Example: | 1779 | # file, given keys in info_keys list. Example: |
1817 | # info["AcquisitionDate"] = dicom.GetAcquisitionDate() | 1780 | # info["AcquisitionDate"] = dicom.GetAcquisitionDate() |
1818 | for key in INFO_KEYS: | 1781 | for key in INFO_KEYS: |
1819 | - info[key] = eval("parser.Get"+key+"()") | 1782 | + info[key] = eval("parser.Get" + key + "()") |
1820 | 1783 | ||
1821 | return info | 1784 | return info |
1822 | 1785 | ||
1786 | + | ||
1823 | def LoadDictionary(filename): | 1787 | def LoadDictionary(filename): |
1824 | """ | 1788 | """ |
1825 | Given a binary file (containing a dictionary), return dictionary | 1789 | Given a binary file (containing a dictionary), return dictionary |
@@ -1844,14 +1808,15 @@ def DumpDictionary(filename, dictionary=info): | @@ -1844,14 +1808,15 @@ def DumpDictionary(filename, dictionary=info): | ||
1844 | pickle.dump(info, fp) | 1808 | pickle.dump(info, fp) |
1845 | fp.close() | 1809 | fp.close() |
1846 | 1810 | ||
1811 | + | ||
1847 | if __name__ == "__main__": | 1812 | if __name__ == "__main__": |
1848 | 1813 | ||
1849 | # Example of how to use Parser | 1814 | # Example of how to use Parser |
1850 | fail_count = 0 | 1815 | fail_count = 0 |
1851 | total = 48 | 1816 | total = 48 |
1852 | 1817 | ||
1853 | - for i in range(1,total+1): | ||
1854 | - filename = "..//data//"+str(i)+".dcm" | 1818 | + for i in range(1, total + 1): |
1819 | + filename = "..//data//" + str(i) + ".dcm" | ||
1855 | 1820 | ||
1856 | parser = Parser() | 1821 | parser = Parser() |
1857 | if parser.SetFileName(filename): | 1822 | if parser.SetFileName(filename): |
@@ -1865,8 +1830,8 @@ if __name__ == "__main__": | @@ -1865,8 +1830,8 @@ if __name__ == "__main__": | ||
1865 | print("z:", parser.GetDimensionZ()) | 1830 | print("z:", parser.GetDimensionZ()) |
1866 | else: | 1831 | else: |
1867 | print("--------------------------------------------------") | 1832 | print("--------------------------------------------------") |
1868 | - total-=1 | ||
1869 | - fail_count+=1 | 1833 | + total -= 1 |
1834 | + fail_count += 1 | ||
1870 | 1835 | ||
1871 | print("\nREPORT:") | 1836 | print("\nREPORT:") |
1872 | print("failed: ", fail_count) | 1837 | print("failed: ", fail_count) |
@@ -1874,16 +1839,13 @@ if __name__ == "__main__": | @@ -1874,16 +1839,13 @@ if __name__ == "__main__": | ||
1874 | 1839 | ||
1875 | # Example of how to use auxiliary functions | 1840 | # Example of how to use auxiliary functions |
1876 | total = 38 | 1841 | total = 38 |
1877 | - for i in range(1,total+1): | ||
1878 | - if (i==8) or (i==9) or (i==13): | 1842 | + for i in range(1, total + 1): |
1843 | + if (i == 8) or (i == 9) or (i == 13): | ||
1879 | pass | 1844 | pass |
1880 | else: | 1845 | else: |
1881 | - filename = "..//data//"+str(i)+".dcm" | 1846 | + filename = "..//data//" + str(i) + ".dcm" |
1882 | info = BuildDictionary(filename) | 1847 | info = BuildDictionary(filename) |
1883 | - #print info | ||
1884 | - | ||
1885 | - | ||
1886 | - | 1848 | + # print info |
1887 | 1849 | ||
1888 | 1850 | ||
1889 | class Dicom(object): | 1851 | class Dicom(object): |
@@ -1896,7 +1858,7 @@ class Dicom(object): | @@ -1896,7 +1858,7 @@ class Dicom(object): | ||
1896 | self.LoadImageInfo() | 1858 | self.LoadImageInfo() |
1897 | self.LoadPatientInfo() | 1859 | self.LoadPatientInfo() |
1898 | self.LoadAcquisitionInfo() | 1860 | self.LoadAcquisitionInfo() |
1899 | - #self.LoadStudyInfo() | 1861 | + # self.LoadStudyInfo() |
1900 | 1862 | ||
1901 | def LoadImageInfo(self): | 1863 | def LoadImageInfo(self): |
1902 | self.image = Image() | 1864 | self.image = Image() |
@@ -1911,9 +1873,6 @@ class Dicom(object): | @@ -1911,9 +1873,6 @@ class Dicom(object): | ||
1911 | self.acquisition.SetParser(self.parser) | 1873 | self.acquisition.SetParser(self.parser) |
1912 | 1874 | ||
1913 | 1875 | ||
1914 | - | ||
1915 | - | ||
1916 | - | ||
1917 | class Patient(object): | 1876 | class Patient(object): |
1918 | def __init__(self): | 1877 | def __init__(self): |
1919 | pass | 1878 | pass |
@@ -1928,7 +1887,6 @@ class Patient(object): | @@ -1928,7 +1887,6 @@ class Patient(object): | ||
1928 | 1887 | ||
1929 | 1888 | ||
1930 | class Acquisition(object): | 1889 | class Acquisition(object): |
1931 | - | ||
1932 | def __init__(self): | 1890 | def __init__(self): |
1933 | pass | 1891 | pass |
1934 | 1892 | ||
@@ -1950,7 +1908,6 @@ class Acquisition(object): | @@ -1950,7 +1908,6 @@ class Acquisition(object): | ||
1950 | 1908 | ||
1951 | 1909 | ||
1952 | class Image(object): | 1910 | class Image(object): |
1953 | - | ||
1954 | def __init__(self): | 1911 | def __init__(self): |
1955 | pass | 1912 | pass |
1956 | 1913 | ||
@@ -1969,14 +1926,14 @@ class Image(object): | @@ -1969,14 +1926,14 @@ class Image(object): | ||
1969 | self.time = parser.GetImageTime() | 1926 | self.time = parser.GetImageTime() |
1970 | self.type = parser.GetImageType() | 1927 | self.type = parser.GetImageType() |
1971 | self.size = (parser.GetDimensionX(), parser.GetDimensionY()) | 1928 | self.size = (parser.GetDimensionX(), parser.GetDimensionY()) |
1972 | - #self.imagedata = parser.GetImageData() | 1929 | + # self.imagedata = parser.GetImageData() |
1973 | self.bits_allocad = parser._GetBitsAllocated() | 1930 | self.bits_allocad = parser._GetBitsAllocated() |
1974 | self.thumbnail_path = parser.thumbnail_path | 1931 | self.thumbnail_path = parser.thumbnail_path |
1975 | 1932 | ||
1976 | self.number_of_frames = parser.GetNumberOfFrames() | 1933 | self.number_of_frames = parser.GetNumberOfFrames() |
1977 | self.samples_per_pixel = parser.GetImageSamplesPerPixel() | 1934 | self.samples_per_pixel = parser.GetImageSamplesPerPixel() |
1978 | 1935 | ||
1979 | - if (parser.GetImageThickness()): | 1936 | + if parser.GetImageThickness(): |
1980 | self.spacing.append(parser.GetImageThickness()) | 1937 | self.spacing.append(parser.GetImageThickness()) |
1981 | else: | 1938 | else: |
1982 | self.spacing.append(1.0) | 1939 | self.spacing.append(1.0) |
invesalius/reader/dicom_reader.py
1 | -#-------------------------------------------------------------------------- | 1 | +# -------------------------------------------------------------------------- |
2 | # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | 2 | # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas |
3 | # Copyright: (C) 2001 Centro de Pesquisas Renato Archer | 3 | # Copyright: (C) 2001 Centro de Pesquisas Renato Archer |
4 | # Homepage: http://www.softwarepublico.gov.br | 4 | # Homepage: http://www.softwarepublico.gov.br |
5 | # Contact: invesalius@cti.gov.br | 5 | # Contact: invesalius@cti.gov.br |
6 | # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | 6 | # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) |
7 | -#-------------------------------------------------------------------------- | 7 | +# -------------------------------------------------------------------------- |
8 | # Este programa e software livre; voce pode redistribui-lo e/ou | 8 | # Este programa e software livre; voce pode redistribui-lo e/ou |
9 | # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | 9 | # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme |
10 | # publicada pela Free Software Foundation; de acordo com a versao 2 | 10 | # publicada pela Free Software Foundation; de acordo com a versao 2 |
@@ -15,36 +15,35 @@ | @@ -15,36 +15,35 @@ | ||
15 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | 15 | # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM |
16 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | 16 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais |
17 | # detalhes. | 17 | # detalhes. |
18 | -#-------------------------------------------------------------------------- | 18 | +# -------------------------------------------------------------------------- |
19 | import os | 19 | import os |
20 | -import threading | ||
21 | -import tempfile | ||
22 | import sys | 20 | import sys |
23 | - | 21 | +import tempfile |
22 | +import threading | ||
24 | from multiprocessing import cpu_count | 23 | from multiprocessing import cpu_count |
25 | 24 | ||
26 | -import vtk | ||
27 | import gdcm | 25 | import gdcm |
26 | +import vtk | ||
27 | + | ||
28 | # Not showing GDCM warning and debug messages | 28 | # Not showing GDCM warning and debug messages |
29 | gdcm.Trace_DebugOff() | 29 | gdcm.Trace_DebugOff() |
30 | gdcm.Trace_WarningOff() | 30 | gdcm.Trace_WarningOff() |
31 | -from invesalius.pubsub import pub as Publisher | 31 | +import glob |
32 | +import plistlib | ||
32 | 33 | ||
33 | import invesalius.constants as const | 34 | import invesalius.constants as const |
34 | import invesalius.reader.dicom as dicom | 35 | import invesalius.reader.dicom as dicom |
35 | import invesalius.reader.dicom_grouper as dicom_grouper | 36 | import invesalius.reader.dicom_grouper as dicom_grouper |
36 | import invesalius.session as session | 37 | import invesalius.session as session |
37 | -import glob | ||
38 | import invesalius.utils as utils | 38 | import invesalius.utils as utils |
39 | - | ||
40 | from invesalius import inv_paths | 39 | from invesalius import inv_paths |
41 | from invesalius.data import imagedata_utils | 40 | from invesalius.data import imagedata_utils |
41 | +from invesalius.pubsub import pub as Publisher | ||
42 | 42 | ||
43 | -import plistlib | ||
44 | - | ||
45 | -if sys.platform == 'win32': | 43 | +if sys.platform == "win32": |
46 | try: | 44 | try: |
47 | import win32api | 45 | import win32api |
46 | + | ||
48 | _has_win32api = True | 47 | _has_win32api = True |
49 | except ImportError: | 48 | except ImportError: |
50 | _has_win32api = False | 49 | _has_win32api = False |
@@ -79,6 +78,7 @@ def SelectLargerDicomGroup(patient_group): | @@ -79,6 +78,7 @@ def SelectLargerDicomGroup(patient_group): | ||
79 | 78 | ||
80 | return larger_group | 79 | return larger_group |
81 | 80 | ||
81 | + | ||
82 | def SortFiles(filelist, dicom): | 82 | def SortFiles(filelist, dicom): |
83 | # Sort slices | 83 | # Sort slices |
84 | # FIXME: Coronal Crash. necessary verify | 84 | # FIXME: Coronal Crash. necessary verify |
@@ -89,15 +89,17 @@ def SortFiles(filelist, dicom): | @@ -89,15 +89,17 @@ def SortFiles(filelist, dicom): | ||
89 | sorter.SetZSpacingTolerance(1e-10) | 89 | sorter.SetZSpacingTolerance(1e-10) |
90 | sorter.Sort(filelist) | 90 | sorter.Sort(filelist) |
91 | 91 | ||
92 | - #Getting organized image | 92 | + # Getting organized image |
93 | filelist = sorter.GetFilenames() | 93 | filelist = sorter.GetFilenames() |
94 | 94 | ||
95 | return filelist | 95 | return filelist |
96 | 96 | ||
97 | + | ||
97 | tag_labels = {} | 98 | tag_labels = {} |
98 | main_dict = {} | 99 | main_dict = {} |
99 | dict_file = {} | 100 | dict_file = {} |
100 | 101 | ||
102 | + | ||
101 | class LoadDicom: | 103 | class LoadDicom: |
102 | def __init__(self, grouper, filepath): | 104 | def __init__(self, grouper, filepath): |
103 | self.grouper = grouper | 105 | self.grouper = grouper |
@@ -109,8 +111,11 @@ class LoadDicom: | @@ -109,8 +111,11 @@ class LoadDicom: | ||
109 | reader = gdcm.ImageReader() | 111 | reader = gdcm.ImageReader() |
110 | if _has_win32api: | 112 | if _has_win32api: |
111 | try: | 113 | try: |
112 | - reader.SetFileName(utils.encode(win32api.GetShortPathName(self.filepath), | ||
113 | - const.FS_ENCODE)) | 114 | + reader.SetFileName( |
115 | + utils.encode( | ||
116 | + win32api.GetShortPathName(self.filepath), const.FS_ENCODE | ||
117 | + ) | ||
118 | + ) | ||
114 | except TypeError: | 119 | except TypeError: |
115 | reader.SetFileName(win32api.GetShortPathName(self.filepath)) | 120 | reader.SetFileName(win32api.GetShortPathName(self.filepath)) |
116 | else: | 121 | else: |
@@ -118,7 +123,7 @@ class LoadDicom: | @@ -118,7 +123,7 @@ class LoadDicom: | ||
118 | reader.SetFileName(utils.encode(self.filepath, const.FS_ENCODE)) | 123 | reader.SetFileName(utils.encode(self.filepath, const.FS_ENCODE)) |
119 | except TypeError: | 124 | except TypeError: |
120 | reader.SetFileName(self.filepath) | 125 | reader.SetFileName(self.filepath) |
121 | - if (reader.Read()): | 126 | + if reader.Read(): |
122 | file = reader.GetFile() | 127 | file = reader.GetFile() |
123 | # Retrieve data set | 128 | # Retrieve data set |
124 | dataSet = file.GetDataSet() | 129 | dataSet = file.GetDataSet() |
@@ -133,23 +138,23 @@ class LoadDicom: | @@ -133,23 +138,23 @@ class LoadDicom: | ||
133 | tag = gdcm.Tag(0x0008, 0x0005) | 138 | tag = gdcm.Tag(0x0008, 0x0005) |
134 | ds = reader.GetFile().GetDataSet() | 139 | ds = reader.GetFile().GetDataSet() |
135 | image_helper = gdcm.ImageHelper() | 140 | image_helper = gdcm.ImageHelper() |
136 | - data_dict['spacing'] = image_helper.GetSpacingValue(reader.GetFile()) | 141 | + data_dict["spacing"] = image_helper.GetSpacingValue(reader.GetFile()) |
137 | if ds.FindDataElement(tag): | 142 | if ds.FindDataElement(tag): |
138 | - encoding_value = str(ds.GetDataElement(tag).GetValue()).split('\\')[0] | ||
139 | - | 143 | + encoding_value = str(ds.GetDataElement(tag).GetValue()).split("\\")[0] |
144 | + | ||
140 | if encoding_value.startswith("Loaded"): | 145 | if encoding_value.startswith("Loaded"): |
141 | encoding = "ISO_IR 100" | 146 | encoding = "ISO_IR 100" |
142 | else: | 147 | else: |
143 | try: | 148 | try: |
144 | encoding = const.DICOM_ENCODING_TO_PYTHON[encoding_value] | 149 | encoding = const.DICOM_ENCODING_TO_PYTHON[encoding_value] |
145 | except KeyError: | 150 | except KeyError: |
146 | - encoding = 'ISO_IR 100' | 151 | + encoding = "ISO_IR 100" |
147 | else: | 152 | else: |
148 | encoding = "ISO_IR 100" | 153 | encoding = "ISO_IR 100" |
149 | 154 | ||
150 | # Iterate through the Header | 155 | # Iterate through the Header |
151 | iterator = header.GetDES().begin() | 156 | iterator = header.GetDES().begin() |
152 | - while (not iterator.equal(header.GetDES().end())): | 157 | + while not iterator.equal(header.GetDES().end()): |
153 | dataElement = iterator.next() | 158 | dataElement = iterator.next() |
154 | if not dataElement.IsUndefinedLength(): | 159 | if not dataElement.IsUndefinedLength(): |
155 | tag = dataElement.GetTag() | 160 | tag = dataElement.GetTag() |
@@ -164,20 +169,20 @@ class LoadDicom: | @@ -164,20 +169,20 @@ class LoadDicom: | ||
164 | if not group in data_dict.keys(): | 169 | if not group in data_dict.keys(): |
165 | data_dict[group] = {} | 170 | data_dict[group] = {} |
166 | 171 | ||
167 | - if not(utils.VerifyInvalidPListCharacter(data[1])): | 172 | + if not (utils.VerifyInvalidPListCharacter(data[1])): |
168 | data_dict[group][field] = utils.decode(data[1], encoding) | 173 | data_dict[group][field] = utils.decode(data[1], encoding) |
169 | else: | 174 | else: |
170 | data_dict[group][field] = "Invalid Character" | 175 | data_dict[group][field] = "Invalid Character" |
171 | 176 | ||
172 | # Iterate through the Data set | 177 | # Iterate through the Data set |
173 | iterator = dataSet.GetDES().begin() | 178 | iterator = dataSet.GetDES().begin() |
174 | - while (not iterator.equal(dataSet.GetDES().end())): | 179 | + while not iterator.equal(dataSet.GetDES().end()): |
175 | dataElement = iterator.next() | 180 | dataElement = iterator.next() |
176 | if not dataElement.IsUndefinedLength(): | 181 | if not dataElement.IsUndefinedLength(): |
177 | tag = dataElement.GetTag() | 182 | tag = dataElement.GetTag() |
178 | # if (tag.GetGroup() == 0x0009 and tag.GetElement() == 0x10e3) \ | 183 | # if (tag.GetGroup() == 0x0009 and tag.GetElement() == 0x10e3) \ |
179 | - # or (tag.GetGroup() == 0x0043 and tag.GetElement() == 0x1027): | ||
180 | - # continue | 184 | + # or (tag.GetGroup() == 0x0043 and tag.GetElement() == 0x1027): |
185 | + # continue | ||
181 | data = stf.ToStringPair(tag) | 186 | data = stf.ToStringPair(tag) |
182 | stag = tag.PrintAsPipeSeparatedString() | 187 | stag = tag.PrintAsPipeSeparatedString() |
183 | 188 | ||
@@ -189,28 +194,28 @@ class LoadDicom: | @@ -189,28 +194,28 @@ class LoadDicom: | ||
189 | if not group in data_dict.keys(): | 194 | if not group in data_dict.keys(): |
190 | data_dict[group] = {} | 195 | data_dict[group] = {} |
191 | 196 | ||
192 | - if not(utils.VerifyInvalidPListCharacter(data[1])): | ||
193 | - data_dict[group][field] = utils.decode(data[1], encoding, 'replace') | 197 | + if not (utils.VerifyInvalidPListCharacter(data[1])): |
198 | + data_dict[group][field] = utils.decode( | ||
199 | + data[1], encoding, "replace" | ||
200 | + ) | ||
194 | else: | 201 | else: |
195 | data_dict[group][field] = "Invalid Character" | 202 | data_dict[group][field] = "Invalid Character" |
196 | 203 | ||
197 | - | ||
198 | # -------------- To Create DICOM Thumbnail ----------- | 204 | # -------------- To Create DICOM Thumbnail ----------- |
199 | 205 | ||
200 | - | ||
201 | try: | 206 | try: |
202 | data = data_dict[str(0x028)][str(0x1050)] | 207 | data = data_dict[str(0x028)][str(0x1050)] |
203 | - level = [float(value) for value in data.split('\\')][0] | 208 | + level = [float(value) for value in data.split("\\")][0] |
204 | data = data_dict[str(0x028)][str(0x1051)] | 209 | data = data_dict[str(0x028)][str(0x1051)] |
205 | - window = [float(value) for value in data.split('\\')][0] | ||
206 | - except(KeyError, ValueError): | 210 | + window = [float(value) for value in data.split("\\")][0] |
211 | + except (KeyError, ValueError): | ||
207 | level = None | 212 | level = None |
208 | window = None | 213 | window = None |
209 | 214 | ||
210 | img = reader.GetImage() | 215 | img = reader.GetImage() |
211 | thumbnail_path = imagedata_utils.create_dicom_thumbnails(img, window, level) | 216 | thumbnail_path = imagedata_utils.create_dicom_thumbnails(img, window, level) |
212 | 217 | ||
213 | - #------ Verify the orientation -------------------------------- | 218 | + # ------ Verify the orientation -------------------------------- |
214 | 219 | ||
215 | direc_cosines = img.GetDirectionCosines() | 220 | direc_cosines = img.GetDirectionCosines() |
216 | orientation = gdcm.Orientation() | 221 | orientation = gdcm.Orientation() |
@@ -220,41 +225,43 @@ class LoadDicom: | @@ -220,41 +225,43 @@ class LoadDicom: | ||
220 | _type = orientation.GetType(direc_cosines) | 225 | _type = orientation.GetType(direc_cosines) |
221 | label = orientation.GetLabel(_type) | 226 | label = orientation.GetLabel(_type) |
222 | 227 | ||
223 | - | ||
224 | # ---------- Refactory -------------------------------------- | 228 | # ---------- Refactory -------------------------------------- |
225 | - data_dict['invesalius'] = {'orientation_label' : label} | 229 | + data_dict["invesalius"] = {"orientation_label": label} |
226 | 230 | ||
227 | # ------------------------------------------------------------- | 231 | # ------------------------------------------------------------- |
228 | dict_file[self.filepath] = data_dict | 232 | dict_file[self.filepath] = data_dict |
229 | - | ||
230 | - #---------- Verify is DICOMDir ------------------------------- | 233 | + |
234 | + # ---------- Verify is DICOMDir ------------------------------- | ||
231 | is_dicom_dir = 1 | 235 | is_dicom_dir = 1 |
232 | - try: | ||
233 | - if (data_dict[str(0x002)][str(0x002)] != "1.2.840.10008.1.3.10"): #DICOMDIR | ||
234 | - is_dicom_dir = 0 | ||
235 | - except(KeyError): | 236 | + try: |
237 | + if ( | ||
238 | + data_dict[str(0x002)][str(0x002)] != "1.2.840.10008.1.3.10" | ||
239 | + ): # DICOMDIR | ||
236 | is_dicom_dir = 0 | 240 | is_dicom_dir = 0 |
237 | - | ||
238 | - if not(is_dicom_dir): | 241 | + except (KeyError): |
242 | + is_dicom_dir = 0 | ||
243 | + | ||
244 | + if not (is_dicom_dir): | ||
239 | parser = dicom.Parser() | 245 | parser = dicom.Parser() |
240 | - parser.SetDataImage(dict_file[self.filepath], self.filepath, thumbnail_path) | ||
241 | - | 246 | + parser.SetDataImage( |
247 | + dict_file[self.filepath], self.filepath, thumbnail_path | ||
248 | + ) | ||
249 | + | ||
242 | dcm = dicom.Dicom() | 250 | dcm = dicom.Dicom() |
243 | - #self.l.acquire() | 251 | + # self.l.acquire() |
244 | dcm.SetParser(parser) | 252 | dcm.SetParser(parser) |
245 | grouper.AddFile(dcm) | 253 | grouper.AddFile(dcm) |
246 | 254 | ||
247 | - #self.l.release() | ||
248 | - | 255 | + # self.l.release() |
249 | 256 | ||
250 | - #========== used in test ======================================= | ||
251 | - #print dict_file | ||
252 | - #main_dict = dict( | 257 | + # ========== used in test ======================================= |
258 | + # print dict_file | ||
259 | + # main_dict = dict( | ||
253 | # data = dict_file, | 260 | # data = dict_file, |
254 | # labels = tag_labels) | 261 | # labels = tag_labels) |
255 | - #print main_dict | ||
256 | - #print "\n" | ||
257 | - #plistlib.writePlist(main_dict, ".//teste.plist") | 262 | + # print main_dict |
263 | + # print "\n" | ||
264 | + # plistlib.writePlist(main_dict, ".//teste.plist") | ||
258 | 265 | ||
259 | 266 | ||
260 | def yGetDicomGroups(directory, recursive=True, gui=True): | 267 | def yGetDicomGroups(directory, recursive=True, gui=True): |
@@ -271,11 +278,11 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | @@ -271,11 +278,11 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | ||
271 | nfiles = len(filenames) | 278 | nfiles = len(filenames) |
272 | 279 | ||
273 | counter = 0 | 280 | counter = 0 |
274 | - grouper = dicom_grouper.DicomPatientGrouper() | ||
275 | - #q = Queue.Queue() | ||
276 | - #l = threading.Lock() | ||
277 | - #threads = [] | ||
278 | - #for i in xrange(cpu_count()): | 281 | + grouper = dicom_grouper.DicomPatientGrouper() |
282 | + # q = Queue.Queue() | ||
283 | + # l = threading.Lock() | ||
284 | + # threads = [] | ||
285 | + # for i in xrange(cpu_count()): | ||
279 | # t = LoadDicom(grouper, q, l) | 286 | # t = LoadDicom(grouper, q, l) |
280 | # t.start() | 287 | # t.start() |
281 | # threads.append(t) | 288 | # threads.append(t) |
@@ -286,7 +293,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | @@ -286,7 +293,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | ||
286 | filepath = os.path.join(dirpath, name) | 293 | filepath = os.path.join(dirpath, name) |
287 | counter += 1 | 294 | counter += 1 |
288 | if gui: | 295 | if gui: |
289 | - yield (counter,nfiles) | 296 | + yield (counter, nfiles) |
290 | LoadDicom(grouper, filepath) | 297 | LoadDicom(grouper, filepath) |
291 | else: | 298 | else: |
292 | dirpath, dirnames, filenames = os.walk(directory) | 299 | dirpath, dirnames, filenames = os.walk(directory) |
@@ -294,17 +301,17 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | @@ -294,17 +301,17 @@ def yGetDicomGroups(directory, recursive=True, gui=True): | ||
294 | filepath = str(os.path.join(dirpath, name)) | 301 | filepath = str(os.path.join(dirpath, name)) |
295 | counter += 1 | 302 | counter += 1 |
296 | if gui: | 303 | if gui: |
297 | - yield (counter,nfiles) | ||
298 | - #q.put(filepath) | 304 | + yield (counter, nfiles) |
305 | + # q.put(filepath) | ||
299 | 306 | ||
300 | - #for t in threads: | 307 | + # for t in threads: |
301 | # q.put(0) | 308 | # q.put(0) |
302 | 309 | ||
303 | - #for t in threads: | 310 | + # for t in threads: |
304 | # t.join() | 311 | # t.join() |
305 | 312 | ||
306 | - #TODO: Is this commented update necessary? | ||
307 | - #grouper.Update() | 313 | + # TODO: Is this commented update necessary? |
314 | + # grouper.Update() | ||
308 | yield grouper.GetPatientsGroups() | 315 | yield grouper.GetPatientsGroups() |
309 | 316 | ||
310 | 317 | ||
@@ -321,14 +328,14 @@ class ProgressDicomReader: | @@ -321,14 +328,14 @@ class ProgressDicomReader: | ||
321 | self.stoped = True | 328 | self.stoped = True |
322 | 329 | ||
323 | def SetWindowEvent(self, frame): | 330 | def SetWindowEvent(self, frame): |
324 | - self.frame = frame | 331 | + self.frame = frame |
325 | 332 | ||
326 | - def SetDirectoryPath(self, path,recursive=True): | 333 | + def SetDirectoryPath(self, path, recursive=True): |
327 | self.running = True | 334 | self.running = True |
328 | self.stoped = False | 335 | self.stoped = False |
329 | - self.GetDicomGroups(path,recursive) | 336 | + self.GetDicomGroups(path, recursive) |
330 | 337 | ||
331 | - def UpdateLoadFileProgress(self,cont_progress): | 338 | + def UpdateLoadFileProgress(self, cont_progress): |
332 | Publisher.sendMessage("Update dicom load", data=cont_progress) | 339 | Publisher.sendMessage("Update dicom load", data=cont_progress) |
333 | 340 | ||
334 | def EndLoadFile(self, patient_list): | 341 | def EndLoadFile(self, patient_list): |
@@ -337,7 +344,9 @@ class ProgressDicomReader: | @@ -337,7 +344,9 @@ class ProgressDicomReader: | ||
337 | def GetDicomGroups(self, path, recursive): | 344 | def GetDicomGroups(self, path, recursive): |
338 | 345 | ||
339 | if not const.VTK_WARNING: | 346 | if not const.VTK_WARNING: |
340 | - log_path = utils.encode(str(inv_paths.USER_LOG_DIR.joinpath('vtkoutput.txt')), const.FS_ENCODE) | 347 | + log_path = utils.encode( |
348 | + str(inv_paths.USER_LOG_DIR.joinpath("vtkoutput.txt")), const.FS_ENCODE | ||
349 | + ) | ||
341 | fow = vtk.vtkFileOutputWindow() | 350 | fow = vtk.vtkFileOutputWindow() |
342 | fow.SetFileName(log_path) | 351 | fow.SetFileName(log_path) |
343 | ow = vtk.vtkOutputWindow() | 352 | ow = vtk.vtkOutputWindow() |
@@ -354,10 +363,8 @@ class ProgressDicomReader: | @@ -354,10 +363,8 @@ class ProgressDicomReader: | ||
354 | self.EndLoadFile(value_progress) | 363 | self.EndLoadFile(value_progress) |
355 | self.UpdateLoadFileProgress(None) | 364 | self.UpdateLoadFileProgress(None) |
356 | 365 | ||
357 | - #Is necessary in the case user cancel | ||
358 | - #the load, ensure that dicomdialog is closed | ||
359 | - if(self.stoped): | 366 | + # Is necessary in the case user cancel |
367 | + # the load, ensure that dicomdialog is closed | ||
368 | + if self.stoped: | ||
360 | self.UpdateLoadFileProgress(None) | 369 | self.UpdateLoadFileProgress(None) |
361 | - self.stoped = False | ||
362 | - | ||
363 | - | 370 | + self.stoped = False |