Skip to content

Commit

Permalink
BF: ReproIn - Support pipolar fieldmaps by providing them with _epi n…
Browse files Browse the repository at this point in the history
…ot _magnitude suffix

There is also internal small ReproIn RF to minimize code duplication for common
functionality.

This change might result in slightly different naming due to now enforced order
of _dir- to come before the leftover BIDS suffixes.  So if previosly there were
some other BIDS _key-value pairs which we did not treat in ReproIn, and they
were listed BEFORE _dir- - they might now be added AFTER it.  Some subsequent
PR should probably add treatment for other BIDS _key"s (e.g. _ce) and place them
in the order listed within BIDS specification
  • Loading branch information
yarikoptic committed Jul 3, 2019
1 parent 5357359 commit 290e7f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
22 changes: 18 additions & 4 deletions heudiconv/heuristics/reproin.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,10 @@ def infotodict(seqinfo):
if not dcm_image_iod_spec:
raise ValueError("Do not know image data type yet to make decision")
seqtype_label = {
'M': 'magnitude', # might want explicit {file_index} ?
# might want explicit {file_index} ?
# _epi for pipolar fieldmaps, see
# https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#case-4-multiple-phase-encoded-directions-pepolar
'M': 'epi' if 'dir' in series_info else 'magnitude',
'P': 'phasediff',
'DIFFUSION': 'epi', # according to KODI those DWI are the EPIs we need
}[dcm_image_iod_spec]
Expand Down Expand Up @@ -610,12 +613,23 @@ def infotodict(seqinfo):
if s.is_motion_corrected and 'rec-' in series_info.get('bids', ''):
raise NotImplementedError("want to add _acq-moco but there is _acq- already")

def from_series_info(name):
"""A little helper to provide _name-value if series_info knows it
Returns None otherwise
"""
if series_info.get(name):
return "%s-%s" % (name, series_info[name])
else:
return None

suffix_parts = [
None if not series_info.get('task') else "task-%s" % series_info['task'],
None if not series_info.get('acq') else "acq-%s" % series_info['acq'],
from_series_info('task'),
from_series_info('acq'),
# But we want to add an indicator in case it was motion corrected
# in the magnet. ref sample /2017/01/03/qa
None if not s.is_motion_corrected else 'rec-moco',
from_series_info('dir'),
series_info.get('bids'),
run_label,
seqtype_label,
Expand Down Expand Up @@ -903,7 +917,7 @@ def split2(s):
.replace('_', 'X').replace('-', 'X') \
.replace('(', '{').replace(')', '}') # for Philips

if key in ['ses', 'run', 'task', 'acq']:
if key in ['ses', 'run', 'task', 'acq', 'dir']:
# those we care about explicitly
regd[{'ses': 'session'}.get(key, key)] = sanitize_str(value)
else:
Expand Down
5 changes: 4 additions & 1 deletion heudiconv/heuristics/test_reproin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,7 @@ def test_parse_series_spec():
# from (date) since Philips does not allow for {}
assert pdpn("func_ses-{date}") == \
pdpn("func_ses-(date)") == \
{'seqtype': 'func', 'session': '{date}'}
{'seqtype': 'func', 'session': '{date}'}

assert pdpn("fmap_dir-AP_ses-01") == \
{'seqtype': 'fmap', 'session': '01', 'dir': 'AP'}

0 comments on commit 290e7f5

Please sign in to comment.