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

Update T1w scans with re-defaced images #146

Closed
renelabounek opened this issue Jul 21, 2023 · 5 comments · Fixed by #148
Closed

Update T1w scans with re-defaced images #146

renelabounek opened this issue Jul 21, 2023 · 5 comments · Fixed by #148
Assignees

Comments

@renelabounek
Copy link
Contributor

renelabounek commented Jul 21, 2023

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:

  • sub-milan05
  • sub-milan06
  • sub-milan07
  • sub-beijingVerio01
  • sub-beijingVerio02
  • sub-beijingVerio04

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
Copy link
Contributor

valosekj commented Aug 9, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor

valosekj commented Aug 9, 2023

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 #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
Copy link
Contributor

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 valosekj self-assigned this Aug 10, 2023
@valosekj
Copy link
Contributor

I fixed the orientation using the following script:
#!/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!

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

Successfully merging a pull request may close this issue.

2 participants