diff --git a/CHANGELOG.md b/CHANGELOG.md index 35a2321..c9993f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ This document contains the Spec2nii release history in reverse chronological ord 0.7.4 (WIP) --------------------------------- -- Refinements and improvements to the GE SVS pipeline from Mark Mikkelsen +- 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. 0.7.3 (Tuesday 12th March 2024) ------------------------------- diff --git a/spec2nii/jmrui.py b/spec2nii/jmrui.py index 498d6fe..cf683c3 100644 --- a/spec2nii/jmrui.py +++ b/spec2nii/jmrui.py @@ -246,7 +246,7 @@ def readjMRUItxt(filename): Header information """ - signalRe = re.compile(r'Signal (\d{1,}) out of (\d{1,}) in file') + signalRe = re.compile(r'Signal (?:number: |)(\d{1,}) out of (\d{1,}) in file') headerRe = re.compile(r'(\w*):(.*)') header = {} data = [] diff --git a/tests/spec2nii_test_data b/tests/spec2nii_test_data index 2181603..12973b9 160000 --- a/tests/spec2nii_test_data +++ b/tests/spec2nii_test_data @@ -1 +1 @@ -Subproject commit 2181603035ef4647a338ad4950a21aaaa7c9929c +Subproject commit 12973b964ce06faf4f1a1df1a522d87e2a407067 diff --git a/tests/test_jmrui.py b/tests/test_jmrui.py index aa19fd9..6bdb023 100644 --- a/tests/test_jmrui.py +++ b/tests/test_jmrui.py @@ -16,7 +16,8 @@ testdata = {'fida_single': file_path / 'spec2nii_test_data/jmrui/metab_jmrui.txt', 'txt_multi': file_path / 'spec2nii_test_data/jmrui/basis_woTMS.txt', 'mrui_single': file_path / 'spec2nii_test_data/jmrui/press2.mrui', - 'mrui_multi': file_path / 'spec2nii_test_data/jmrui/ALLSIG.mrui'} + 'mrui_multi': file_path / 'spec2nii_test_data/jmrui/ALLSIG.mrui', + 'txt_old': file_path / 'spec2nii_test_data/jmrui/P31rest_proc_jmrui.txt'} @pytest.fixture @@ -106,3 +107,22 @@ def test_jmrui_multi_mrui(affine_file, tmp_path): assert converted.shape == (1, 1, 1, 2048, 28) assert np.iscomplexobj(converted.dataobj) assert np.allclose(np.loadtxt(affine_file), converted.affine) + + +def test_jmrui_old(affine_file, tmp_path): + """Test the 'jmrui' txt old format with different # signal syntax. + Namely, 'Signal number: ' rather than 'Signal') + """ + # Run spec2nii on text + subprocess.call(['spec2nii', 'jmrui', + '-f', 'txt_old', + '-o', str(tmp_path), + '-a', affine_file, + '-j', testdata['txt_old']]) + + # Load the new nifti file + converted = nib.load(tmp_path / 'txt_old.nii.gz') + + assert converted.shape == (1, 1, 1, 2048) + assert np.iscomplexobj(converted.dataobj) + assert np.allclose(np.loadtxt(affine_file), converted.affine)