Commit 9c7b39bdba51c6d01c8ffdccc92470941c2b5d0f

Authored by Paulo Henrique Junqueira Amorim
1 parent 25b57760

ADD: Volume Orientation detected original orientation, and add Project() original orientation

invesalius/constants.py
@@ -37,6 +37,11 @@ CORONAL_VOLUME_CAM_POSITION = {"FRONT":(0,0,-1), "BACK":(0,0,1), "RIGHT":(-1,0,0 @@ -37,6 +37,11 @@ CORONAL_VOLUME_CAM_POSITION = {"FRONT":(0,0,-1), "BACK":(0,0,1), "RIGHT":(-1,0,0
37 "LEFT":(1,0,0), "TOP":(0,-1,0), "BOTTOM":(0,1,0),\ 37 "LEFT":(1,0,0), "TOP":(0,-1,0), "BOTTOM":(0,1,0),\
38 "ISOMETRIC":(-0.5,-0.5,-1)} 38 "ISOMETRIC":(-0.5,-0.5,-1)}
39 39
  40 +VOLUME_POSITION = {AXIAL: [AXIAL_VOLUME_CAM_VIEW_UP, AXIAL_VOLUME_CAM_POSITION],
  41 + SAGITAL: [SAGITAL_VOLUME_CAM_VIEW_UP, SAGITAL_VOLUME_CAM_POSITION],
  42 + CORONAL: [CORONAL_VOLUME_CAM_VIEW_UP, CORONAL_VOLUME_CAM_POSITION]}
  43 +
  44 +
40 # Mask threshold options 45 # Mask threshold options
41 proj = Project() 46 proj = Project()
42 THRESHOLD_RANGE = proj.threshold_modes["Bone"] 47 THRESHOLD_RANGE = proj.threshold_modes["Bone"]
invesalius/control.py
@@ -44,7 +44,15 @@ class Controller(): @@ -44,7 +44,15 @@ class Controller():
44 output = dicom.LoadImages(dir_) 44 output = dicom.LoadImages(dir_)
45 45
46 if output: 46 if output:
47 - imagedata, acquisition_modality, tilt_value = output 47 + imagedata, acquisition_modality, tilt_value, orientation = output
  48 + print orientation
  49 + if (orientation == "CORONAL"):
  50 + orientation = const.CORONAL
  51 + elif(orientation == "SAGITTAL"):
  52 + orientation = const.SAGITAL
  53 + else:
  54 + orientation = const.AXIAL
  55 +
48 if (tilt_value): 56 if (tilt_value):
49 #TODO: Show dialog so user can set not other value 57 #TODO: Show dialog so user can set not other value
50 tilt_value *= -1 58 tilt_value *= -1
@@ -54,7 +62,10 @@ class Controller(): @@ -54,7 +62,10 @@ class Controller():
54 "No DICOM files were found. Trying to read with ITK..." 62 "No DICOM files were found. Trying to read with ITK..."
55 imagedata = analyze.ReadDirectory(dir_) 63 imagedata = analyze.ReadDirectory(dir_)
56 acquisition_modality = "MRI" 64 acquisition_modality = "MRI"
57 - 65 +
  66 + #TODO: Verify if all Analyse is AXIAL orientation
  67 + orientation = const.AXIAL
  68 +
58 if not imagedata: 69 if not imagedata:
59 print "Sorry, but there are no medical images supported on this dir." 70 print "Sorry, but there are no medical images supported on this dir."
60 else: 71 else:
@@ -63,7 +74,8 @@ class Controller(): @@ -63,7 +74,8 @@ class Controller():
63 proj.name = "Untitled" 74 proj.name = "Untitled"
64 proj.SetAcquisitionModality(acquisition_modality) 75 proj.SetAcquisitionModality(acquisition_modality)
65 proj.imagedata = imagedata 76 proj.imagedata = imagedata
66 - 77 + proj.original_orientation = orientation
  78 +
67 threshold_range = proj.imagedata.GetScalarRange() 79 threshold_range = proj.imagedata.GetScalarRange()
68 const.THRESHOLD_OUTVALUE = threshold_range[0] 80 const.THRESHOLD_OUTVALUE = threshold_range[0]
69 const.THRESHOLD_INVALUE = threshold_range[1] 81 const.THRESHOLD_INVALUE = threshold_range[1]
invesalius/data/viewer_volume.py
@@ -24,6 +24,7 @@ import vtk @@ -24,6 +24,7 @@ import vtk
24 from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor 24 from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
25 import wx.lib.pubsub as ps 25 import wx.lib.pubsub as ps
26 import constants as const 26 import constants as const
  27 +import project as prj
27 28
28 class Viewer(wx.Panel): 29 class Viewer(wx.Panel):
29 def __init__(self, parent): 30 def __init__(self, parent):
@@ -127,8 +128,11 @@ class Viewer(wx.Panel): @@ -127,8 +128,11 @@ class Viewer(wx.Panel):
127 cam = self.ren.GetActiveCamera() 128 cam = self.ren.GetActiveCamera()
128 cam.SetFocalPoint(0,0,0) 129 cam.SetFocalPoint(0,0,0)
129 130
130 - xv,yv,zv = const.AXIAL_VOLUME_CAM_VIEW_UP[position]  
131 - xp,yp,zp = const.AXIAL_VOLUME_CAM_POSITION[position] 131 + proj = prj.Project()
  132 + orig_orien = proj.original_orientation
  133 +
  134 + xv,yv,zv = const.VOLUME_POSITION[orig_orien][0][position]
  135 + xp,yp,zp = const.VOLUME_POSITION[orig_orien][1][position]
132 136
133 cam.SetViewUp(xv,yv,zv) 137 cam.SetViewUp(xv,yv,zv)
134 cam.SetPosition(xp,yp,zp) 138 cam.SetPosition(xp,yp,zp)
invesalius/project.py
@@ -49,6 +49,7 @@ class Project(object): @@ -49,6 +49,7 @@ class Project(object):
49 49
50 self.presets = Presets() 50 self.presets = Presets()
51 51
  52 + self.original_orientation = None
52 # MRI ? CT? 53 # MRI ? CT?
53 self.threshold_modes = self.presets.thresh_ct 54 self.threshold_modes = self.presets.thresh_ct
54 55
invesalius/reader/dicom_reader.py
@@ -109,7 +109,7 @@ def LoadImages(dir_): @@ -109,7 +109,7 @@ def LoadImages(dir_):
109 read.Update() 109 read.Update()
110 110
111 #Resample image in x,y dimension 111 #Resample image in x,y dimension
112 - img = ResampleImage2D(read.GetOutput(), 200) 112 + img = ResampleImage2D(read.GetOutput(), 256)
113 113
114 #Stack images in Z axes 114 #Stack images in Z axes
115 img_app.AddInput(img) 115 img_app.AddInput(img)
@@ -124,7 +124,7 @@ def LoadImages(dir_): @@ -124,7 +124,7 @@ def LoadImages(dir_):
124 124
125 img_axial.Update() 125 img_axial.Update()
126 126
127 - return img_axial, acquisition_modality, tilt 127 + return img_axial, acquisition_modality, tilt, orientation
128 128
129 def GetDicomFiles(path, recursive = False): 129 def GetDicomFiles(path, recursive = False):
130 # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER 130 # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER