spine-generic / data-multi-subject

Multi-subject data for the Spine Generic project
Creative Commons Attribution 4.0 International
21 stars 15 forks source link

Update T1w scans with re-defaced images #146

Closed renelabounek closed 7 months ago

renelabounek commented 12 months ago

Following the #115, I have shared with @jcohenadad 49 re-defaced T1w scans. I have done visual inspection and confirm that no subject ID switch happenned and that re-defaced scans contains the whole brain volume without any cut-offs.

Six scans can not be re-defaced, because raw data are unavailable:

We should decide if bain cut offs are minimal in these 6 scans or if these IDs should be added into the brain_t1 category in the exclude.yml file.

I am still awaiting if another 4 scans of one center will be re-defaced or not.

valosekj commented 11 months ago

Thank you @renelabounek! I successfully downloaded the re-defaced images for 49 subjects and saved them to ~/duke/temp/janvalosek/data-multi-subject-redefaced.

@mguaypaq, could you please push the data to git-annex? Thanks!

renelabounek commented 11 months ago

In the most of the images in bids format, I have executed fslreorient2std. But not in all the cases. Thus, it may be worth to double check if orientation of all updated scans is the same as manually drawn masks, etc. in the database.

valosekj commented 11 months ago

In the most of the images in bids format, I have executed fslreorient2std.

Thanks for this comment! This is important information!

I checked the orientation of both the original images (located under master branch) and the re-defaced ones (~/duke/temp/janvalosek/data-multi-subject-redefaced):

# orig
data-multi-subject-redefaced$ for file in sub-*/anat/*nii.gz;do echo ${file}; sct_image -i ../data-multi-subject/${file} -header | grep -E qform_[xyz];echo "";done >> orientations_orig.txt

# re-defaced
data-multi-subject-redefaced$ for file in sub-*/anat/*nii.gz;do echo ${file}; sct_image -i ${file} -header | grep -E qform_[xyz];echo "";done >> orientations_redefaced.txt

orientations_orig.txt orientations_redefaced.txt

Indeed, in 18 subjects, orientation has been changed from LPI to RPI; see here.

Thus, it may be worth to double check if orientation of all updated scans is the same as manually drawn masks, etc. in the database.

Good point! The thing is that the label files under derivatives/labels already have a different orientation (and sometimes even resolution!!!) relative to the original images. This happened because the images were reoriented to RPI and resampled to 1mm iso, see code here. See also issue https://github.com/spine-generic/data-multi-subject/issues/144.


A possible solution: reorient the re-defaced images back to LPI using sct_image -setorient LPI to match the original images under master branch.

valosekj commented 11 months ago

A possible solution: reorient the re-defaced images back to LPI using sct_image -setorient LPI to match the original images under master branch.

We agreed on this solution during the SCT dev meeting on 2023-08-10 --> I will do it.

valosekj commented 11 months ago
I fixed the orientation using the following script: ```bash #!/bin/bash # Fix orientation of the re-defaced images to match the original images for file in sub-*/anat/*nii.gz;do redefaced_image=${file} original_image="../data-multi-subject/${file}" echo "Redefaced image: ${redefaced_image}" echo "Original image: ${original_image}" # Fetch orientations, e.g., LPI or RPI redefaced_orientation=$(sct_image -i ${redefaced_image} -header | grep -E qform_[xyz] | awk '{printf "%s", substr($2, 1, 1)}') original_orientation=$(sct_image -i ${original_image} -header | grep -E qform_[xyz] | awk '{printf "%s", substr($2, 1, 1)}') echo "Redefaced orientation: ${redefaced_orientation}" echo "Original orientation: ${original_orientation}" if [[ ${redefaced_orientation} != ${original_orientation} ]]; then echo "Orientations are different --> fixing it" sct_image -i ${redefaced_image} -setorient ${original_orientation} -o ${redefaced_image} fixed_orientation=$(sct_image -i ${redefaced_image} -header | grep -E qform_[xyz] | awk '{printf "%s", substr($2, 1, 1)}') echo "Fixed orientation: ${fixed_orientation}" fi done ```

Now, the orientation between the re-defaced and original images (located under master branch) is identical:

orientations_orig.txt orientations_redefaced.txt

See diff here.

I saved the data to ~/duke/temp/janvalosek/data-multi-subject-redefaced. @mguaypaq, could you please push the data to git-annex? Thanks!