read_roi#
- ktch.io.read_roi(file_path, as_frame=False)[source]#
Read an ImageJ ROI file (.roi) or ROI set (.zip).
Reads the ROI types that store a list of coordinates: closed outlines (polygon, freehand, traced), open curves (polyline, freeline), angles and points. The coordinates are returned as the file stores them, in pixels with y downward (see
RoiDatafor where an integer coordinate lies in a pixel).- Parameters:
- file_pathstr or pathlib.Path
Path to a
.roifile, or to a.zipof.roifiles such as the ROI Manager saves. Entries of the.zipthat are not.roifiles are skipped.- as_framebool, default=False
If True, return a
DataFrame.
- Returns:
- resultRoiData or list of RoiData or pd.DataFrame
A
RoiDatafor a single ROI, a list of them, in the order of the ROI set, for several, or, withas_frame=True, one DataFrame with columnsx,y,nameandpositionand a MultiIndex(specimen_id, coord_id).
- Raises:
- FileNotFoundError
If the file does not exist.
- ValueError
If the file is not a
.roior.zipfile, if a ROI set holds no.roifile, if a ROI is not in the ImageJ format or is truncated, or if a ROI is of a type without a coordinate list (rectangle, oval, straight line, composite, text, image, or a freehand ellipse or rotated rectangle). The message names the ROI.
Examples
>>> from ktch.io import read_roi >>> rois = read_roi("RoiSet.zip") >>> rois[0].coords