Skip to content

Commit

Permalink
ENH: twix mixed headers (#135)
Browse files Browse the repository at this point in the history
* Catch an odd case where there were XA like headers in VX scan.

* Update changelog
  • Loading branch information
wtclarke authored Apr 18, 2024
1 parent 306c039 commit 239de68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This document contains the Spec2nii release history in reverse chronological ord
---------------------------------
- Refinements and improvements to the GE SVS pipeline from Mark Mikkelsen.
- Add support for older jMRUI text formats which have a slightly different syntax. With thanks to Donnie Cameron.
- Handle odd case of XA like .twix headers in a VX baseline scan

0.7.3 (Tuesday 12th March 2024)
-------------------------------
Expand Down
12 changes: 11 additions & 1 deletion spec2nii/Siemens/twixfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,17 @@ def examineTwix(twixObj, fileName, mraid):
def extractTwixMetadata(mapVBVDHdr, original_file):
"""Pass to appropriate extractTwixMetadata function for software version."""
if xa_or_vx(mapVBVDHdr) == 'vx':
return extractTwixMetadata_vx(mapVBVDHdr, original_file)
try:
return extractTwixMetadata_vx(mapVBVDHdr, original_file)
except KeyError as original_err:
try:
print(f'VX-line scanner headers caused KeyError {original_err}.')
print('Trying XA interpreter. ')
return extractTwixMetadata_xa(mapVBVDHdr, original_file)
except Exception as backup_err:
print(f'XA interpreter failed with reason {backup_err}. Raising original error.')
raise original_err

elif xa_or_vx(mapVBVDHdr) == 'xa':
return extractTwixMetadata_xa(mapVBVDHdr, original_file)

Expand Down

0 comments on commit 239de68

Please sign in to comment.