Commit 9db53ccb authored by William Clarke's avatar William Clarke
Browse files

More progress towards processing prov and tests.

parent b3936768
......@@ -44,4 +44,35 @@ def test_coilcombine():
assert combined.hdr_ext['ProcessingApplied'][0]['Method'] == 'RF coil combination'
assert combined.hdr_ext['ProcessingApplied'][0]['Details']\
== 'Coil combination, reference data used (wref_raw.nii.gz), prewhitening applied.'
== 'fsl_mrs.utils.preproc.nifti_mrs_proc.coilcombine, reference=wref_raw.nii.gz, no_prewhiten=False.'
def test_average():
nmrs_ref_obj = read_FID(wrefc)
combined = nproc.average(nmrs_ref_obj, 'DIM_DYN')
assert combined.hdr_ext['ProcessingApplied'][0]['Method'] == 'Signal averaging'
assert combined.hdr_ext['ProcessingApplied'][0]['Details']\
== 'fsl_mrs.utils.preproc.nifti_mrs_proc.average, dim=DIM_DYN.'
def test_align():
nmrs_obj = read_FID(metab)
combined = nproc.coilcombine(nmrs_obj)
aligned = nproc.align(combined, 'DIM_DYN', ppmlim=(1.0, 4.0), niter=1, apodize=5)
assert aligned.hdr_ext['ProcessingApplied'][1]['Method'] == 'Frequency and phase correction'
assert aligned.hdr_ext['ProcessingApplied'][1]['Details']\
== 'fsl_mrs.utils.preproc.nifti_mrs_proc.align, dim=DIM_DYN, '\
'target=None, ppmlim=(1.0, 4.0), niter=1, apodize=5.'
def test_aligndiff():
# For want of data this is a bizzare way of using this function.
nmrs_obj = read_FID(wrefc)
aligned = nproc.aligndiff(nmrs_obj, 'DIM_COIL', 'DIM_DYN', 'add', ppmlim=(1.0, 4.0))
assert aligned.hdr_ext['ProcessingApplied'][0]['Method'] == 'Alignment of subtraction sub-spectra'
assert aligned.hdr_ext['ProcessingApplied'][0]['Details']\
== 'fsl_mrs.utils.preproc.nifti_mrs_proc.aligndiff, dim_align=DIM_COIL, '\
'dim_diff=DIM_DYN, diff_type=add, target=None, ppmlim=(1.0, 4.0).'
......@@ -106,15 +106,12 @@ def coilcombine(data, reference=None, no_prewhiten=False, figure=False, report=N
fig.show()
# Update processing prov
processing_info = 'Coil combination, '
processing_info = f'{__name__}.coilcombine, '
if reference is None:
processing_info += 'no reference data, '
processing_info += 'reference=None, '
else:
processing_info += f'reference data used ({reference.filename}), '
if no_prewhiten:
processing_info += 'no prewhitening.'
else:
processing_info += 'prewhitening applied.'
processing_info += f'reference={reference.filename}, '
processing_info += f'no_prewhiten={no_prewhiten}.'
update_processing_prov(combinedc_obj, 'RF coil combination', processing_info)
......@@ -153,6 +150,13 @@ def average(data, dim, figure=False, report=None, report_all=False):
html=report)
if figure:
fig.show()
# Update processing prov
processing_info = f'{__name__}.average, '
processing_info += f'dim={dim}.'
update_processing_prov(combined_obj, 'Signal averaging', processing_info)
return combined_obj
......@@ -205,6 +209,20 @@ def align(data, dim, target=None, ppmlim=None, niter=2, apodize=10, figure=False
if figure:
for ff in fig:
ff.show()
# Update processing prov
processing_info = f'{__name__}.align, '
processing_info += f'dim={dim}, '
if target is not None:
processing_info += 'target used, '
else:
processing_info += 'target=None, '
processing_info += f'ppmlim={ppmlim}, '
processing_info += f'niter={niter}, '
processing_info += f'apodize={apodize}.'
update_processing_prov(aligned_obj, 'Frequency and phase correction', processing_info)
return aligned_obj
......@@ -279,6 +297,19 @@ def aligndiff(data,
if figure:
for ff in fig:
ff.show()
# Update processing prov
processing_info = f'{__name__}.aligndiff, '
processing_info += f'dim_align={dim_align}, '
processing_info += f'dim_diff={dim_diff}, '
processing_info += f'diff_type={diff_type}, '
if target is not None:
processing_info += 'target used, '
else:
processing_info += 'target=None, '
processing_info += f'ppmlim={ppmlim}.'
update_processing_prov(aligned_obj, 'Alignment of subtraction sub-spectra', processing_info)
return aligned_obj
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment