Skip to content

Commit

Permalink
more fixes, works on example GE data, require dcm2niix patch
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinsard committed May 30, 2024
1 parent 5c692c0 commit 39dfd5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions heudiconv/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Check warning on line 340 in heudiconv/convert.py

View check run for this annotation

Codecov / codecov/patch

heudiconv/convert.py#L340

Added line #L340 was not covered by tests
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion heudiconv/dicoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 39dfd5b

Please sign in to comment.