Commit 298c9f956bf977f3a7e166be229553001a8c172b

Authored by Thiago Franco de Moraes
1 parent a27efd65
Exists in master

Improvements in surface overwritting

invesalius/control.py
... ... @@ -917,6 +917,9 @@ class Controller():
917 917 sop_class_uid = dicom.acquisition.sop_class_uid
918 918 xyspacing = dicom.image.spacing
919 919 orientation = dicom.image.orientation_label
  920 + samples_per_pixel = dicom.image.samples_per_pixel
  921 +
  922 + print(f"\n\n\n\n{samples_per_pixel =}\n\n\n")
920 923  
921 924 wl = float(dicom.image.level)
922 925 ww = float(dicom.image.window)
... ...
invesalius/data/surface.py
... ... @@ -424,8 +424,11 @@ class SurfaceManager():
424 424 actor.GetProperty().SetOpacity(1-surface.transparency)
425 425  
426 426 if overwrite and self.actors_dict.keys():
427   - old_actor = self.actors_dict[index]
428   - Publisher.sendMessage('Remove surface actor from viewer', actor=old_actor)
  427 + try:
  428 + old_actor = self.actors_dict[index]
  429 + Publisher.sendMessage('Remove surface actor from viewer', actor=old_actor)
  430 + except KeyError:
  431 + pass
429 432  
430 433 self.actors_dict[surface.index] = actor
431 434  
... ...
invesalius/reader/dicom.py
... ... @@ -955,13 +955,14 @@ class Parser():
955 955  
956 956 Critical DICOM tag (0x0028,0x0002). Cannot be edited.
957 957 """
958   - tag = gdcm.Tag(0x0028, 0x0002)
959   - sf = gdcm.StringFilter()
960   - sf.SetFile(self.gdcm_reader.GetFile())
961   - res = sf.ToStringPair(tag)
962   - if (res[1]):
963   - return int(res[1])
964   - return ""
  958 + try:
  959 + data = self.data_image[str(0x0028)][str(0x0002)]
  960 + except KeyError:
  961 + data = 1
  962 +
  963 + if not data:
  964 + return 1
  965 + return data
965 966  
966 967 def GetPhotometricInterpretation(self):
967 968 """
... ... @@ -1967,6 +1968,7 @@ class Image(object):
1967 1968 self.thumbnail_path = parser.thumbnail_path
1968 1969  
1969 1970 self.number_of_frames = parser.GetNumberOfFrames()
  1971 + self.samples_per_pixel = parser.GetImageSamplesPerPixel()
1970 1972  
1971 1973 if (parser.GetImageThickness()):
1972 1974 self.spacing.append(parser.GetImageThickness())
... ...