[Windows/WSL] warping field creation error

Hello SCT team,

I am trying to run the command
sct_register_to_template -i fmri_spine_moco_mean.nii.gz -s fmri_spine_moco_mean_seg_corr.nii.gz -l fmri_labels.nii.gz

It works and registers properly, but I keep getting an error when it goes to save the warping fields. The error I get is pasted below and is the same error as in this post, but there is no solution that helps me.

I am running this command through WSL on an external drive. My computer does not have enough storage space for all the data so I have to keep it on the external drive. I have tried the command locally with the full paths to the external drive for the data, but that doesn’t work. However, if I move the data locally on my computer and run it it works.

I am assuming it doesn’t like the external drive, but I don’t have a solution to that so any help is much appreciated.

My next thoughts are to just reinstall SCT and see if that does anything.

Generate output files…
File warp_template2anat.nii.gz already exists. Deleting it…
Traceback (most recent call last):
File “/home/sensel/spinalcordtoolbox/python/envs/venv_sct/lib/python3.7/shutil.py”, line 566, in move
os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: ‘/tmp/sct-20220706151611.621359-register_to_template-9y2i33xq/warp_template2anat.nii.gz’ → ‘warp_template2anat.nii.gz’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/sensel/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_register_to_template.py”, line 1336, in
File “/home/sensel/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_register_to_template.py”, line 767, in main
generate_output_file(os.path.join(path_tmp, “warp_template2anat.nii.gz”), os.path.join(path_output, “warp_template2anat.nii.gz”), verbose=verbose)
File “/home/sensel/spinalcordtoolbox/spinalcordtoolbox/image.py”, line 1480, in generate_output_file
shutil.move(fname_in, fname_out)
File “/home/sensel/spinalcordtoolbox/python/envs/venv_sct/lib/python3.7/shutil.py”, line 580, in move
copy_function(src, real_dst)
File “/home/sensel/spinalcordtoolbox/python/envs/venv_sct/lib/python3.7/shutil.py”, line 267, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
File “/home/sensel/spinalcordtoolbox/python/envs/venv_sct/lib/python3.7/shutil.py”, line 206, in copystat
PermissionError: [Errno 1] Operation not permitted

Hi @sensel,

Thank you for reporting this error. I have begun investigating possible solutions for this issue, and will report back as soon as I can with a fix.

For now, I have opened a new issue in the SCT repository (#3832) for further investigation. :slight_smile:

Kind regards,

1 Like

Hi @sensel,

I have created a fix for this issue (PR #3833), and it will be included in the upcoming SCT v5.7 release (ETA late July).

However, if you would like to try out this fix right now, you can apply the fix using this patch:

0001-image.py-Use-shutil.copyfile-if-src-dest-are-on-diff.patch (2.1 KB)

To apply this patch, you can run the following commands inside WSL:

wget https://forum.spinalcordmri.org/uploads/short-url/9mRLa3EJFYH5rxsLPB6eC8MKUi9.patch
git apply 9mRLa3EJFYH5rxsLPB6eC8MKUi9.patch

Then, feel free to re-run your sct_register_to_template command and let me know how it goes. :slight_smile:

Kind regards,

Worked like a charm! Thank you!

1 Like

Hello! This patch is included in the latest release SCT v5.7. :tada: