File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1032,8 +1032,9 @@ def _find_subj_ses(f_name):
1032
1032
# we will allow the match at either directories or within filename
1033
1033
# assuming that bids layout is "correct"
1034
1034
regex = re .compile ('sub-(?P<subj>[a-zA-Z0-9]*)([/_]ses-(?P<ses>[a-zA-Z0-9]*))?' )
1035
- res = regex .search (f_name ).groupdict ()
1036
- return res .get ('subj' ), res .get ('ses' , None )
1035
+ regex_res = regex .search (f_name )
1036
+ res = regex_res .groupdict () if regex_res else {}
1037
+ return res .get ('subj' , None ), res .get ('ses' , None )
1037
1038
1038
1039
1039
1040
def save_scans_key (item , bids_files ):
@@ -1060,6 +1061,13 @@ def save_scans_key(item, bids_files):
1060
1061
f_name = f_name .replace ('json' , 'nii.gz' )
1061
1062
rows [f_name ] = get_formatted_scans_key_row (item )
1062
1063
subj_ , ses_ = _find_subj_ses (f_name )
1064
+ if not subj_ :
1065
+ lgr .warning (
1066
+ "Failed to detect fullfilled BIDS layout. "
1067
+ "No scans.tsv file(s) will be produced for %s" ,
1068
+ ", " .join (bids_files )
1069
+ )
1070
+ return
1063
1071
if subj and subj_ != subj :
1064
1072
raise ValueError (
1065
1073
"We found before subject %s but now deduced %s from %s"
You can’t perform that action at this time.
0 commit comments