gallantlab / pycortex

Pycortex is a python-based toolkit for surface visualization of fMRI data
https://gallantlab.github.io/pycortex
BSD 2-Clause "Simplified" License
581 stars 137 forks source link

FIX,MNT import surfaces generated from volumes with any voxel size #531

Closed mvdoc closed 5 months ago

mvdoc commented 5 months ago

This PR fixes the bug first described in #300. Pycortex always assumed that the surfaces were generated out of T1s with 1mm3 isotropic voxel size. If one imported surfaces generated from other volumes (e.g., sub-mm), then the surfaces would be misaligned (see example in #300). To fix this issue, here I'm simply importing and converting the surfaces to gifti with Freesurfer's mris_convert --to-scanner, which uses the same coordinate system as the T1 rather than the TKR system used for surfaces.

This change produces the same surfaces as the old code for 1mm3 volumes. I'm waiting for freesurfer to finish on a sub-mm volume to test it there too.

(This PR also cleans up the code in that function a bit to make it easier to maintain...)

mvdoc commented 5 months ago

OK, I tested this with a sub-mm T1, and it worked as well.