File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 8282 default_metadata_json = helper_functions .check_pet2bids_config (
8383 "DEFAULT_METADATA_JSON"
8484 )
85- if default_metadata_json and Path (default_metadata_json ).exists ():
85+ if default_metadata_json and Path (str ( default_metadata_json ) ).exists ():
8686 # do nothing
8787 pass
88- else :
88+ elif default_metadata_json and not Path (str (default_metadata_json )).exists ():
89+ # Copy template to the specified path
8990 try :
91+ # Ensure the parent directory exists before copying
92+ Path (default_metadata_json ).parent .mkdir (parents = True , exist_ok = True )
9093 shutil .copy (
9194 Path (metadata_folder ) / "template_json.json" , default_metadata_json
9295 )
9396 except FileNotFoundError :
97+ # Fallback to module folder template
98+ Path (default_metadata_json ).parent .mkdir (parents = True , exist_ok = True )
9499 shutil .copy (module_folder / "template_json.json" , default_metadata_json )
100+ else :
101+ # No DEFAULT_METADATA_JSON set in config, do nothing
102+ pass
95103else :
96104 # if it doesn't exist use the default one included in this library
97105 helper_functions .modify_config_file (
Original file line number Diff line number Diff line change @@ -523,11 +523,11 @@ def show_sidecar(self, output_path=None):
523523 )
524524 else :
525525 collection_of_fields [field ] = self .sidecar_template .get (field )
526-
527- if helper_functions .collect_bids_part ("ses" , self .output_path ) != "" :
528- collection_of_fields ["ses" ] = helper_functions .collect_bids_part (
529- "ses" , self .output_path
530- )
526+ if self . output_path :
527+ if helper_functions .collect_bids_part ("ses" , self .output_path ) != "" :
528+ collection_of_fields ["ses" ] = helper_functions .collect_bids_part (
529+ "ses" , self .output_path
530+ )
531531
532532 if self .ezbids :
533533 hash_string = helper_functions .hash_fields (** collection_of_fields )
Original file line number Diff line number Diff line change @@ -282,7 +282,7 @@ def main():
282282 os .environ ["PET2BIDS_TELEMETRY_ENABLED" ] = "False"
283283
284284 collect_pixel_data = False
285- if cli_args .convert or cli_args .update :
285+ if cli_args .convert or cli_args .update or cli_args . sidecar :
286286 collect_pixel_data = True
287287 if cli_args .scannerparams is not None :
288288 # if no args are supplied to --scannerparams/-s
You can’t perform that action at this time.
0 commit comments