From d72ba98a328e92d6ef8a2fab5f0b5eeb40486413 Mon Sep 17 00:00:00 2001 From: Vasilis Karlaftis Date: Wed, 20 May 2026 11:00:54 +0100 Subject: [PATCH] updated clean command to match nifti-mrs 1.4.1 release --- CHANGELOG.md | 3 ++- pyproject.toml | 2 +- spec2nii/other.py | 2 +- tests/test_other_func.py | 6 ++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8962f1..4d6e9d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ This document contains the Spec2nii release history in reverse chronological order. -0.8.12 (WIP) +0.8.12 (Wednesday 20th May 2026) ------------ - Handle DICOMs missing series and instance numbers (generated through Siemens retrorecon). - Special case handling of ViennaCrt sequence for VE DICOM. +- Bumped dependency to nifti-mrs 1.4.1 0.8.11 (Monday 20th April 2026) ---------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 6f6b443..a3c6e85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "scipy>=1.13", "brukerapi>=0.1.8,<0.1.9", "pandas", - "nifti-mrs>=1.3.2", + "nifti-mrs>=1.4.1", "chardet" ] diff --git a/spec2nii/other.py b/spec2nii/other.py index 1a7a978..4a83a3b 100644 --- a/spec2nii/other.py +++ b/spec2nii/other.py @@ -107,7 +107,7 @@ def clean_hdr_ext(args): nifti_mrs_img = NIFTI_MRS(args.file, validate_on_creation=False) print("'intent_name' is valid.") except NotNIFTI_MRS as exc: - if str(exc) != 'NIFTI-MRS intent code not set.': + if 'NIFTI-MRS intent code not valid' not in str(exc): raise # if failed, read as a regular NIfTI, update intent and re-save from fsl.data.image import Image diff --git a/tests/test_other_func.py b/tests/test_other_func.py index 0a993d7..7197b5b 100644 --- a/tests/test_other_func.py +++ b/tests/test_other_func.py @@ -226,6 +226,8 @@ def test_clean_intent(tmp_path): nib.save(img, tmp_path / 'invalid1.nii.gz') img.header['intent_name'] = None nib.save(img, tmp_path / 'invalid2.nii.gz') + img.header['intent_name'] = 'test_v2_1'.encode() + nib.save(img, tmp_path / 'invalid3.nii.gz') # Create reference intent_name data_text = files('nifti_mrs.standard').joinpath('definitions.json').read_text(encoding='utf-8') @@ -235,8 +237,8 @@ def test_clean_intent(tmp_path): intent_name = f'mrs_v{v_major}_{v_minor}'.encode() # Test clean call on this file - for file, intent in zip(['valid', 'invalid1', 'invalid2'], - ['mrs_v2_1'.encode(), intent_name, intent_name]): + for file, intent in zip(['valid', 'invalid1', 'invalid2', 'invalid3'], + ['mrs_v2_1'.encode(), intent_name, intent_name, intent_name]): subprocess.check_call(['spec2nii', 'clean', '-o', tmp_path, '-f', 'cleaned',