Skip to content

Commit 56387cc

Browse files
committed
Fix and add explanation on how change cc_visualization.py
1 parent f6a9726 commit 56387cc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CorpusCallosum/cc_visualization.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77

8-
from CorpusCallosum.data.constants import FSAVERAGE_MIDDLE
98
from CorpusCallosum.data.fsaverage_cc_template import load_fsaverage_cc_template
109
from CorpusCallosum.shape.contour import CCContour
1110
from CorpusCallosum.shape.mesh import CCMesh
@@ -222,7 +221,15 @@ def main(
222221
cc_mesh.plot_mesh(output_path=str(output_dir / "cc_mesh.html"), **plot_kwargs)
223222

224223
#FIXME: needs to be adapted to new interface of CCMesh.to_fs_coordinates / to_vox_coordinates
225-
cc_mesh = cc_mesh.to_vox_coordinates(lr_offset=FSAVERAGE_MIDDLE / resolution)
224+
# Here we need to load the np.linalg.inv(fsavg_vox2ras @ orig2fsavg_vox2vox)
225+
# This is the same as orig2fsavg_ras2ras from cc_up.lta
226+
# orig2fsavg_ras2ras = read_lta(output_dir / "mri/transforms/cc_up.lta")
227+
# orig = nibabel.load(output_dir / "mri/orig.mgz")
228+
# cc_mesh = cc_mesh.to_vox_coordinates(mesh_ras2vox=np.linalg.inv(orig2fsavg_ras2ras @ orig.affine))
229+
# If we are willing to screenshot here in fsavg space, this can be simplified to just fsavg_vox2ras
230+
from CorpusCallosum.data.read_write import load_fsaverage_data
231+
fsavg_vox2ras, _ = load_fsaverage_data(Path(__file__).parent / "data/fsaverage_data.json")
232+
cc_mesh = cc_mesh.to_vox_coordinates(mesh_ras2vox=np.linalg.inv(fsavg_vox2ras))
226233
logger.info(f"Writing vtk file to {output_dir / 'cc_mesh.vtk'}")
227234
cc_mesh.write_vtk(str(output_dir / "cc_mesh.vtk"))
228235
logger.info(f"Writing freesurfer surface file to {output_dir / 'cc_mesh.fssurf'}")

CorpusCallosum/data/read_write.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def load_fsaverage_centroids(centroids_path: str | Path) -> dict[int, npt.NDArra
129129
return {int(label): np.array(centroid) for label, centroid in centroids_data.items()}
130130

131131

132-
def load_fsaverage_affine(affine_path: str | Path) -> npt.NDArray[float]:
132+
def load_fsaverage_affine(affine_path: str | Path) -> AffineMatrix4x4:
133133
"""Load fsaverage affine matrix from static text file.
134134
135135
Parameters

0 commit comments

Comments
 (0)