From 9c7b39bdba51c6d01c8ffdccc92470941c2b5d0f Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Mon, 10 Aug 2009 16:48:16 +0000 Subject: [PATCH] ADD: Volume Orientation detected original orientation, and add Project() original orientation --- invesalius/constants.py | 5 +++++ invesalius/control.py | 18 +++++++++++++++--- invesalius/data/viewer_volume.py | 8 ++++++-- invesalius/project.py | 1 + invesalius/reader/dicom_reader.py | 4 ++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 1ad8aa1..cdaf140 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -37,6 +37,11 @@ CORONAL_VOLUME_CAM_POSITION = {"FRONT":(0,0,-1), "BACK":(0,0,1), "RIGHT":(-1,0,0 "LEFT":(1,0,0), "TOP":(0,-1,0), "BOTTOM":(0,1,0),\ "ISOMETRIC":(-0.5,-0.5,-1)} +VOLUME_POSITION = {AXIAL: [AXIAL_VOLUME_CAM_VIEW_UP, AXIAL_VOLUME_CAM_POSITION], + SAGITAL: [SAGITAL_VOLUME_CAM_VIEW_UP, SAGITAL_VOLUME_CAM_POSITION], + CORONAL: [CORONAL_VOLUME_CAM_VIEW_UP, CORONAL_VOLUME_CAM_POSITION]} + + # Mask threshold options proj = Project() THRESHOLD_RANGE = proj.threshold_modes["Bone"] diff --git a/invesalius/control.py b/invesalius/control.py index abff53f..7d8bc70 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -44,7 +44,15 @@ class Controller(): output = dicom.LoadImages(dir_) if output: - imagedata, acquisition_modality, tilt_value = output + imagedata, acquisition_modality, tilt_value, orientation = output + print orientation + if (orientation == "CORONAL"): + orientation = const.CORONAL + elif(orientation == "SAGITTAL"): + orientation = const.SAGITAL + else: + orientation = const.AXIAL + if (tilt_value): #TODO: Show dialog so user can set not other value tilt_value *= -1 @@ -54,7 +62,10 @@ class Controller(): "No DICOM files were found. Trying to read with ITK..." imagedata = analyze.ReadDirectory(dir_) acquisition_modality = "MRI" - + + #TODO: Verify if all Analyse is AXIAL orientation + orientation = const.AXIAL + if not imagedata: print "Sorry, but there are no medical images supported on this dir." else: @@ -63,7 +74,8 @@ class Controller(): proj.name = "Untitled" proj.SetAcquisitionModality(acquisition_modality) proj.imagedata = imagedata - + proj.original_orientation = orientation + threshold_range = proj.imagedata.GetScalarRange() const.THRESHOLD_OUTVALUE = threshold_range[0] const.THRESHOLD_INVALUE = threshold_range[1] diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index 9acd074..eb83142 100755 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -24,6 +24,7 @@ import vtk from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor import wx.lib.pubsub as ps import constants as const +import project as prj class Viewer(wx.Panel): def __init__(self, parent): @@ -127,8 +128,11 @@ class Viewer(wx.Panel): cam = self.ren.GetActiveCamera() cam.SetFocalPoint(0,0,0) - xv,yv,zv = const.AXIAL_VOLUME_CAM_VIEW_UP[position] - xp,yp,zp = const.AXIAL_VOLUME_CAM_POSITION[position] + proj = prj.Project() + orig_orien = proj.original_orientation + + xv,yv,zv = const.VOLUME_POSITION[orig_orien][0][position] + xp,yp,zp = const.VOLUME_POSITION[orig_orien][1][position] cam.SetViewUp(xv,yv,zv) cam.SetPosition(xp,yp,zp) diff --git a/invesalius/project.py b/invesalius/project.py index 522e682..dc3df6c 100755 --- a/invesalius/project.py +++ b/invesalius/project.py @@ -49,6 +49,7 @@ class Project(object): self.presets = Presets() + self.original_orientation = None # MRI ? CT? self.threshold_modes = self.presets.thresh_ct diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index f27ce25..63fbe98 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -109,7 +109,7 @@ def LoadImages(dir_): read.Update() #Resample image in x,y dimension - img = ResampleImage2D(read.GetOutput(), 200) + img = ResampleImage2D(read.GetOutput(), 256) #Stack images in Z axes img_app.AddInput(img) @@ -124,7 +124,7 @@ def LoadImages(dir_): img_axial.Update() - return img_axial, acquisition_modality, tilt + return img_axial, acquisition_modality, tilt, orientation def GetDicomFiles(path, recursive = False): # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER -- libgit2 0.21.2