Skip to content

Commit

Permalink
Add condition to check if JSON sidecar exists. If not, do not raise e…
Browse files Browse the repository at this point in the history
…rror, instead, print warning.
  • Loading branch information
valosekj committed May 13, 2023
1 parent 33457d3 commit b1cf43e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions copy_files_to_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ def main():
print(f'Copying: {path_file_in} to {path_file_out}')
path_file_json_in = path_file_in.replace('nii.gz', 'json')
path_file_json_out = path_file_out.replace('nii.gz', 'json')
shutil.copy(path_file_json_in, path_file_json_out)
print(f'Copying: {path_file_json_in} to {path_file_json_out}')
if os.path.isfile(path_file_json_in):
shutil.copy(path_file_json_in, path_file_json_out)
print(f'Copying: {path_file_json_in} to {path_file_json_out}')
else:
print(f'Warning: {path_file_json_in} does not exist.')


if __name__ == '__main__':
Expand Down

0 comments on commit b1cf43e

Please sign in to comment.