Skip to content

Commit

Permalink
Deal with singleton spectra display issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtclarke committed Dec 6, 2023
1 parent 7b4c026 commit 8ac6536
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
This document contains the nifti_mrs_tools release history in reverse chronological order.

1.1.0 (WIP)
-----------------------------
1.0.3 (Wednesday 6th December 2023)
-----------------------------------
- Fixes issue with displaying spectra with a singleton dimension
- Code spelling changes.

1.0.2 (Friday 28th July 2023)
Expand Down
2 changes: 1 addition & 1 deletion src/mrs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def vis_nifti_mrs(file):
fig = plot_spectra(data.mrs(), ppmlim=args.ppmlim, plot_avg=args.no_mean)

else:
while data.ndim > 4:
while data.ndim > 4 and np.prod(data.shape[4:]) > 1:
print(f'Averaging {data.dim_tags[0]}')
data = nifti_mrs_proc.average(data, data.dim_tags[0])
fig = plot_spectrum(data.mrs(), ppmlim=args.ppmlim)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_script_mrs_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ def test_vis_svs(tmp_path):

assert (tmp_path / 'svs4.png').exists()

# Test SVS with singleton dimension
subprocess.check_call([
'mrs_tools', 'reorder',
'--file', svs_raw,
'--dim_order', 'DIM_COIL', 'DIM_DYN', 'DIM_EDIT',
'--output', str(tmp_path),
'--filename', 'singleton'])

subprocess.check_call(['mrs_tools', 'vis',
'--ppmlim', '0.2', '4.2',
'--save', str(tmp_path / 'svs5.png'),
str(tmp_path / 'singleton.nii.gz')])

assert (tmp_path / 'svs5.png').exists()


# def test_vis_basis(tmp_path):
# subprocess.check_call(['mrs_tools', 'vis',
Expand Down

0 comments on commit 8ac6536

Please sign in to comment.