From 546ea0d2bb7cb5358e2c1a8107c904ef30ed1b87 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Sun, 19 Dec 2010 23:44:32 +0000 Subject: [PATCH] FIX: Fixed open sagittal study --- invesalius/reader/dicom_reader.py | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index a1f092b..a35cf65 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -101,9 +101,8 @@ class LoadDicom: grouper = self.grouper - reader = gdcm.Reader() + reader = gdcm.ImageReader() reader.SetFileName(self.filepath) - if (reader.Read()): file = reader.GetFile() @@ -207,8 +206,20 @@ class LoadDicom: write_png.SetFileName(thumbnail_path) write_png.Write() + #------ Verify the orientation -------------------------------- + + img = reader.GetImage() + direc_cosines = img.GetDirectionCosines() + orientation = gdcm.Orientation() + try: + type = orientation.GetType(tuple(direc_cosines)) + except TypeError: + type = orientation.GetType(direc_cosines) + label = orientation.GetLabel(type) + + # ---------- Refactory -------------------------------------- - data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(self.filepath)} + data_dict['invesalius'] = {'orientation_label' : label} # ------------------------------------------------------------- dict_file[self.filepath] = data_dict @@ -240,30 +251,6 @@ class LoadDicom: #plistlib.writePlist(main_dict, ".//teste.plist")""" -def GetImageOrientationLabel(filename): - """ - Return Label regarding the orientation of - an image. (AXIAL, SAGITTAL, CORONAL, - OBLIQUE or UNKNOWN) - """ - gdcm_reader = gdcm.ImageReader() - gdcm_reader.SetFileName(filename) - - img = gdcm_reader.GetImage() - direc_cosines = img.GetDirectionCosines() - orientation = gdcm.Orientation() - try: - type = orientation.GetType(tuple(direc_cosines)) - except TypeError: - type = orientation.GetType(direc_cosines) - label = orientation.GetLabel(type) - - if (label): - return label - else: - return "" - - def yGetDicomGroups(directory, recursive=True, gui=True): """ Return all full paths to DICOM files inside given directory. -- libgit2 0.21.2