Skip to content

Commit 4e16f10

Browse files
committed
ENH: strip a possible leading PREFIX:
see ReproNim/reproin#14
1 parent 2815f07 commit 4e16f10

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

heudiconv/heuristics/reproin.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
Sequence names on the scanner must follow this specification to avoid manual
2929
conversion/handling:
3030
31-
<seqtype[-label]>[_ses-<SESID>][_task-<TASKID>][_acq-<ACQLABEL>][_run-<RUNID>][_dir-<DIR>][<more BIDS>][__<custom>]
31+
[PREFIX:]<seqtype[-label]>[_ses-<SESID>][_task-<TASKID>][_acq-<ACQLABEL>][_run-<RUNID>][_dir-<DIR>][<more BIDS>][__<custom>]
3232
3333
where
34+
[PREFIX:] - leading capital letters followed by : are stripped/ignored
3435
<...> - value to be entered
3536
[...] - optional -- might be nearly mandatory for some modalities (e.g.,
3637
run for functional) and very optional for others
@@ -783,9 +784,14 @@ def parse_series_spec(series_spec):
783784
series_spec = series_spec.replace("anat_T1w", "anat-T1w")
784785
series_spec = series_spec.replace("hardi_64", "dwi_acq-hardi64")
785786
series_spec = series_spec.replace("AAHead_Scout", "anat-scout")
786-
787-
# Parse the name according to our convention
788-
# https://docs.google.com/document/d/1R54cgOe481oygYVZxI7NHrifDyFUZAjOBwCTu7M7y48/edit?usp=sharing
787+
788+
# Parse the name according to our convention/specification
789+
790+
# Strip off leading CAPITALS: prefix to accommodate some reported usecases:
791+
# https://github.com/ReproNim/reproin/issues/14
792+
# where PU: prefix is added by the scanner
793+
series_spec = re.sub("^[A-Z]*:", "", series_spec)
794+
789795
# Remove possible suffix we don't care about after __
790796
series_spec = series_spec.split('__', 1)[0]
791797

@@ -982,15 +988,18 @@ def test_parse_series_spec():
982988
{'seqtype': 'func', 'seqtype_label': 'bold'}
983989

984990
# pdpn("bids_func_ses+_task-boo_run+") == \
985-
# order should not matter
986-
assert pdpn("bids_func_ses+_run+_task-boo") == \
991+
# order and PREFIX: should not matter
992+
assert \
993+
pdpn("PREFIX:bids_func_ses+_task-boo_run+") == \
994+
pdpn("bids_func_ses+_run+_task-boo") == \
987995
{
988996
'seqtype': 'func',
989997
# 'seqtype_label': 'bold',
990998
'session': '+',
991999
'run': '+',
9921000
'task': 'boo',
9931001
}
1002+
9941003
# TODO: fix for that
9951004
assert pdpn("bids_func-pace_ses-1_task-boo_acq-bu_bids-please_run-2__therest") == \
9961005
pdpn("bids_func-pace_ses-1_run-2_task-boo_acq-bu_bids-please__therest") == \

0 commit comments

Comments
 (0)