Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test possible bugs with --overwrite flag & possibly default to clearing old outputs until this is resolved #44

Open
LuciMoore opened this issue May 19, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@LuciMoore
Copy link
Contributor

What happened?

I was debugging by running the application and had produced all of the prebibsnet outputs up until the point that the prebibsnet output anatomicals are copied into the bibsnet input folder. I ran the application again using the --overwrite flag (for reasons that aren't relevant here) and it errored at https://github.com/DCAN-Labs/CABINET/blob/main/run.py#L666 because the output file didn't exist yet from the prior run, so when it tries to remove it there is a file not found error

I would suggest that we only run the copy command whether the file exists or not (if it doesn't exist, it will create it and if it does exist from a prior run, it will be overwritten).

So replace:

        if j_args["common"]["overwrite"]:  # TODO Should --overwrite delete old image file(s)?
            os.remove(out_nii_fpath)
        if not os.path.exists(out_nii_fpath): 
            shutil.copy2(transformed_images[f"T{t}w"], out_nii_fpath)

with:

        if j_args["common"]["overwrite"]:  # TODO Should --overwrite delete old image file(s)?
            shutil.copy2(transformed_images[f"T{t}w"], out_nii_fpath)        

We'll also want to look through the rest of the code base to make sure this issue doesn't exist elsewhere

What command did you use?

not relevant - logic is apparent in code

What version of CABINET are you using?

2.4.0

Relevant log output

No response

Add any additional information or context about the problem here.

No response

@LuciMoore LuciMoore added the bug Something isn't working label May 19, 2023
@kellyhi08
Copy link

I believe I ran into a similar problem when using the overwrite flag. My command worked without it, but failed with the overwrite flag.

Command that works
singularity run --nv --cleanenv --no-home -B $path/BIBSnet_inputs/:/input -B $path/BIBSnet_outputs:/output $path/infant/BIBSnet/bibsnet.sif /input /output participant -v --participant-label $subnum -z

Command that does not work
singularity run --nv --cleanenv --no-home -B $path/BIBSnet_inputs/:/input -B $path/BIBSnet_outputs:/output $path/infant/BIBSnet/bibsnet.sif /input /output participant -v --participant-label $subnum -z --overwrite
Error
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/bibsnet/bibsnet/sub-019/ses-01/input/sub-019_ses-01_optimal_resized_0000.nii.gz'

@LuciMoore
Copy link
Contributor Author

adding info from related issue #46: in prebibsnet, if the crop2full.mat files exist, it skips cropping with robustfov. we should also look for the presence of the cropped T1 and T2 (eg cropped/T1w/sub-_ses-_0000.nii.gz) before skipping robustfov

@LuciMoore LuciMoore changed the title Test possible bugs with --overwrite flag Test possible bugs with --overwrite flag & possibly default to clearing old outputs until this is resolved Sep 20, 2024
@LuciMoore
Copy link
Contributor Author

LuciMoore commented Sep 20, 2024

see relevant issue #137 - might be best to default to clearing old outputs and/or update documentation to help with triage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants