Skip to content

Commit

Permalink
add complex part to ImageType for use in heuristics, it is done in dc…
Browse files Browse the repository at this point in the history
…m2niix when converting
  • Loading branch information
bpinsard committed May 30, 2024
1 parent ba524c1 commit 5c692c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions heudiconv/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,10 @@ def save_converted_files(
is_uncombined = (
len(set(filter(bool, channel_names))) > 1
) # Check for uncombined data
PARTS = ["M", "P", "IMAGINARY", "REAL"]
is_complex = (
len(set(filter(lambda x: [part in x for part in PARTS], image_types))) > 1
) # Determine if data are complex (magnitude + phase)
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)
echo_times_lst = sorted(echo_times) # also converts to list
channel_names_lst = sorted(channel_names) # also converts to list

Expand Down
9 changes: 9 additions & 0 deletions heudiconv/dicoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ def create_seqinfo(
else:
sequence_name = ""

# 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"]
cplx_idx = int(dcminfo.get([0x43, 0x102F]).value)
part = GE_CPLX_CODING[cplx_idx]
if part not in image_type:
image_type = image_type + (part,)

# initialized in `group_dicoms_to_seqinfos`
global total_files
total_files += len(series_files)
Expand Down

0 comments on commit 5c692c0

Please sign in to comment.