poldracklab / pydeface

defacing utility for MRI images
MIT License
110 stars 42 forks source link

How to save defaced output in a different directory (from input) when using --applyto argument. #50

Open anandsaini024 opened 1 year ago

anandsaini024 commented 1 year ago

I am using pydeface 2.0.2 on docker. Following is the command I am using to deface my multiple .nii files using --applyto argument:

docker run -v /home/ .. /outputs:/output -v /home/ .. /inputs/:/input pydeface:0.1.2 pydeface --outfile /output/defaced.nii.gz --applyto /input/*.nii.gz --outfile /output/ --force /input/sample_file_1.nii.gz

Pydeface command is basically as follows:

*pydeface --outfile /output/defaced.nii.gz --applyto /input/.nii.gz --outfile /output/ --force /input/sample_file_1.nii.gz**

This works fine and save the defaced output in my input directory and not in the outfile directory where I want to store the output. Can you please let me know what corrections can be made to save defaced output in a separate directory to that of input using --applyto argument?

Thanks

ofgulban commented 1 year ago

Hi @anandsaini024 , thanks for your question.

Looking at the source, I see that the --applyto uses its input path as the output. So I think the extra --outfile arguments you use are actually not doing anything with regards to where the applyto outputs are saved.

Quickest workaround would be if you use a few move commands to move the applyto outputs to the folders you want them to be. Would this work for you? Otherwise, we need to modify the behavior make a new release of pydeface etc. which might take some time in my schedule.

anandsaini024 commented 1 year ago

Quickest workaround would be if you use a few move commands to move the applyto outputs to the folders you want them to be. Would this work for you? Otherwise, we need to modify the behavior make a new release of pydeface etc. which might take some time in my schedule.

Using move commands will not help in my case as I have a problem with the outputs saving in the same path to begin with ( because my input directory is read-only). Can you think of anything else that could be helpful in my case? Also, let me know if you think there should be any modification in pydeface. Thanks

ofgulban commented 1 year ago

I see, ok then I can have a look at this on thursday, or latest friday. Will update you.

anandsaini024 commented 1 year ago

Sure, Thanks!

ofgulban commented 1 year ago

Hi @anandsaini024 , try cloning pydeface from the devel branch and install it (if done correctly you should see pydeface 2.0.3). See the new --outdir argument. Using this should export all your outputs into a custom output directory.

anandsaini024 commented 1 year ago

Thank you @ofgulban

ofgulban commented 1 year ago

@anandsaini024 , I assume everything is working. It might take some time for me to release this update. So, if you encounter any bugs related to this issue feel free to post here.