PyNutil.seg_to_coords#

PyNutil.seg_to_coords(folder, registration, atlas, pixel_id=[0, 0, 0], object_cutoff=0, segmentation_format='binary', return_orientation='asr')[source]#

Transform segmentation images into atlas-space coordinates.

Parameters:
  • folder – Path to a folder containing segmentation images.

  • 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.

  • pixel_id – RGB value or label identifier used to select the segmented class of interest.

  • object_cutoff – Minimum object size to keep during segmentation processing.

  • segmentation_format – Name of the segmentation adapter to use, for example "binary" or "cellpose".

  • return_orientation (3-letter BrainGlobe orientation string (e.g. "asr",) – “ras”). Defaults to “asr” (internal orientation).

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")
>>> result = seg_to_coords(
...     "path/to/segmentations/",
...     registration,
...     atlas,
...     pixel_id=[0, 0, 0],
... )
>>> result.points.points.shape
(N, 3)
>>> result.objects.labels.shape
(M,)