From fe2987186f0182cd771d3612cf971a6272cf0ae5 Mon Sep 17 00:00:00 2001 From: tatiana Date: Fri, 2 Oct 2009 18:40:27 +0000 Subject: [PATCH] ENC: Gantry tilt dialog, dicom import enhacements --- invesalius/control.py | 22 ++++++++++++++-------- invesalius/reader/dicom.py | 32 +++++++++++++++++++------------- invesalius/reader/dicom_grouper.py | 5 +++-- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index 867f96f..c56aa29 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -9,6 +9,7 @@ import project as prj import data.imagedata_utils as utils import data.surface as surface import data.volume as volume +import gui.dialogs as dialog import reader.dicom_reader as dcm import reader.analyze_reader as analyze @@ -52,9 +53,10 @@ class Controller(): proj.name = "Untitled" if output: - #acquisition_modality, tilt_value, orientation,window, level + # In this case, there were DICOM files on the folder imagedata, dicom = output - + + # Set orientation orientation = dicom.image.orientation_label if (orientation == "CORONAL"): orientation = const.CORONAL @@ -62,16 +64,20 @@ class Controller(): orientation = const.SAGITAL else: orientation = const.AXIAL - - window = window = float(dicom.image.window) - level = level = float(dicom.image.level) + + # Retrieve window, level, modalit + window = float(dicom.image.window) + level = float(dicom.image.level) acquisition_modality = dicom.acquisition.modality + + # If there was gantry tilt, fix it: tilt_value = dicom.acquisition.tilt if (tilt_value): - #TODO: Show dialog so user can set not other value - tilt_value *= -1 + # Tell user gantry tilt and fix, according to answer + message = "Fix gantry tilt applying the degrees bellow" + value = -1*tilt_value + tilt_value = dialog.ShowNumberDialog(message, value) imagedata = utils.FixGantryTilt(imagedata, tilt_value) - print "Fixed Gantry Tilt", str(tilt_value) else: "No DICOM files were found. Trying to read with ITK..." imagedata = analyze.ReadDirectory(dir_) diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index 1037b23..9bef4ad 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -1198,7 +1198,7 @@ class Parser(): .GetSliceThickness() if (data): return float(data) - return None + return 0 def GetImageConvolutionKernel(self): """ @@ -1684,22 +1684,28 @@ class Image(object): self.position = [1, 1, 1] self.number = parser.GetImageNumber() + print "*****************" self.spacing = spacing = parser.GetPixelSpacing() + print "Spacing:", spacing self.orientation_label = parser.GetImageOrientationLabel() self.file = parser.filename - if (parser.GetImageThickness()): - spacing.append(parser.GetImageThickness()) - else: - try: - spacing.append(1.5) - except(AttributeError): - spacing = [1, 1, 1] - - spacing[0] = round(spacing[0],2) - spacing[1] = round(spacing[1],2) - spacing[2] = round(spacing[2],2) - self.spacing = spacing + if self.spacing: + print "Thickness:", parser.GetImageThickness() + # If the image is "alone", we set thickness as z axis + if (parser.GetImageThickness()): + spacing.append(parser.GetImageThickness()) + else: + try: + spacing.append(1.5) + except(AttributeError): + spacing = [1, 1, 1] + + # If there are too many float digits + spacing[0] = round(spacing[0],2) + spacing[1] = round(spacing[1],2) + spacing[2] = round(spacing[2],2) + self.spacing = spacing try: self.type = parser.GetImageType()[2] diff --git a/invesalius/reader/dicom_grouper.py b/invesalius/reader/dicom_grouper.py index fe84bda..ed5077c 100644 --- a/invesalius/reader/dicom_grouper.py +++ b/invesalius/reader/dicom_grouper.py @@ -78,7 +78,7 @@ class DicomGroups: """ return self.groups_dcm - def GetSplitterTyoe(self): + def GetSplitterType(self): """ Return Integer with the SplitterType 0 option used the name of patient information, @@ -347,4 +347,5 @@ class DicomGroups: spacing = None for information in self.groups_dcm[key][0]: - information.image.spacing[2] = spacing + if information.image.spacing: + information.image.spacing[2] = spacing -- libgit2 0.21.2