Skip to content

Data Loaders

Annota provides data loaders for importing annotations from various file formats commonly used in digital pathology.

Load polygon annotations from HDF5 mask files:

import { loadH5Masks } from "annota";
const annotations = await loadH5Masks("/path/to/masks.h5", {
color: "#FF0000",
fillOpacity: 0.3,
});

Load point annotations from HDF5 coordinate files:

import { loadH5Coordinates } from "annota";
const points = await loadH5Coordinates("/path/to/coords.h5", {
color: "#00FF00",
fillOpacity: 0.8,
});
import { loadJSONFile } from "annota";
const annotations = loadJSONFile(jsonData);
import { annotationsToJSON } from "annota";
const json = annotationsToJSON(annotations);
import { loadPgmFile } from "annota";
const annotations = loadPgmFile(pgmData, {
threshold: 128,
});
import { loadPgmPolygons } from "annota";
const polygons = loadPgmPolygons(pgmData, {
threshold: 128,
});
import { annotationsToPgm } from "annota";
const pgmData = annotationsToPgm(annotations, width, height);