metachat.pp.load_barrier_segments

metachat.pp.load_barrier_segments(csv_path=None, coord_cols=('axis-2', 'axis-1'), close_polygons=True, scale=None)[source]

Parse Napari shapes CSV and extract barrier line segments.

This function converts a Napari shapes .csv file (usually exported from Napari’s “Shapes” layer) into a list of 2D line segments represented as coordinate pairs. Each shape is grouped by its index and its vertices ordered by vertex-index.

Parameters

csv_pathstr

Path to the Napari shapes CSV file.

coord_colstuple of str, default=(‘axis-2’, ‘axis-1’)

Column names representing the coordinate axes in the CSV. The order is typically (‘axis-2’, ‘axis-1’) = (Y, X).

close_polygonsbool, default=True

Whether to close polygonal shapes by connecting the last vertex to the first.

scalefloat, optional

Scaling factor applied to all coordinates. For example, set scale=0.5 to convert from pixel to micrometer units.

Returns

segslist of tuple

A list of line segments, each represented as [((x1, y1), (x2, y2)), ((x3, y3), (x4, y4)), …].

Notes

The input CSV should contain at least the following columns: [‘index’, ‘vertex-index’, ‘shape-type’, ‘axis-2’, ‘axis-1’].