PyNutil.seg_to_coords#
- PyNutil.seg_to_coords(image_series, registration, atlas, object_cutoff=0, return_orientation='asr')[source]#
Transform segmentation images into atlas-space coordinates.
- Parameters:
image_series (
ImageSeries) – AnImageSeriesproduced byread_segmentation_dir(), or constructed manually for custom segmentation types. The series carriespixel_idandsegmentation_formatset at read time.registration (
RegistrationData) – Registration data returned byPyNutil.read_alignment().atlas (
Union[AtlasData,BrainGlobeAtlas]) – Atlas definition to use for labeling. This may be anAtlasDatainstance or a BrainGlobe atlas object.object_cutoff – Minimum object size to keep during segmentation processing.
- Returns:
Atlas-space points, centroid-level objects, section metadata, and region-area summaries for the processed series. The returned object exposes
result.pointsfor per-pixel atlas-space coordinates andresult.objectsfor centroid-level object coordinates. Both point sets include labels, hemisphere labels, per-section lengths, and undamaged masks when available.- Return type:
Examples
Process binary segmentation images with a BrainGlobe atlas:
>>> from brainglobe_atlasapi import BrainGlobeAtlas >>> atlas = BrainGlobeAtlas("allen_mouse_25um") >>> registration = read_alignment("path/to/alignment.json") >>> segs = read_segmentation_dir("path/to/segmentations/", pixel_id=[0, 0, 0]) >>> result = seg_to_coords(segs, registration, atlas) >>> result.points.points.shape (N, 3) >>> result.objects.labels.shape (M,)