From 9825d92027f10414596f177e74d0a59d01c36509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stadler?= Date: Tue, 14 May 2019 10:30:28 +0200 Subject: [PATCH 1/4] fix for Philips --- heudiconv/heuristics/reproin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/heudiconv/heuristics/reproin.py b/heudiconv/heuristics/reproin.py index 7de451de..26388f37 100644 --- a/heudiconv/heuristics/reproin.py +++ b/heudiconv/heuristics/reproin.py @@ -426,16 +426,15 @@ def ls(study_session, seqinfo): # So we just need subdir and file_suffix! def infotodict(seqinfo): """Heuristic evaluator for determining which runs belong where - - allowed template fields - follow python string module: - + + allowed template fields - follow python string module: + item: index within category subject: participant id seqitem: run number during scanning subindex: sub index within group session: scan index for longitudinal acq """ - seqinfo = fix_seqinfo(seqinfo) lgr.info("Processing %d seqinfo entries", len(seqinfo)) and_dicom = ('dicom', 'nii.gz') @@ -841,6 +840,7 @@ def parse_series_spec(series_spec): # https://github.com/ReproNim/reproin/issues/14 # where PU: prefix is added by the scanner series_spec = re.sub("^[A-Z]*:", "", series_spec) + series_spec = re.sub("^WIP ", "", series_spec) # remove Philips WIP prefix # Remove possible suffix we don't care about after __ series_spec = series_spec.split('__', 1)[0] @@ -889,6 +889,7 @@ def split2(s): # sanitize values, which must not have _ and - is undesirable ATM as well # TODO: BIDSv2.0 -- allows "-" so replace with it instead value = str(value).replace('_', 'X').replace('-', 'X') + value = str(value).replace('(', '{').replace(')', '}') # for Philips if key in ['ses', 'run', 'task', 'acq']: # those we care about explicitly From 4c36fb4c8a0ca099234934c755fe3c242610a677 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 14 May 2019 12:44:11 -0400 Subject: [PATCH 2/4] ENH(TST): basic testing for WIP stripping and (date)->{date} tune up --- heudiconv/heuristics/test_reproin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/heudiconv/heuristics/test_reproin.py b/heudiconv/heuristics/test_reproin.py index 2517b29f..0a63dc1d 100644 --- a/heudiconv/heuristics/test_reproin.py +++ b/heudiconv/heuristics/test_reproin.py @@ -166,6 +166,7 @@ def test_parse_series_spec(): assert \ pdpn(" PREFIX:bids_func_ses+_task-boo_run+ ") == \ pdpn("PREFIX:bids_func_ses+_task-boo_run+") == \ + pdpn("WIP func_ses+_task-boo_run+") == \ pdpn("bids_func_ses+_run+_task-boo") == \ { 'seqtype': 'func', @@ -202,3 +203,9 @@ def test_parse_series_spec(): 'acq': 'MPRAGE', 'seqtype_label': 'T1w' } + + # Check for currently used {date}, which should also should get adjusted + # from (date) since Philips does not allow for {} + assert pdpn("func_ses-{date}") == \ + pdpn("func_ses-(date)") == \ + {'seqtype': 'func', 'session': '{date}'} \ No newline at end of file From 97304860df3a45504fd5038b8fd5b9cadfc75928 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 14 May 2019 12:45:00 -0400 Subject: [PATCH 3/4] ENH: just do all replacements in "one" line and avoid unneeded 2nd str() --- heudiconv/heuristics/reproin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heudiconv/heuristics/reproin.py b/heudiconv/heuristics/reproin.py index 26388f37..262388ef 100644 --- a/heudiconv/heuristics/reproin.py +++ b/heudiconv/heuristics/reproin.py @@ -888,8 +888,9 @@ def split2(s): # sanitize values, which must not have _ and - is undesirable ATM as well # TODO: BIDSv2.0 -- allows "-" so replace with it instead - value = str(value).replace('_', 'X').replace('-', 'X') - value = str(value).replace('(', '{').replace(')', '}') # for Philips + value = str(value) \ + .replace('_', 'X').replace('-', 'X') \ + .replace('(', '{').replace(')', '}') # for Philips if key in ['ses', 'run', 'task', 'acq']: # those we care about explicitly From 9196e8943f6284f2a4faba46753bee3b5b4e434d Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 15 May 2019 12:13:55 -0400 Subject: [PATCH 4/4] ENH(DOC): adjust docstring to describe Philips tuneups --- heudiconv/heuristics/reproin.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/heudiconv/heuristics/reproin.py b/heudiconv/heuristics/reproin.py index 262388ef..4829941f 100644 --- a/heudiconv/heuristics/reproin.py +++ b/heudiconv/heuristics/reproin.py @@ -28,10 +28,11 @@ Sequence names on the scanner must follow this specification to avoid manual conversion/handling: - [PREFIX:][_ses-][_task-][_acq-][_run-][_dir-][][__] + [PREFIX:][WIP ][_ses-][_task-][_acq-][_run-][_dir-][][__] where [PREFIX:] - leading capital letters followed by : are stripped/ignored + [WIP ] - prefix is stripped/ignored (added by Philips for patch sequences) <...> - value to be entered [...] - optional -- might be nearly mandatory for some modalities (e.g., run for functional) and very optional for others @@ -104,6 +105,16 @@ Although we still support "-" and "+" used within SESID and TASKID, their use is not recommended, thus not listed here + +## Scanner specifics + +We perform following actions regardless of the type of scanner, but applied +generally to accommodate limitations imposed by different manufacturers/models: + +### Philips + +- We replace all ( with { and ) with } to be able e.g. to specify session {date} +- "WIP " prefix unconditionally added by the scanner is stripped """ import os