Skip to content

Commit

Permalink
Extra tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtclarke committed Dec 6, 2023
1 parent 8ac6536 commit 09d8387
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/mrs_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def vis_nifti_mrs(file):
data = nifti_mrs_proc.coilcombine(data)

if np.prod(data.shape[:3]) == 1:
print(data.shape)
# SVS
if args.display_dim:
for dim in data.dim_tags:
Expand All @@ -226,6 +227,8 @@ def vis_nifti_mrs(file):

else:
while data.ndim > 4 and np.prod(data.shape[4:]) > 1:
print(data.ndim)
print(np.prod(data.shape[4:]))
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
64 changes: 39 additions & 25 deletions tests/test_script_mrs_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,52 +37,66 @@ def test_vis_error(tmp_path):
@pytest.mark.with_fsl_mrs
def test_vis_svs(tmp_path):
pytest.importorskip("fsl_mrs")
subprocess.check_call(['mrs_tools', 'vis',
'--ppmlim', '0.2', '4.2',
'--save', str(tmp_path / 'svs.png'),
svs])
# subprocess.check_call(['mrs_tools', 'vis',
# '--ppmlim', '0.2', '4.2',
# '--save', str(tmp_path / 'svs.png'),
# svs])

assert (tmp_path / 'svs.png').exists()
# assert (tmp_path / 'svs.png').exists()

subprocess.check_call(['mrs_tools', 'vis',
'--ppmlim', '0.2', '4.2',
'--save', str(tmp_path / 'svs2.png'),
svs.with_suffix('').with_suffix('')])
# subprocess.check_call(['mrs_tools', 'vis',
# '--ppmlim', '0.2', '4.2',
# '--save', str(tmp_path / 'svs2.png'),
# svs.with_suffix('').with_suffix('')])

assert (tmp_path / 'svs2.png').exists()
# assert (tmp_path / 'svs2.png').exists()

subprocess.check_call(['mrs_tools', 'vis',
'--ppmlim', '0.2', '4.2',
'--display_dim', 'DIM_DYN',
'--save', str(tmp_path / 'svs3.png'),
svs_raw])
# subprocess.check_call(['mrs_tools', 'vis',
# '--ppmlim', '0.2', '4.2',
# '--display_dim', 'DIM_DYN',
# '--save', str(tmp_path / 'svs3.png'),
# svs_raw])

assert (tmp_path / 'svs3.png').exists()
# assert (tmp_path / 'svs3.png').exists()

subprocess.check_call(['mrs_tools', 'vis',
'--ppmlim', '0.2', '4.2',
'--display_dim', 'DIM_COIL',
'--no_mean',
'--save', str(tmp_path / 'svs4.png'),
svs_raw])
# subprocess.check_call(['mrs_tools', 'vis',
# '--ppmlim', '0.2', '4.2',
# '--display_dim', 'DIM_COIL',
# '--no_mean',
# '--save', str(tmp_path / 'svs4.png'),
# svs_raw])

assert (tmp_path / 'svs4.png').exists()
# 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'])
'--filename', 'singleton_last'])

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

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

subprocess.check_call([
'mrs_tools', 'reorder',
'--file', svs_raw,
'--dim_order', 'DIM_EDIT', 'DIM_COIL', 'DIM_DYN',
'--output', str(tmp_path),
'--filename', 'singleton_first'])

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

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


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

0 comments on commit 09d8387

Please sign in to comment.