diff --git a/CHANGELOG.md b/CHANGELOG.md index d90c9c3..cb42cea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ This document contains the Spec2nii release history in reverse chronological order. -0.6.2 (Saturday 4th February 2023) +0.6.2 (Sunday 5th February 2023) ---------------------------------- - Handle HYPER references in SPAR/SDAT pipeline - Handle HURCULES/HERMES (smm_svs_herc) sequence in XA twix format. +- Changed behaviour of Siemens DICOM `spec2nii dicom` to recursively glob directory argument. +- Better error output when encountering MR Image SOPClassUID. 0.6.1 (Wednesday 18th January 2023) ----------------------------------- diff --git a/spec2nii/Siemens/dicomfunctions.py b/spec2nii/Siemens/dicomfunctions.py index 3f4129d..ce0b7fa 100644 --- a/spec2nii/Siemens/dicomfunctions.py +++ b/spec2nii/Siemens/dicomfunctions.py @@ -45,11 +45,19 @@ def xa_or_vx(img): elif img.dcm_data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.4.2': return 'xa' else: - raise IncompatibleSOPClassUID( - 'spec2nii does not recognise this SOPClassUID ' - f'{img.dcm_data.SOPClassUID}. This data was collected on a' - f' {img.dcm_data.SoftwareVersions} baseline scanner.' - ' spec2nii is tested on VA-VE, and XA20 and XA30 DICOM files.') + if img.dcm_data.SOPClassUID == '1.2.840.10008.5.1.4.1.1.4': + raise IncompatibleSOPClassUID( + f'spec2nii detected SOPClassUID {img.dcm_data.SOPClassUID}.' + ' This normaly contains MR imaging (not spectroscopy) data.' + ' This data was collected on a' + f' {img.dcm_data.SoftwareVersions} baseline scanner.' + ' spec2nii is tested on VA-VE, XA20, and XA30 DICOM files.') + else: + raise IncompatibleSOPClassUID( + 'spec2nii does not recognise this SOPClassUID ' + f'{img.dcm_data.SOPClassUID} as MRS data. This data was collected on a' + f' {img.dcm_data.SoftwareVersions} baseline scanner.' + ' spec2nii is tested on VA-VE, XA20, and XA30 DICOM files.') def svs_or_CSI(img): @@ -89,7 +97,16 @@ def multi_file_dicom(files_in, fname_out, tag, verbose): img = nibabel.nicom.dicomwrappers.wrapper_from_file(fn) - mrs_type = svs_or_CSI(img) + try: + mrs_type = svs_or_CSI(img) + except IncompatibleSOPClassUID as exc: + if len(files_in) == 1: + raise exc + else: + print(f'Skipping {fn}.') + print('Raised IncompatibleSOPClassUID error. Moving to next file.') + print(f'Message: {str(exc)}\n') + continue if mrs_type == 'SVS': specDataCmplx, orientation, dwelltime, meta_obj = process_siemens_svs(img, verbose=verbose) diff --git a/spec2nii/spec2nii.py b/spec2nii/spec2nii.py index dae8a7a..26dad77 100644 --- a/spec2nii/spec2nii.py +++ b/spec2nii/spec2nii.py @@ -415,9 +415,9 @@ def dicom(self, args): path_in = Path(args.file) if path_in.is_dir(): # Look for typical dicom file extensions - files_in = sorted(path_in.glob('*.IMA')) + \ - sorted(path_in.glob('*.ima')) + \ - sorted(path_in.glob('*.dcm')) + files_in = sorted(path_in.rglob('*.IMA')) + \ + sorted(path_in.rglob('*.ima')) + \ + sorted(path_in.rglob('*.dcm')) # If none found look for all files if len(files_in) == 0: