unravel.coordinates.labeled_voxel_img_to_points module#

Use coords_labeled_voxel_img_to_points or labeled_voxel_img_to_points from UNRAVEL to decode a labeled voxel image back into a table of label coordinates.

This is useful after a unique-voxel labeled image has been reoriented, resampled, or warped into another space, e.g. MERFISH-CCF space.

Input:
  • labeled .nii.gz image where each nonzero value is a voxel_label

  • optional mapping CSV from points_to_labeled_voxel_img linking voxel_label to original metadata

Output:
  • CSV with one row per voxel_label and coordinates in the current image space

Note

  • If warping creates multiple voxels for the same label, coordinates are summarized by centroid, median, and mode-like first voxel.

  • Use centroid_x/y/z for sphere-mask creation unless you prefer an integer voxel coordinate. The rounded centroid columns are also provided.

Usage:#

labeled_voxel_img_to_points

-i unique_voxels_labeled_MERFISH.nii.gz -map unique_voxels/units__unique_voxel_mapping.csv -o unique_voxels_MERFISH_coords.csv -v

unravel.coordinates.labeled_voxel_img_to_points.parse_args()[source]#
unravel.coordinates.labeled_voxel_img_to_points.summarize_label_coords(label, coords, mode='centroid_rounded')[source]#

Summarize coordinates for one label and return a dict.

Parameters:#

labelint

The voxel label being summarized.

coordsndarray

An Nx3 array of voxel coordinates corresponding to the given label.

modestr

The method for summarizing coordinates. Options are: - ‘centroid_rounded’: Compute the centroid and round to the nearest integer voxel coordinate - ‘centroid_float’: Compute the centroid and keep as float (physical space) - ‘median’: Compute the median coordinate across all voxels - ‘first’: Take the coordinates of the first voxel (mode-like)

Returns:#

dict

A dictionary for a row with keys ‘voxel_label’, ‘x’, ‘y’, ‘z’, and ‘n_voxels_after_warp’.

unravel.coordinates.labeled_voxel_img_to_points.main()[source]#