From 298c9f956bf977f3a7e166be229553001a8c172b Mon Sep 17 00:00:00 2001 From: Thiago Franco de Moraes Date: Tue, 4 May 2021 16:43:55 -0300 Subject: [PATCH] Improvements in surface overwritting --- invesalius/control.py | 3 +++ invesalius/data/surface.py | 7 +++++-- invesalius/reader/dicom.py | 16 +++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index e3e8144..44cd58f 100644 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -917,6 +917,9 @@ class Controller(): sop_class_uid = dicom.acquisition.sop_class_uid xyspacing = dicom.image.spacing orientation = dicom.image.orientation_label + samples_per_pixel = dicom.image.samples_per_pixel + + print(f"\n\n\n\n{samples_per_pixel =}\n\n\n") wl = float(dicom.image.level) ww = float(dicom.image.window) diff --git a/invesalius/data/surface.py b/invesalius/data/surface.py index 1139e94..3fb5ba5 100644 --- a/invesalius/data/surface.py +++ b/invesalius/data/surface.py @@ -424,8 +424,11 @@ class SurfaceManager(): actor.GetProperty().SetOpacity(1-surface.transparency) if overwrite and self.actors_dict.keys(): - old_actor = self.actors_dict[index] - Publisher.sendMessage('Remove surface actor from viewer', actor=old_actor) + try: + old_actor = self.actors_dict[index] + Publisher.sendMessage('Remove surface actor from viewer', actor=old_actor) + except KeyError: + pass self.actors_dict[surface.index] = actor diff --git a/invesalius/reader/dicom.py b/invesalius/reader/dicom.py index 799f562..105c9d9 100644 --- a/invesalius/reader/dicom.py +++ b/invesalius/reader/dicom.py @@ -955,13 +955,14 @@ class Parser(): Critical DICOM tag (0x0028,0x0002). Cannot be edited. """ - tag = gdcm.Tag(0x0028, 0x0002) - sf = gdcm.StringFilter() - sf.SetFile(self.gdcm_reader.GetFile()) - res = sf.ToStringPair(tag) - if (res[1]): - return int(res[1]) - return "" + try: + data = self.data_image[str(0x0028)][str(0x0002)] + except KeyError: + data = 1 + + if not data: + return 1 + return data def GetPhotometricInterpretation(self): """ @@ -1967,6 +1968,7 @@ class Image(object): self.thumbnail_path = parser.thumbnail_path self.number_of_frames = parser.GetNumberOfFrames() + self.samples_per_pixel = parser.GetImageSamplesPerPixel() if (parser.GetImageThickness()): self.spacing.append(parser.GetImageThickness()) -- libgit2 0.21.2