Skip to content

Commit

Permalink
Merge pull request #121 from GalKepler/fmap_acq
Browse files Browse the repository at this point in the history
Dynamically detect the acquisition label of fieldmaps
  • Loading branch information
ZviBaratz committed Mar 15, 2023
2 parents 33bd294 + 501c084 commit 8f9224d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/dicom_parser/utils/bids/header_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ def find_phase_encoding(header: dict) -> str:
return pe
except (AttributeError, IndexError):
return


def detect_associated_target(header: dict) -> str:
"""
Detects the target associated with a given sequence.
Parameters
----------
header : dict
Dictionary containing DICOM's header.
Returns
-------
str
The target's name.
"""
description = header.get("SeriesDescription", "").lower()
if "spinechofieldmap" in description:
target = "rest"
elif "se_tfmri" in description:
target = "task"
return target
3 changes: 2 additions & 1 deletion src/dicom_parser/utils/bids/sequence_to_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
find_mprage_ce,
find_phase_encoding,
find_task_name,
detect_associated_target,
)

# Dictionaries (`Dict[str, Union[str, Callable]]``) associating MR sequences
Expand Down Expand Up @@ -34,7 +35,7 @@
FLAIR = {"data_type": "anat", "suffix": "FLAIR"}
FUNCTIONAL_FIELDMAP = {
"data_type": "fmap",
"acq": "func",
"acq": detect_associated_target,
"dir": find_phase_encoding,
"suffix": "epi",
}
Expand Down

0 comments on commit 8f9224d

Please sign in to comment.