@@ -1533,7 +1533,6 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
1533
1533
else :
1534
1534
# prep files
1535
1535
assert files_opt
1536
- assert not sids
1537
1536
files = []
1538
1537
for f in files_opt :
1539
1538
if isdir (f ):
@@ -1559,6 +1558,17 @@ def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
1559
1558
raise NotImplementedError (
1560
1559
"For now, if no subj template is provided, requiring "
1561
1560
"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
1562
1572
1563
1573
for studyUID , seqinfo in seqinfo_dict .items ():
1564
1574
# 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,
1575
1585
study_session_info = StudySessionInfo (
1576
1586
ids .get ('locator' ),
1577
1587
ids .get ('session' , session ) or session ,
1578
- ids .get ('subject' , None ))
1588
+ sid or ids .get ('subject' , None )
1589
+ )
1579
1590
if study_session_info in study_sessions :
1580
1591
#raise ValueError(
1581
1592
lgr .warning (
0 commit comments