Skip to content

Commit 4b82ec2

Browse files
authored
Merge pull request #358 from dartmouth-pbs/bf-se-fmap
BF: ReproIn - Support pipolar fieldmaps by providing them with _epi not _magnitude
2 parents a3e92ae + 290e7f5 commit 4b82ec2

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

heudiconv/heuristics/reproin.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ def infotodict(seqinfo):
551551
if not dcm_image_iod_spec:
552552
raise ValueError("Do not know image data type yet to make decision")
553553
seqtype_label = {
554-
'M': 'magnitude', # might want explicit {file_index} ?
554+
# might want explicit {file_index} ?
555+
# _epi for pipolar fieldmaps, see
556+
# https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-4-multiple-phase-encoded-directions-pepolar
557+
'M': 'epi' if 'dir' in series_info else 'magnitude',
555558
'P': 'phasediff',
556559
'DIFFUSION': 'epi', # according to KODI those DWI are the EPIs we need
557560
}[dcm_image_iod_spec]
@@ -610,12 +613,23 @@ def infotodict(seqinfo):
610613
if s.is_motion_corrected and 'rec-' in series_info.get('bids', ''):
611614
raise NotImplementedError("want to add _acq-moco but there is _acq- already")
612615

616+
def from_series_info(name):
617+
"""A little helper to provide _name-value if series_info knows it
618+
619+
Returns None otherwise
620+
"""
621+
if series_info.get(name):
622+
return "%s-%s" % (name, series_info[name])
623+
else:
624+
return None
625+
613626
suffix_parts = [
614-
None if not series_info.get('task') else "task-%s" % series_info['task'],
615-
None if not series_info.get('acq') else "acq-%s" % series_info['acq'],
627+
from_series_info('task'),
628+
from_series_info('acq'),
616629
# But we want to add an indicator in case it was motion corrected
617630
# in the magnet. ref sample /2017/01/03/qa
618631
None if not s.is_motion_corrected else 'rec-moco',
632+
from_series_info('dir'),
619633
series_info.get('bids'),
620634
run_label,
621635
seqtype_label,
@@ -903,7 +917,7 @@ def split2(s):
903917
.replace('_', 'X').replace('-', 'X') \
904918
.replace('(', '{').replace(')', '}') # for Philips
905919

906-
if key in ['ses', 'run', 'task', 'acq']:
920+
if key in ['ses', 'run', 'task', 'acq', 'dir']:
907921
# those we care about explicitly
908922
regd[{'ses': 'session'}.get(key, key)] = sanitize_str(value)
909923
else:

heudiconv/heuristics/test_reproin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,7 @@ def test_parse_series_spec():
208208
# from (date) since Philips does not allow for {}
209209
assert pdpn("func_ses-{date}") == \
210210
pdpn("func_ses-(date)") == \
211-
{'seqtype': 'func', 'session': '{date}'}
211+
{'seqtype': 'func', 'session': '{date}'}
212+
213+
assert pdpn("fmap_dir-AP_ses-01") == \
214+
{'seqtype': 'fmap', 'session': '01', 'dir': 'AP'}

0 commit comments

Comments
 (0)