Skip to content

Commit

Permalink
Fixed bug in dict reading in phillips metadata creation. (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtclarke authored Feb 9, 2023
1 parent 1f13235 commit 1be740a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
This document contains the Spec2nii release history in reverse chronological order.

0.6.5 (Wednesday 8th February 2023)
-----------------------------------
- Fixed bug in philips and rda metadata translation functions.

0.6.4 (Tuesday 7th February 2023)
---------------------------------
- Added first pass at new `spec2nii auto` feature with automatic conversion for some formats.
Expand Down
10 changes: 5 additions & 5 deletions spec2nii/Philips/philips.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ def spar_to_nmrs_hdrext(spar_dict):
spar_dict["nucleus"])

def set_standard_def(nifti_mrs_key, location, key, cast=None):
try:
if key in location\
and location[key] is not None:
if cast is not None:
obj.set_standard_def(nifti_mrs_key, cast(getattr(location, key)))
obj.set_standard_def(nifti_mrs_key, cast(location[key]))
else:
obj.set_standard_def(nifti_mrs_key, getattr(location, key))
except AttributeError:
pass
obj.set_standard_def(nifti_mrs_key, location[key])

# # 5.1 MRS specific Tags
# 'EchoTime'
obj.set_standard_def('EchoTime', float(spar_dict['echo_time']) * 1E-3)
Expand Down
9 changes: 4 additions & 5 deletions spec2nii/Siemens/rda.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ def extractRdaMetadata(hdr):

# Standard defined metadata
def set_standard_def(nifti_mrs_key, location, key, cast=None):
try:
if key in location\
and location[key] is not None:
if cast is not None:
obj.set_standard_def(nifti_mrs_key, cast(getattr(location, key)))
obj.set_standard_def(nifti_mrs_key, cast(location[key]))
else:
obj.set_standard_def(nifti_mrs_key, getattr(location, key))
except AttributeError:
pass
obj.set_standard_def(nifti_mrs_key, location[key])

# # 5.1 MRS specific Tags
# 'EchoTime'
Expand Down
1 change: 1 addition & 0 deletions tests/test_philips_sdat_spar.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_svs(tmp_path):
assert hdr_ext['SpectrometerFrequency'][0] == 127.759464
assert hdr_ext['ResonantNucleus'][0] == '1H'
assert hdr_ext['OriginalFile'][0] == svs_path_sdat.name
assert hdr_ext['SoftwareVersions'] == '5.5.2 ; .5.2 ;'


def test_svs_edit(tmp_path):
Expand Down

0 comments on commit 1be740a

Please sign in to comment.