Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Real world value mapping #169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nibabel/nicom/dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ def _scale_data(self, data):
# depending on pydicom and dicom files, values might need casting from Decimal to float
scale = float(self.get('RescaleSlope', 1))
offset = float(self.get('RescaleIntercept', 0))
if scale == 1 and offset == 0:
mpseq = self.get('RealWorldValueMappingSequence',None)
if mpseq == None: # compatibility with pydicom < 0.9.7 ????
mpseq = self.get('RealWorldValueMappings',None)
if mpseq != None and len(mpseq)>0:
mpseq = mpseq[0]
scale = mpseq.get('RealWorldValueSlope',1)
offset = mpseq.get('RealWorldValueIntercept',0)
# a little optimization. If we are applying either the scale or
# the offset, we need to allow upcasting to float.
if scale != 1:
Expand Down