Make the freesurfer input work for T1-weighted data that is not 1mm resoultion #300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thedb-folder were already not properly aligned:After digging some more, I found this piece of code that corrects the gifti coordinates to be RAS coordinates:
pycortex/cortex/freesurfer.py
Line 144 in bbc1741
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?