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