Skip to content

Commit

Permalink
BUGFIX: account for negative Spacings Between Slices in Siemens Multi…
Browse files Browse the repository at this point in the history
…Slice 3D SPECT data
  • Loading branch information
gschramm committed Aug 6, 2021
1 parent 156b50a commit 774ac6c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pymirc/fileio/read_dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def reorient_volume(self, patvol):
3d numpy array
reoriented numpy array in LPS orientation
"""

# check the directions of the norm, col and row dir and revert some axis if necessary
if(self.normdir == -1):
patvol = patvol[::-1,:,:]
Expand Down Expand Up @@ -372,6 +373,13 @@ def get_multislice_3d_data(self, dcm_data):
self.v0 /= np.sqrt((self.v0**2).sum())
self.v0 *= self.sliceDistance

# heuristic modification of v0 and normdir if SpacingBetweenSlices is negative
# tested on Siemens SPECT data
if 'SpacingBetweenSlices' in dcm_data:
if float(dcm_data.SpacingBetweenSlices) < 0:
self.v0 *= -1
self.normdir *= -1

ipp = None

if 'DetectorInformationSequence' in dcm_data:
Expand Down Expand Up @@ -403,6 +411,7 @@ def get_multislice_3d_data(self, dcm_data):
self.affine[:3,2] = self.v2
self.affine[:3,3] = self.offset


return patvol


Expand Down

0 comments on commit 774ac6c

Please sign in to comment.