From 3354ce198cf53f827a1d7e023bd9770a24ec845c Mon Sep 17 00:00:00 2001 From: wtclarke Date: Thu, 12 Oct 2023 11:04:26 +0100 Subject: [PATCH] Add tests for rda with latin1 encoding. --- tests/spec2nii_test_data | 2 +- tests/test_siemens_rda.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/spec2nii_test_data b/tests/spec2nii_test_data index 6f205d3..e0ad587 160000 --- a/tests/spec2nii_test_data +++ b/tests/spec2nii_test_data @@ -1 +1 @@ -Subproject commit 6f205d389085a420b38689f573045166517bb445 +Subproject commit e0ad5870cd5891bbe3fdcf9415845cde1f194884 diff --git a/tests/test_siemens_rda.py b/tests/test_siemens_rda.py index aac48e4..b8f2be8 100644 --- a/tests/test_siemens_rda.py +++ b/tests/test_siemens_rda.py @@ -18,6 +18,8 @@ xa20_svs_path = siemens_path / 'XAData' / 'XA20/rda/spct_002.MR.MRI-LAB Test_Dir.5.1.114540.rda' xa31_locale_svs_path = siemens_path / 'XAData' / 'XA31/rda/locale_XA31.rda' +latin1_encoding = siemens_path / 'rda' / 'latin1.rda' + def test_xa20_svs(tmp_path): @@ -53,3 +55,21 @@ def test_xa31_locale_svs(tmp_path): assert img_t.shape == (1, 1, 1, 1024) assert np.iscomplexobj(img_t.dataobj) + + +def test_latin_encoding(tmp_path): + + subprocess.check_call(['spec2nii', 'rda', + '-f', 'rda_latin1', + '-o', tmp_path, + '-j', str(latin1_encoding)]) + + img_t = read_nifti_mrs(tmp_path / 'rda_latin1.nii.gz') + + hdr_ext_codes = img_t.header.extensions.get_codes() + hdr_ext = json.loads(img_t.header.extensions[hdr_ext_codes.index(44)].get_content()) + + hdr_ext['ResonantNucleus'] = ['1H', ] + + assert img_t.shape == (1, 1, 1, 2048) + assert np.iscomplexobj(img_t.dataobj)