CorpusCallosum.registration.midsagittal_plane_alignment¶
- class CorpusCallosum.registration.midsagittal_plane_alignment.MidplaneDebugVolumes(distance_diff, candidate_mask, left_mask, right_mask)[source]¶
Debug volumes produced by distance-map midplane refinement.
Attributes
distance_diff
(np.ndarray) Voxel-wise difference
d_left - d_rightin fsaverage space.candidate_mask
(np.ndarray) Boolean mask selecting voxels used for plane fitting.
left_mask
(np.ndarray) Partitioned binary left-hemisphere mask in fsaverage space.
right_mask
(np.ndarray) Partitioned binary right-hemisphere mask in fsaverage space.
- class CorpusCallosum.registration.midsagittal_plane_alignment.MidplaneRefinementResult(updated_vox2vox, center_shift_vox, diagnostics, debug_volumes)[source]¶
Container for distance-map refinement outputs.
Attributes
updated_vox2vox
(AffineMatrix4x4) Updated subject-to-fsaverage voxel transform.
center_shift_vox
(float) Estimated LR center shift in fsaverage voxels.
diagnostics
(dict[str, object]) JSON-serializable diagnostics and rejection reasons.
debug_volumes
(MidplaneDebugVolumes) Optional intermediate volumes for quality control and debugging.
- class CorpusCallosum.registration.midsagittal_plane_alignment.MidplaneTransformResult(orig2fsavg_vox2vox, fsavg_vox2ras, fsavg_header_dict, fsavg_shape, base_middle_vox, midline_shift_vox, midline_shift_diagnostics)[source]¶
Result returned by
find_midplane_transform().Attributes
orig2fsavg_vox2vox
(AffineMatrix4x4) Subject-to-fsaverage voxel transform after optional refinement.
fsavg_vox2ras
(AffineMatrix4x4) fsaverage voxel-to-RAS transform used for downstream mapping.
fsavg_header_dict
(MGHHeaderDict) Header metadata for the fsaverage-aligned volume.
fsavg_shape
(Shape3d) Shape of the fsaverage-aligned target grid.
base_middle_vox
(float) Baseline midsagittal x-coordinate in fsaverage voxel units.
midline_shift_vox
(float) Applied LR shift (or estimated center shift) in voxel units.
midline_shift_diagnostics
(dict[str, object]) Method-specific diagnostics for refinement decisions.
- CorpusCallosum.registration.midsagittal_plane_alignment.find_midplane_transform(orig, aseg_img, midplane_method)[source]¶
Resolve the fsaverage midplane transform for a selected refinement method.
- Parameters:
- orig
nibabelImage Input conformed anatomical image.
- aseg_img
nibabelImage Subject aseg segmentation image.
- midplane_method
str Midplane strategy. Supported values are
"center","fsaverage","fsaverage_distance_map", and"fsaverage_symmetry".
- orig
- Returns:
MidplaneTransformResultTransform bundle and method-specific diagnostics for downstream CC steps.
- CorpusCallosum.registration.midsagittal_plane_alignment.refine_midline_lr_shift(orig2fsavg_vox2vox, aseg_data, fsavg_shape, base_middle_vox, max_shift_vox=6, step_vox=1)[source]¶
Refine midsagittal alignment by searching small LR translations.
- Parameters:
- orig2fsavg_vox2vox
AffineMatrix4x4 Initial subject-to-fsaverage voxel transform.
- aseg_data
np.ndarray Subject segmentation labels in native voxel space.
- fsavg_shape
Shape3d Shape of the fsaverage target grid.
- base_middle_vox
float Baseline midsagittal x-coordinate in fsaverage voxels.
- max_shift_vox
int, default=6 Maximum absolute LR shift explored.
- step_vox
int, default=1 Integer step size for the LR search.
- orig2fsavg_vox2vox
- Returns:
Notes
Candidate shifts are regularized and validated with conservative rejection criteria (boundary hits, low support, and weak improvements over baseline).
- CorpusCallosum.registration.midsagittal_plane_alignment.refine_midplane_with_distance_maps(orig2fsavg_vox2vox, aseg_data, fsavg_shape, base_middle_vox, zero_band_vox=0.5, support_distance_vox=24.0, fit_band_vox=20.0, max_tilt_deg=7.5, max_center_shift_vox=8.0)[source]¶
Fit a midsagittal plane from LR distance-map symmetry in fsaverage space.
- Parameters:
- orig2fsavg_vox2vox
AffineMatrix4x4 Initial subject-to-fsaverage voxel transform.
- aseg_data
np.ndarray Subject segmentation labels in native voxel space.
- fsavg_shape
Shape3d Shape of the fsaverage target grid.
- base_middle_vox
float Baseline midsagittal x-coordinate in fsaverage voxels.
- zero_band_vox
float, default=0.5 Absolute distance-difference threshold for candidate midplane voxels.
- support_distance_vox
float, default=24.0 Maximum distance to either hemisphere mask for candidate support.
- fit_band_vox
float, default=20.0 X-range around baseline center used for plane fitting.
- max_tilt_deg
float, default=7.5 Maximum accepted angular tilt away from the LR axis.
- max_center_shift_vox
float, default=8.0 Maximum accepted LR center shift from baseline.
- orig2fsavg_vox2vox
- Returns:
MidplaneRefinementResultUpdated transform, applied center shift, diagnostics, and debug volumes.
- CorpusCallosum.registration.midsagittal_plane_alignment.register_centroids_to_fsavg(aseg_nib)[source]¶
Estimate a rigid subject-to-fsaverage alignment from aseg centroids.
- Parameters:
- aseg_nib
nibabelImage Input aseg image in subject space.
- aseg_nib
- Returns:
tuple[AffineMatrix4x4,AffineMatrix4x4,AffineMatrix4x4,MGHHeaderDict](aseg2fsavg_vox2vox, aseg2fsavg_ras2ras, fsavg_hires_vox2ras, fsavg_header).
- CorpusCallosum.registration.midsagittal_plane_alignment.resample_segmentation_to_fsavg(seg_data, orig2fsavg_vox2vox, fsavg_shape)[source]¶
Resample a segmentation into fsaverage voxel space.
- Parameters:
- seg_data
np.ndarray Input segmentation array in subject voxel space.
- orig2fsavg_vox2vox
AffineMatrix4x4 Subject-to-fsaverage voxel transform.
- fsavg_shape
Shape3d Output shape in fsaverage voxel coordinates.
- seg_data
- Returns:
np.ndarrayResampled integer segmentation in fsaverage space.
Notes
Nearest-neighbor interpolation is used to preserve discrete labels.