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

display warp: fullWarp_abs.nii.gz is invalid: should be encoded in a 5D file with vector intent code #59

Open
sandrinebedard opened this issue Apr 7, 2021 · 4 comments

Comments

@sandrinebedard
Copy link
Member

sandrinebedard commented Apr 7, 2021

Description

I wanted to apply sct_image -i fullWarp_abs.nii.gz -display-warp to the warping field (fullWarp_abs.nii.gz) used for correction of gradient nonlinearities (gradient_unwarp.py). I got this error:

(venv_sct) sabeda@DESKTOP-JQ8A4UV:/mnt/c/Users/sb199/Projet3_data$ sct_image -i warping_field/fullWarp_abs.nii.gz -display-warp

--
Spinal Cord Toolbox (git-jca/3336-display-warp-7de29b49e9979eb22409e8a11eb2c79eb0277281)
sct_image -i warping_field/fullWarp_abs.nii.gz -display-warp
--

Creating temporary folder (/tmp/sct-20210407144012.007017-jex9nz5p)
sct_resample -i grid_3.nii.gz -f 3x3x1 -x nn -o grid_3_resample.nii.gz # in /tmp/sct-20210407144012.007017-jex9nz5p
sct_apply_transfo -i /tmp/sct-20210407144012.007017-jex9nz5p/grid_3_resample.nii.gz -d /tmp/sct-20210407144012.007017-jex9nz5p/grid_3_resample.nii.gz -w /mnt/c/Users/sb199/Projet3_data/warping_field/fullWarp_abs.nii.gz -o /mnt/c/Users/sb199/Projet3_data/warping_field/grid_3_resample_fullWarp_abs.nii.gz # in /mnt/c/Users/sb199/Projet3_data
Traceback (most recent call last):
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_image.py", line 554, in <module>
    main(sys.argv[1:])
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_image.py", line 233, in main
    visualize_warp(im_warp=im_in, im_grid=None, step=3, rm_tmp=True)
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_image.py", line 547, in visualize_warp
    run_proc(['sct_apply_transfo', '-i', fname_grid, '-d', fname_grid, '-w', fname_warp, '-o', grid_warped])
  File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/utils/sys.py", line 320, in run_proc
    raise RuntimeError(output)
RuntimeError:
--
Spinal Cord Toolbox (git-jca/3336-display-warp-7de29b49e9979eb22409e8a11eb2c79eb0277281)

sct_apply_transfo -i /tmp/sct-20210407144012.007017-jex9nz5p/grid_3_resample.nii.gz -d /tmp/sct-20210407144012.007017-jex9nz5p/grid_3_resample.nii.gz -w /mnt/c/Users/sb199/Projet3_data/warping_field/fullWarp_abs.nii.gz -o /mnt/c/Users/sb199/Projet3_data/warping_field/grid_3_resample_fullWarp_abs.nii.gz
--


Parse list of warping fields...
Traceback (most recent call last):
File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_apply_transfo.py", line 365, in <module>
main(sys.argv[1:])
File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_apply_transfo.py", line 360, in main
transform.apply()
File "/mnt/c/Users/sb199/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_apply_transfo.py", line 169, in apply
.format(path_warp))
ValueError: Displacement field in /mnt/c/Users/sb199/Projet3_data/warping_field/fullWarp_abs.nii.gz is invalid: should be encoded in a 5D file with vector intent code (see https://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h

I tested sct_image -display-warp with a warping field created with sct_register_multimodal and everything worked.
So I think fullWarp_abs.nii.gz follows FSL convention and not ITK, it has only 4 dimensions.

Maybe not worth the trouble for just displaying the grid with the warping field.

The file is in : duke/temp/sebeda/data_warping_field/fullWarp_abs.nii.gz

@sandrinebedard
Copy link
Member Author

UPDATE

I did not figure out how to convert the warping field in the ITK format to make it compatible with sct_image -display-warp but, I figured out that fullWarp_abs.nii.gz is a volume of coefficient, so to have the field, I ran :

fnirtfileutils -i fullWarp_abs.nii.gz -o field.nii.gz

And on ITK-SNAP, when clicking on multi-component display --> grid I get this:
image

Well, it is not as nice as the output of sct_image -display-warp but, from what I observed, the grid is only in the axial view, I think having the sagittal view for the warping field may be better here, maybe we ca do something with that image instead.

@sandrinebedard
Copy link
Member Author

@jcohenadad I may need your insights on this please 😊

@jcohenadad
Copy link
Member

So I think fullWarp_abs.nii.gz follows FSL convention and not ITK, it has only 4 dimensions.

yup! you figured this out. As you probably noticed we have a sct_image -to-fsl feature, but no sct_image -to-itk 😬

However, your investigation in #59 (comment) is excellent, and i think largely sufficient if the goal is simply to export a nice-looking image to illustrate gradient non-linearity correction in the pipeline figure of your article

@sandrinebedard
Copy link
Member Author

However, your investigation in #59 (comment) is excellent, and i think largely sufficient if the goal is simply to export a nice-looking image to illustrate gradient non-linearity correction in the pipeline figure of your article

That's what I thought! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants