Skip to content

Conversation

@Gilles86
Copy link
Contributor

@Gilles86 Gilles86 commented Dec 6, 2018

Hi,

I tried to use pycortex with my 7T mp2rage data at a resolution of 0.64mm and I just couldn't get it to work. The volumes always seemed to be sampled wrong, whatever transformation matrix I would use, even for the very T1w images the segmentations were built on (identity matrix, fsl BBR, import of freesurfer, import of fsl...).

After some digging, I noticed that when I imported the freesurfer segmentations using cortex.freesurfer.import_subj, the resulting giftis that were put in the db-folder were already not properly aligned:
screenshot 2018-12-06 11 02 10

After digging some more, I found this piece of code that corrects the gifti coordinates to be RAS coordinates:

surfmove = trans - np.sign(trans) * [128, 128, 128]

This seems to assume that the anatomicals are always 256x256x256 voxels and at a resolution of 1 mm, like the standard freesurfer pipelines spit out. However, my data is different: I have 256x320x320 voxels at a resolution of 0.64 mm. I think there will be more people like me.

I revised the code, using Freesurfer's mris_convert to go to gii and borrowing very heavily on the work by the fmriprep folks to correct to RAS coordinates (who apparently base their work on the HPC preprocessing pipeline):
https://github.com/poldracklab/fmriprep/blob/master/fmriprep/interfaces/surf.py#L193

What do guys you think?

@Gilles86
Copy link
Contributor Author

Gilles86 commented Feb 8, 2019

So I rebased this commit to the latest upstream/master version. Can someone of the core pycortex team have a look at this gain?

For my research the submillimeter resolution is really necessary, but I also want to stay in sync with the latest upstream updates.

@tknapen
Copy link
Contributor

tknapen commented Feb 22, 2019

@alexhuth @jamesgao Sorry to badger you, but is there any way you could merge this pul request? We're moving our entire lab to high-res anatomies and we'd like to be able to keep using pycortex. If you have any questions, please ask me or @Gilles86 Thanks!

@jamesgao
Copy link
Contributor

Any chance you guys can rebase these commits off the latest head? The diff is pretty hard to read because of doc updates. If possible, a cleaner commit history would also be highly appreciated!

Also, since we don't have any higher resolution anatomicals to test this with, adding a test would also let us know if this code actually works or not.

Base automatically changed from master to main January 19, 2021 20:02
@mvdoc
Copy link
Contributor

mvdoc commented Apr 5, 2024

Hi @Gilles86 @tknapen, sorry it took so long but I guess it's better late than never :-) I finally got my hands on a sub-mm T1 and could replicate the bug. This bug will be fixed as soon as we merge #531.

For PyCortex's purposes, I think it's sufficient to use mris_convert --to-scanner rather than using the fixes from fMRIPrep (now in sMRIprep: https://www.nipreps.org/smriprep/0.11.1/api/smriprep.interfaces.surf.html#smriprep.interfaces.surf.NormalizeSurf).

If you have a chance to test the new code, please let me know if it works with your files too. We will push a new pycortex release soon with this new fix.

@mvdoc
Copy link
Contributor

mvdoc commented Apr 5, 2024

Note also that the surfaces imported into pycortex will not look aligned to the T1 when opened with freeview (this happens also with surfaces computed on 1mm isotropic data). But they will work fine in pycortex.

@mvdoc
Copy link
Contributor

mvdoc commented Apr 8, 2024

I will close this PR as the bug has been fixed. Please feel free to open an issue if there are still problems with importing sub-mm volumes.

@mvdoc mvdoc closed this Apr 8, 2024
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 this pull request may close these issues.

4 participants