Skip to content

Commit bb86e28

Browse files
author
DBIC BIDS Team
committed
ENH: allow to override a subject id if a single sequence dicoms provided
1 parent 8a1a024 commit bb86e28

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

bin/heudiconv

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,6 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
15331533
else:
15341534
# prep files
15351535
assert files_opt
1536-
assert not sids
15371536
files = []
15381537
for f in files_opt:
15391538
if isdir(f):
@@ -1559,6 +1558,17 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
15591558
raise NotImplementedError(
15601559
"For now, if no subj template is provided, requiring "
15611560
"heuristic to have infotoids")
1561+
1562+
if sids:
1563+
if not (len(sids) == 1 and len(seqinfo_dict) == 1):
1564+
raise RuntimeError(
1565+
"We were provided some subjects (%s) but we can deal only "
1566+
"with overriding only 1 subject id. Got %d subjects and "
1567+
"found %d sequences" % (sids, len(sids), len(seqinfo_dict))
1568+
)
1569+
sid = sids[0]
1570+
else:
1571+
sid = None
15621572

15631573
for studyUID, seqinfo in seqinfo_dict.items():
15641574
# so we have a single study, we need to figure out its
@@ -1575,7 +1585,8 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
15751585
study_session_info = StudySessionInfo(
15761586
ids.get('locator'),
15771587
ids.get('session', session) or session,
1578-
ids.get('subject', None))
1588+
sid or ids.get('subject', None)
1589+
)
15791590
if study_session_info in study_sessions:
15801591
#raise ValueError(
15811592
lgr.warning(

0 commit comments

Comments
 (0)