When I warp the template to the native space, the PAM50 atlas seems different from the DWI images and segmentation mask. I think that this mismatch between PAM50 and the DWI images is affecting the statistics (sct_extract_metrics).
I used sct-4.3.
Image registration is completely image-dependent and should be resolved on a case-by-case basis (image resolution, contrast, noise, artefacts, etc.). So it is impossible for us to help without seeing the images. Would you be able to share them?
Here I attached the images of 2 subjects: the Mean Diffusivity, the mask of the DWI segmentation, and the dmri_labels.
With these images I run the sct_register_to_template. If you need more data let me know. Thanks in advance.
Given that the cord segmentation is slightly larger than the cord itself (oversegmentation), I would only rely on the cord segmentation to do the cord alignment and get its orientation (rotatino) on a slice-by-slice basis. Then, I would switch to the image-based registration. Given the relatively small appearance of the cord compared to the PAM50 template, I would increase slightly the number of iterations (but not too much, given that the SyN algorithm is poorly regularized). I find that the following configuration works pretty well:
Thanks for your work. The registration is obviously improved. However, when I run the sct_warp_template, with the -w warp_template2anat obtained from your script, I obtain the PAM50 atlas with a different field of view (or orientation), as informed fsleyes. I tried to use a different mask, but the results were similar. The template2anat.nii was correct, but the problem appears when I run the sct_warp_template.
These patients have severe atrophy in the spinal cord; that’s why it seems small compared to the template.
I do not know if this mismatch could affect the results when I extract the metrics for each label and each WM atlas pathway
As I told you, the template2anat.nii do not seems to show this problem, however when I apply the warp_template2dmri.nii.gz appear this message. It could be a problem to extract the dwi-related metrics?
I don’t see any file called “PARESP_00003__003_WholeSpine_Mask2.nii.gz” in the files you shared. To make sure you and I are testing your code on the same data, could you please zip all the necessary files into a single zip package and upload it here. thanks
OS: linux (Linux-5.4.0-66-generic-x86_64-with-debian-bullseye-sid)
CPU cores: Available: 8, Used by ITK functions: 8
RAM: Total: 31993MB, Used: 824MB, Available: 30659MB
Check Python executable…[OK]
Using bundled python 3.6.12 |Anaconda, Inc.| (default, Sep 8 2020, 23:10:56)
[GCC 7.3.0] at /home/jnavas/sct_5.1.0/python/envs/venv_sct/bin/python
Check if data are installed…[OK]
Check if colored is installed…[OK] (1.4.2)
Check if dipy is installed…[OK] (1.3.0)
Check if futures is installed…[OK]
Check if h5py is installed…[OK] (2.10.0)
Check if Keras (2.1.5) is installed…[OK] (2.1.5)
Check if ivadomed (2.6.1) is installed…[OK] (2.6.1)
Check if matplotlib is installed…[OK] (3.3.3)
Check if nibabel is installed…[OK] (3.2.1)
Check if numpy is installed…[OK] (1.19.5)
Check if onnxruntime (1.4.0) is installed…[OK] (1.4.0)
Check if pandas is installed…[OK] (1.1.5)
Check if psutil is installed…[OK] (5.8.0)
Check if pyqt5 (5.11.3) is installed…[OK] (5.11.3)
Check if pytest is installed…[OK] (6.2.1)
Check if pytest-cov is installed…[OK] (version = ‘2.11.1’)
Check if raven is installed…[OK]
Check if requests is installed…[OK] (2.25.1)
Check if requirements-parser is installed…[OK] (0.2.0)
Check if scipy is installed…[OK] (1.5.4)
Check if scikit-image is installed…[OK] (0.17.2)
Check if scikit-learn is installed…[OK] (0.24.1)
Check if tensorflow (1.5.0) is installed…[OK] (1.5.0)
Check if torch (1.5.0+cpu) is installed…[OK] (1.5.0+cpu)
Check if torchvision (0.6.0+cpu) is installed…[OK] (0.6.0+cpu)
Check if xlwt is installed…[OK] (1.3.0)
Check if tqdm is installed…[OK] (4.56.0)
Check if transforms3d is installed…[OK] (0.3.1)
Check if urllib3 is installed…[OK] (1.26.2)
Check if pytest_console_scripts is installed…[OK]
Check if pytest-xdist is installed…[OK] (2.2.0)
Check if spinalcordtoolbox is installed…[OK]
Check ANTs compatibility with OS …[OK]
Check PropSeg compatibility with OS …[OK]
Check if DISPLAY variable is set…[OK]
Check if figure can be opened with PyQt…[OK]
@Javier_Navas ah! I found out what the problem was! My FSLeyes version (0.31) was older than yours (0.34.2), and it did not show the “Displaying images with different orientations/fields of view” message.
I have upgraded FSLeyes to 0.34.2 and I confirm that I do see this message. Investigating further, I do notice a discrepancy between the input image and the template for the qform/sform:
Now, the good news is that this is not an issue for SCT pipelines, which relies on the qform only. So you can go ahead with your analyses. However, I do agree that we should ensure the sform is preserved. An issue has now been opened and we will fix it with high priority.