From 39dfd5b2b991dfa0806b7a6aac6f86744e0a4cc5 Mon Sep 17 00:00:00 2001 From: bpinsard Date: Thu, 30 May 2024 15:38:37 -0400 Subject: [PATCH] more fixes, works on example GE data, require dcm2niix patch --- heudiconv/convert.py | 17 ++++++++++++----- heudiconv/dicoms.py | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/heudiconv/convert.py b/heudiconv/convert.py index 9bc6e0b7..b48e26fa 100644 --- a/heudiconv/convert.py +++ b/heudiconv/convert.py @@ -332,9 +332,9 @@ def update_complex_name(metadata: dict[str, Any], filename: str) -> str: # Check to see if it is magnitude or phase part: img_type = cast(List[str], metadata.get("ImageType", [])) - if "M" in img_type: + if "M" in img_type or "MAGNITUDE" in img_type: part = "mag" - elif "P" in img_type: + elif "P" in img_type or "PHASE" in img_type: part = "phase" elif "REAL" in img_type: part = "real" @@ -980,9 +980,16 @@ def save_converted_files( len(set(filter(bool, channel_names))) > 1 ) # Check for uncombined data CPLX_PARTS = ["MAGNITUDE", "PHASE", "IMAGINARY", "REAL"] - is_complex = len(set([ - it for its in image_types for part in CPLX_PARTS if 'part' - ])) # Determine if data are complex (magnitude + phase or real + imag or all-4) + is_complex = len( + set( + [ + part + for its in image_types + for part in CPLX_PARTS + if part in its or part[0] in its + ] + ) + ) # Determine if data are complex (magnitude + phase or real + imag or all-4) echo_times_lst = sorted(echo_times) # also converts to list channel_names_lst = sorted(channel_names) # also converts to list diff --git a/heudiconv/dicoms.py b/heudiconv/dicoms.py index 627fd92f..824455d1 100644 --- a/heudiconv/dicoms.py +++ b/heudiconv/dicoms.py @@ -100,7 +100,7 @@ def create_seqinfo( # GE data # see https://github.com/rordenlab/dcm2niix/tree/master/GE#complex-image-component if dcminfo.get([0x43, 0x102F]): - GE_CPLX_CODING = ["PHASE", "MAGNITUDE", "REAL", "IMAGINARY"] + GE_CPLX_CODING = ["MAGNITUDE", "PHASE", "REAL", "IMAGINARY"] cplx_idx = int(dcminfo.get([0x43, 0x102F]).value) part = GE_CPLX_CODING[cplx_idx] if part not in image_type: