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) – An ImageSeries produced by read_segmentation_dir(), or constructed manually for custom segmentation types. The series carries pixel_id and segmentation_format set at read time.

  • registration (RegistrationData) – Registration data returned by PyNutil.read_alignment().

  • atlas (Union[AtlasData, BrainGlobeAtlas]) – Atlas definition to use for labeling. This may be an AtlasData instance 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.points for per-pixel atlas-space coordinates and result.objects for centroid-level object coordinates. Both point sets include labels, hemisphere labels, per-section lengths, and undamaged masks when available.

Return type:

ExtractionResult

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,)