unravel.coordinates.ccf30_points_to_merfish module#
Use coords_ccf30_points_to_merfish or ccf30_points_to_merfish from UNRAVEL
to transform CCFv3 30 µm point coordinates into MERFISH-CCF space using ANTs point transforms.
This is the point-coordinate analogue of warp_ccf30_to_merfish. It should
be used instead of warping sparse labeled point images, because sparse labels
can be dropped or merged during image resampling/warping.
- Input:
CSV with CCF30 voxel coordinates, e.g. x, y, z
CCF30 moving image used as the coordinate reference
CCF30_to_MERFISH warp root
- Output:
- CSV with original columns plus transformed MERFISH coordinates:
ccf30_x, ccf30_y, ccf30_z ccf30_phys_ras_x/y/z ccf30_phys_lps_x/y/z merfish_phys_lps_x/y/z merfish_phys_ras_x/y/z merfish_padded_x/y/z merfish_x, merfish_y, merfish_z merfish_in_bounds
Notes
Input x/y/z are assumed to be CCF30 voxel coordinates.
ANTs point transforms use physical coordinates in LPS space.
NIfTI affines from nibabel are treated as RAS; by default this script converts RAS <-> LPS around the ANTs point transform.
Image resampling and point transforms use opposite transform directions in ANTs. For moving CCF30 points -> fixed MERFISH points, this script uses: initial transform inverted, affine transform inverted, inverse warp
The final MERFISH voxel coordinates are cropped to match the unpadded MERFISH_resampled_average_template.nii.gz dimensions, matching the behavior of warp_ccf30_to_merfish / forward_warp.
Usage:#
- coords_ccf30_points_to_merfish
-i unique_voxels_CCF30_coords.csv -m CCF30/atlas_CCFv3_2020_30um.nii.gz -w /path/to/MERFISHf_CCF30m -x x -y y -z z -o unique_voxels_MERFISH_coords.csv -v
- unravel.coordinates.ccf30_points_to_merfish.ras_to_lps(points)[source]#
Convert Nx3 RAS physical coordinates to LPS.
- unravel.coordinates.ccf30_points_to_merfish.lps_to_ras(points)[source]#
Convert Nx3 LPS physical coordinates to RAS.
- unravel.coordinates.ccf30_points_to_merfish.voxel_to_physical_ras(voxel_coords, affine)[source]#
Convert Nx3 voxel coordinates to physical RAS coordinates.
- unravel.coordinates.ccf30_points_to_merfish.physical_ras_to_voxel(phys_coords, affine)[source]#
Convert Nx3 physical RAS coordinates to voxel coordinates.
- unravel.coordinates.ccf30_points_to_merfish.calculate_padded_dimensions(original_dimensions, pad_percent=0.15)[source]#
Match UNRAVEL forward_warp padding calculation.
- unravel.coordinates.ccf30_points_to_merfish.get_point_transformlist_moving_to_fixed(reg_outputs_path)[source]#
Return transform list for mapping moving-space points to fixed-space points.
This is the point-transform analogue of moving image -> fixed image warping. Because ANTs point transforms go opposite to image resampling, this uses the inverse-warp style list.