diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ee756a17c0c7a0d9f1288ba79937d92ee462bc0..c66cfbd3075736f07aebc64c57cceaa01f93474c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,10 @@ This document contains the FSL-MRS release history in reverse chronological order. +2.4.3 (Friday 21st March 2025) +------------------------------ +- Fixed bug introduced in 2.4.2 where the option to suppress alignment step in `fsl_mrs_preproc{_edit}` only suppressed some alignment. +- Update minimum hlsvdpropy version to 2.0.2 + 2.4.2 (Monday 17th March 2025) ------------------------------ - Added a `freeshift_lorentzian` model with inter-metabolite shifts (freeshift) and lorentzian lineshape. diff --git a/fsl_mrs/scripts/fsl_mrs_preproc.py b/fsl_mrs/scripts/fsl_mrs_preproc.py index d1dd2f58b276d0689769b74ecf6c55949cbbf5cb..cdb03a2664a0522a4a705dc3b90f040de2086f09 100755 --- a/fsl_mrs/scripts/fsl_mrs_preproc.py +++ b/fsl_mrs/scripts/fsl_mrs_preproc.py @@ -275,13 +275,21 @@ def main(): covariance=covariance, no_prewhiten=no_prewhiten) - verbose_print('... Align Dynamics (1st iteration) ...') - supp_data = nifti_mrs_proc.align( - supp_data, - 'DIM_DYN', - ppmlim=args.align_limits, - window=args.align_window, - report=report_dir) + if args.align: + verbose_print('... Align Dynamics (1st iteration) ...') + supp_data = nifti_mrs_proc.align( + supp_data, + 'DIM_DYN', + ppmlim=args.align_limits, + window=args.align_window, + report=report_dir) + + if has_multiple_dynamics(ref_data): + ref_data = nifti_mrs_proc.align(ref_data, 'DIM_DYN', ppmlim=(0, 8)) + if args.quant is not None and has_multiple_dynamics(quant_data): + quant_data = nifti_mrs_proc.align(quant_data, 'DIM_DYN', ppmlim=(0, 8)) + if args.ecc is not None and has_multiple_dynamics(ecc_data): + ecc_data = nifti_mrs_proc.align(ecc_data, 'DIM_DYN', ppmlim=(0, 8)) # Bad average removal on the suppressed data if args.unlike: @@ -307,23 +315,15 @@ def main(): verbose_print(f'{bd_shape}/{supp_shape + bd_shape} ' 'bad averages identified and removed.') - # Frequency and phase align the FIDs - if args.align: - verbose_print('... Align Dynamics (2nd iteration) ...') - supp_data = nifti_mrs_proc.align( - supp_data, - 'DIM_DYN', - ppmlim=args.align_limits, - window=args.align_window, - report=report_dir) - - if has_multiple_dynamics(ref_data): - ref_data = nifti_mrs_proc.align(ref_data, 'DIM_DYN', ppmlim=(0, 8)) - - if args.quant is not None and has_multiple_dynamics(quant_data): - quant_data = nifti_mrs_proc.align(quant_data, 'DIM_DYN', ppmlim=(0, 8)) - if args.ecc is not None and has_multiple_dynamics(ecc_data): - ecc_data = nifti_mrs_proc.align(ecc_data, 'DIM_DYN', ppmlim=(0, 8)) + # After removal repeat frequency and phase align the FIDs + if args.align: + verbose_print('... Align Dynamics (2nd iteration) ...') + supp_data = nifti_mrs_proc.align( + supp_data, + 'DIM_DYN', + ppmlim=args.align_limits, + window=args.align_window, + report=report_dir) # Average the data (if asked to do so) if args.average: diff --git a/fsl_mrs/scripts/fsl_mrs_preproc_edit.py b/fsl_mrs/scripts/fsl_mrs_preproc_edit.py index e84a266b79f99095004e624cb3a02ca7629a8aca..8e4ccbd637f32cbb9935eb17a3cd50ecca5f23a1 100644 --- a/fsl_mrs/scripts/fsl_mrs_preproc_edit.py +++ b/fsl_mrs/scripts/fsl_mrs_preproc_edit.py @@ -263,17 +263,19 @@ def main(): no_prewhiten=no_prewhiten) # Frequency and phase align the FIDs in the ON/OFF condition - verbose_print('... Align Dynamics ...') - supp_data = nifti_mrs_proc.align( - supp_data, - 'DIM_DYN', - ppmlim=args.align_ppm_dynamic, - niter=4, - window=args.align_window_dynamic, - report=report_dir, - report_all=True) + if args.align: + verbose_print('... Align Dynamics ...') + supp_data = nifti_mrs_proc.align( + supp_data, + 'DIM_DYN', + ppmlim=args.align_ppm_dynamic, + niter=4, + window=args.align_window_dynamic, + report=report_dir, + report_all=True) if args.dynamic_align and args.align: + verbose_print('... Align Dynamics using spectral model ...') # Run dynamic fitting based alignment edit_0, edit_1 = ntools.split(supp_data, 'DIM_EDIT', 0) @@ -296,7 +298,7 @@ def main(): supp_data = ntools.merge([edit_0_aligned, edit_1_aligned], 'DIM_EDIT') - elif args.align: + if args.align: if 'DIM_DYN' in ref_data.dim_tags: ref_data = nifti_mrs_proc.align(ref_data, 'DIM_DYN', ppmlim=(0, 8)) diff --git a/fsl_mrs/tests/test_scripts_preproc.py b/fsl_mrs/tests/test_scripts_preproc.py index af3b2f1dbfdd87d520889147f5e78d1477e38a5c..a4b0fc708b34eb111dbcfe65f84b19cd2be7b98f 100644 --- a/fsl_mrs/tests/test_scripts_preproc.py +++ b/fsl_mrs/tests/test_scripts_preproc.py @@ -97,16 +97,14 @@ def test_noalign(tmp_path): '--ecc', ecc, '--noalign', '--overwrite', - '--report', '--verbose']) assert retcode == 0 - assert (tmp_path / 'mergedReports.html').exists() assert (tmp_path / 'metab.nii.gz').exists() - assert (tmp_path / 'wref.nii.gz').exists() proc_nii = mrs_io.read_FID(tmp_path / 'metab.nii.gz') assert proc_nii.shape == (1, 1, 1, 4096) + assert all(['.align' not in step['Details'] for step in proc_nii.hdr_ext['ProcessingApplied']]) def test_window_align_preproc(tmp_path): diff --git a/fsl_mrs/tests/test_scripts_preproc_edit.py b/fsl_mrs/tests/test_scripts_preproc_edit.py index 225a9e10f1533ffe2f3851eb9f314ef949d5864a..6ca42fc893bc3683439dcf9d66e6d767c8c76a81 100644 --- a/fsl_mrs/tests/test_scripts_preproc_edit.py +++ b/fsl_mrs/tests/test_scripts_preproc_edit.py @@ -241,8 +241,7 @@ def test_noalign(tmp_path): '--verbose']) assert retcode == 0 - assert (tmp_path / 'diff.nii.gz').exists() assert (tmp_path / 'edit_0.nii.gz').exists() - assert (tmp_path / 'edit_1.nii.gz').exists() - assert (tmp_path / 'wref.nii.gz').exists() - assert (tmp_path / 'options.txt').exists() + + proc_nii = mrs_io.read_FID(tmp_path / 'edit_0.nii.gz') + assert all(['.align, dim=DIM_DYN' not in step['Details'] for step in proc_nii.hdr_ext['ProcessingApplied']]) diff --git a/requirements.txt b/requirements.txt index 4c472d4715ae26240cb56d8ce429259d8f270a17..a68e49cc7caa11c4b62e265b30dbbc20423034ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ pandas jinja2 beautifulsoup4 nibabel>=5.3 -hlsvdpropy +hlsvdpropy>=2.0.2 fslpy>=3.9.0 pillow spec2nii>=0.8.5