Commit 0aca2ead23a31813c3eb5d4f861a305f13a43ec4
1 parent
0759123d
Exists in
master
and in
67 other branches
FIX: Returned DICOM importation from GUI
Showing
2 changed files
with
15 additions
and
5 deletions
Show diff stats
invesalius/gui/dicom_preview_panel.py
| @@ -33,7 +33,7 @@ import constants as const | @@ -33,7 +33,7 @@ import constants as const | ||
| 33 | from reader import dicom_reader | 33 | from reader import dicom_reader |
| 34 | import data.vtk_utils as vtku | 34 | import data.vtk_utils as vtku |
| 35 | import utils | 35 | import utils |
| 36 | - | 36 | +import vtkgdcm |
| 37 | NROWS = 3 | 37 | NROWS = 3 |
| 38 | NCOLS = 6 | 38 | NCOLS = 6 |
| 39 | NUM_PREVIEWS = NCOLS*NROWS | 39 | NUM_PREVIEWS = NCOLS*NROWS |
| @@ -105,11 +105,15 @@ class DicomInfo(object): | @@ -105,11 +105,15 @@ class DicomInfo(object): | ||
| 105 | 105 | ||
| 106 | @property | 106 | @property |
| 107 | def preview(self): | 107 | def preview(self): |
| 108 | + rdicom = vtkgdcm.vtkGDCMImageReader() | ||
| 108 | if self._preview: | 109 | if self._preview: |
| 109 | return self._preview | 110 | return self._preview |
| 110 | else: | 111 | else: |
| 112 | + rdicom.SetFileName(self.dicom.image.file) | ||
| 113 | + rdicom.Update() | ||
| 114 | + | ||
| 111 | colorer = vtk.vtkImageMapToWindowLevelColors() | 115 | colorer = vtk.vtkImageMapToWindowLevelColors() |
| 112 | - colorer.SetInput(self.dicom.image.imagedata) | 116 | + colorer.SetInput(rdicom.GetOutput()) |
| 113 | colorer.SetWindow(float(self.dicom.image.window)) | 117 | colorer.SetWindow(float(self.dicom.image.window)) |
| 114 | colorer.SetLevel(float(self.dicom.image.level)) | 118 | colorer.SetLevel(float(self.dicom.image.level)) |
| 115 | colorer.SetOutputFormatToRGB() | 119 | colorer.SetOutputFormatToRGB() |
| @@ -770,12 +774,17 @@ class SingleImagePreview(wx.Panel): | @@ -770,12 +774,17 @@ class SingleImagePreview(wx.Panel): | ||
| 770 | value = STR_ACQ % (dicom.acquisition.date, | 774 | value = STR_ACQ % (dicom.acquisition.date, |
| 771 | dicom.acquisition.time) | 775 | dicom.acquisition.time) |
| 772 | self.text_acquisition.SetValue(value) | 776 | self.text_acquisition.SetValue(value) |
| 777 | + | ||
| 778 | + | ||
| 779 | + rdicom = vtkgdcm.vtkGDCMImageReader() | ||
| 780 | + rdicom.SetFileName(dicom.image.file) | ||
| 781 | + rdicom.Update() | ||
| 773 | 782 | ||
| 774 | # ADJUST CONTRAST | 783 | # ADJUST CONTRAST |
| 775 | window_level = dicom.image.level | 784 | window_level = dicom.image.level |
| 776 | window_width = dicom.image.window | 785 | window_width = dicom.image.window |
| 777 | colorer = vtk.vtkImageMapToWindowLevelColors() | 786 | colorer = vtk.vtkImageMapToWindowLevelColors() |
| 778 | - colorer.SetInput(dicom.image.imagedata) | 787 | + colorer.SetInput(rdicom.GetOutput()) |
| 779 | colorer.SetWindow(float(window_width)) | 788 | colorer.SetWindow(float(window_width)) |
| 780 | colorer.SetLevel(float(window_level)) | 789 | colorer.SetLevel(float(window_level)) |
| 781 | 790 |
invesalius/reader/dicom.py
| @@ -91,6 +91,7 @@ class Parser(): | @@ -91,6 +91,7 @@ class Parser(): | ||
| 91 | def __init__(self): | 91 | def __init__(self): |
| 92 | self.filename = "" | 92 | self.filename = "" |
| 93 | self.encoding = "" | 93 | self.encoding = "" |
| 94 | + self.filepath = "" | ||
| 94 | 95 | ||
| 95 | #def SetFileName(self, filename): | 96 | #def SetFileName(self, filename): |
| 96 | """ | 97 | """ |
| @@ -140,7 +141,7 @@ class Parser(): | @@ -140,7 +141,7 @@ class Parser(): | ||
| 140 | 141 | ||
| 141 | def SetDataImage(self, data_image, filename): | 142 | def SetDataImage(self, data_image, filename): |
| 142 | self.data_image = data_image | 143 | self.data_image = data_image |
| 143 | - self.filename = filename | 144 | + self.filename = self.filepath = filename |
| 144 | 145 | ||
| 145 | def __format_time(self,value): | 146 | def __format_time(self,value): |
| 146 | sp1 = value.split(".") | 147 | sp1 = value.split(".") |
| @@ -1240,7 +1241,7 @@ class Parser(): | @@ -1240,7 +1241,7 @@ class Parser(): | ||
| 1240 | DICOM standard tag (0x0010, 0x1010) was used. | 1241 | DICOM standard tag (0x0010, 0x1010) was used. |
| 1241 | """ | 1242 | """ |
| 1242 | try: | 1243 | try: |
| 1243 | - data = self.data_image['0010']['0010'] | 1244 | + data = self.data_image['0010']['1010'] |
| 1244 | except(KeyError): | 1245 | except(KeyError): |
| 1245 | return "" | 1246 | return "" |
| 1246 | 1247 |