From f464a5141e012340ead827101519f114a527e955 Mon Sep 17 00:00:00 2001 From: tatiana Date: Tue, 28 Jul 2009 20:44:29 +0000 Subject: [PATCH] ENC: Imagedata reformat matrix is set in constants, and not simply hardcoded on dicom_reader --- invesalius/constants.py | 1 + invesalius/reader/dicom_reader.py | 42 +++++++++++++++++------------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/invesalius/constants.py b/invesalius/constants.py index 9c3725c..be69fa0 100644 --- a/invesalius/constants.py +++ b/invesalius/constants.py @@ -92,4 +92,5 @@ WINDOW_LEVEL = {"Abdomen":(350,50), "Vasculature - Hard":(240,80), "Vasculature - Soft":(650,160)} +REDUCE_IMAGEDATA_QUALITY = 1 diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 4eeff7f..6561766 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -23,19 +23,19 @@ import vtk import vtkgdcm import gdcm +import constants as const import dicom import dicom_grouper from data.imagedata_utils import ResampleImage2D -import constants as const def LoadImages(dir_): # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER - #if 0: - fow = vtk.vtkFileOutputWindow() - fow.SetFileName('vtk_output.txt') - ow = vtk.vtkOutputWindow () - ow.SetInstance (fow) + if 0: + fow = vtk.vtkFileOutputWindow() + fow.SetFileName('vtk_output.txt') + ow = vtk.vtkOutputWindow () + ow.SetInstance (fow) dcm_files, acquisition_modality = GetDicomFiles(dir_) @@ -84,15 +84,19 @@ def LoadImages(dir_): array = vtk.vtkStringArray() - #Case Reduce Matrix of the Image - reduce_matrix = 0 - img_app = vtk.vtkImageAppend() img_app.SetAppendAxis(2) #Define Stack in Z for x in xrange(len(files)): - if not(reduce_matrix): + if not(const.REDUCE_IMAGEDATA_QUALITY): array.InsertValue(x,files[x]) + read = vtkgdcm.vtkGDCMImageReader() + read.SetFileNames(array) + read.Update() + + img_axial = vtk.vtkImageData() + img_axial.DeepCopy(read.GetOutput()) + img_axial.SetSpacing(spacing, spacing, spacing_z) else: #SIf the resolution of the #matrix is very large @@ -107,27 +111,15 @@ def LoadImages(dir_): img_app.AddInput(img) img_app.Update() - img_axial = vtk.vtkImageData() - - if (reduce_matrix): - img_axial.DeepCopy(img_app.GetOutput()) - img_axial.SetSpacing(img_axial.GetSpacing()[0],\ + img_axial = vtk.vtkImageData() + img_axial.DeepCopy(img_app.GetOutput()) + img_axial.SetSpacing(img_axial.GetSpacing()[0],\ img_axial.GetSpacing()[1],\ spacing_z) - else: - read = vtkgdcm.vtkGDCMImageReader() - read.SetFileNames(array) - read.Update() - img_axial.DeepCopy(read.GetOutput()) - img_axial.SetSpacing(spacing, spacing, spacing_z) img_axial.Update() - thresh_min, thresh_max = img_axial.GetScalarRange() - const.THRESHOLD_INVALUE = thresh_max - const.THRESHOLD_OUTVALUE = thresh_min - return img_axial, acquisition_modality, tilt def GetDicomFiles(path, recursive = False): -- libgit2 0.21.2