@@ -275,37 +275,34 @@ def validate(
275275 # concatenate the parsed data and exit
276276 if len (parsed ) < 1 :
277277 logger .info ("No issues/warnings parsed, your dataset is BIDS valid." )
278- return
279-
278+ # Create empty parsed DataFrame to ensure output files are written
279+ parsed = pd . DataFrame ()
280280 else :
281281 parsed = pd .concat (parsed , axis = 0 , ignore_index = True )
282282 subset = parsed .columns .difference (["subject" ])
283283 parsed = parsed .drop_duplicates (subset = subset )
284-
285284 logger .info ("BIDS issues/warnings found in the dataset" )
286285
287- if output_prefix :
288- # normally, write dataframe to file in CLI
289- if abs_path_output :
290- val_tsv = str (output_prefix ) + "_validation.tsv"
291- else :
292- val_tsv = (
293- str (bids_dir ) + "/code/CuBIDS/" + str (output_prefix ) + "_validation.tsv"
294- )
286+ if output_prefix :
287+ # normally, write dataframe to file in CLI
288+ if abs_path_output :
289+ val_tsv = str (output_prefix ) + "_validation.tsv"
290+ else :
291+ val_tsv = str (bids_dir ) + "/code/CuBIDS/" + str (output_prefix ) + "_validation.tsv"
295292
296- parsed .to_csv (val_tsv , sep = "\t " , index = False )
293+ parsed .to_csv (val_tsv , sep = "\t " , index = False )
297294
298- # build validation data dictionary json sidecar
299- val_dict = get_val_dictionary ()
300- val_json = val_tsv .replace ("tsv" , "json" )
301- with open (val_json , "w" ) as outfile :
302- json .dump (val_dict , outfile , indent = 4 )
295+ # build validation data dictionary json sidecar
296+ val_dict = get_val_dictionary ()
297+ val_json = val_tsv .replace ("tsv" , "json" )
298+ with open (val_json , "w" ) as outfile :
299+ json .dump (val_dict , outfile , indent = 4 )
303300
304- logger .info ("Writing issues out to file %s" , val_tsv )
305- return
306- else :
307- # user may be in python session, return dataframe
308- return parsed
301+ logger .info ("Writing issues out to file %s" , val_tsv )
302+ return
303+ else :
304+ # user may be in python session, return dataframe
305+ return parsed
309306
310307
311308def bids_version (bids_dir , write = False , schema = None ):
0 commit comments