Paquo API


Paquo’s most used class is the QuPathProject. Through it you’re accessing images, annotation, metadata and everything that QuPath has to offer (😅 let us know if something’s missing!)

class paquo.projects.QuPathProject(path, mode='r', *, image_provider=<paquo.images.ImageProvider object>)[source]
property images: Sequence[QuPathProjectImageEntry]

project images

add_image(image_id, image_type=None, *, allow_duplicates=False, return_list=False)[source]

add an image to the project

  • image_id (Union[str, Path]) – image_id pointing to the image file (with default image_provider: filename)

  • image_type (Optional[QuPathImageType]) – provide an image type for the image. If not provided the user will be prompted before opening the image in QuPath.

  • allow_duplicates (bool) – check if file has already been added to the project.

Return type:

Union[QuPathProjectImageEntry, List[QuPathProjectImageEntry]]


verify if images are reachable

Return type:

Dict[str, bool]

update_image_paths(*, try_relative=False, **rebase_kwargs)[source]

update image path uris if image files moved

  • try_relative (bool) – if try_relative is True, update_image_paths tries to use relative paths to resolve missing image entries. This is useful in case you move the the project together with its images directory, or in case you remount at a different location.

  • **rebase_kwargs – keyword arguments are handed over to the image provider instance. The default image provider is a paquo.images.ImageProvider which uses the uri2uri keyword argument. (A mapping from old URI to new URI: Mapping[str, str])

Return type:



Delete an image from the QuPath project.


image_entry (Union[QuPathProjectImageEntry, int]) – the image entry to be removed

Return type:


property uri: str

the uri identifying the project location

property path_classes: Tuple[QuPathPathClass, ...]

return path_classes stored in the project

property path: Path

the path to the project root


flush changes in the project to disk

(writes path_classes and project data)

Return type:


property name: str

project name

property timestamp_creation: int

system time at creation in milliseconds

property timestamp_modification: int

system time at modification in milliseconds

property version: str | None

the project version. should be identical to the qupath version


Classes are used to group your annotation into (you’ve guessed it) classes. QuPathPathClasses can have names, a color and they can be children of other classes. If you want to create a new QuPathPathClass just instantiate it by providing a name and an optional color and optional parent class.

class paquo.classes.QuPathPathClass(name, color=None, parent=None, **_kwargs)[source]
classmethod from_java(path_class)[source]

initialize a QuPathPathClass from its corresponding java PathClass

Return type:


property name: str

the name of the class

property id: str

the unique identifier string of the class

property parent: QuPathPathClass | None

the parent path class of this path class

property origin: QuPathPathClass

the toplevel parent of this path class


is this class derived from the parent_class


is this class an ancestor of the child_class

property color: QuPathColor | None

return the path color

property is_valid: bool

check if the path class is valid

property is_derived_class: bool

check if the class is a derived path class


Images in paquo cannot exist on their own and are always bound to a QuPathProject. You access them via QuPathProject.images() or you make a new one from a file via QuPathProject.add_image(). Images let you set a description, provide you with interfaces for metadata and properties and give you access to the various QuPath annotation and detections objects through the QuPathPathObjectHierarchy.

class paquo.images.QuPathProjectImageEntry(entry, *, _project_ref=None)[source]
property entry_id: str

the unique image entry id

property entry_path: Path

path to the image directory

property image_name: str

the image entry name

property image_type: QuPathImageType

image type

property description: str

free text describing the image

property width

image width in pixels

property height

image height in pixels

property num_channels

number of channels in the image

property num_z_slices

number of z_slices in the image

property num_timepoints

number of time points in the image

property downsample_levels: List[Dict[str, float]]

downsample levels provided by the image


The available downsample levels can differ dependent on which image backend is used by QuPath

property metadata: _ProjectImageEntryMetadata

the metadata stored on the image as dict-like proxy

property properties

the properties stored in the image data as a dict-like proxy

property hierarchy: QuPathPathObjectHierarchy

the image entry hierarchy. it contains all annotations

property uri

the image entry uri


check if the image file is readable

Return type:



check if image_data is changed


IOError – if image_data can’t be read

Return type:



save image entry

class paquo.images.QuPathImageType(value)[source]

Enum representing image types

BRIGHTFIELD_H_DAB = 'Brightfield (H-DAB)'
BRIGHTFIELD_H_E = 'Brightfield (H&E)'
BRIGHTFIELD_OTHER = 'Brightfield (other)'
FLUORESCENCE = 'Fluorescence'
OTHER = 'Other'
UNSET = 'Not set'


There’s an additional paquo.images.ImageProvider class which will be introduced when paquo settles on its implementation. See Paquo Issue #13.


The hierarchy is accessed via QuPathProjectImageEntry.hierarchy. It contains proxy objects that allow you to access annotations and detections, as well as importing and exporting them to geojson.

class paquo.hierarchy.QuPathPathObjectHierarchy(hierarchy=None, *, readonly=False, image_name='N/A', autoflush=True)[source]
property is_empty: bool

a hierarchy is empty if it only contains the root object


prevent updates to the hierarchy to trigger an internal update event


flush changes to the hierarchy

property root: QuPathPathAnnotationObject

the hierarchy root node

This object has no roi and cannot be assigned another class. All other objects are descendants of this object if they are attached to this hierarchy.

property annotations: PathObjectProxy[QuPathPathAnnotationObject]

all annotations provided as a flattened set-like proxy

add_annotation(roi, path_class=None, measurements=None, *, path_class_probability=nan)[source]

convenience method for adding annotations

Return type:


property detections: PathObjectProxy[QuPathPathDetectionObject]

all detections provided as a flattened set-like proxy

add_tile(roi, path_class=None, measurements=None, *, path_class_probability=nan)[source]

convenience method for adding tile detections

Return type:



these will be added to self.detections


return all annotations as a list of geojson features

Return type:


load_geojson(geojson, *, raise_on_skip=False, fix_invalid=False)[source]

load annotations into this hierarchy from a geojson list

returns True if new objects were added, False otherwise.

Return type:


to_ome_xml(prefix='paquo', fill_alpha=0.0)[source]

return all annotations in ome xml format

Return type:



Annotations and detections are encapsulated via QuPathPathAnnotationObjects.

class paquo.pathobjects._PathROIObject(java_object, *, update_callback=None)[source]

internal base class for PathObjects

classmethod from_shapely(roi, path_class=None, measurements=None, *, path_class_probability=nan)[source]

create a Path Object from a shapely shape

  • roi (BaseGeometry) – a shapely shape as the region of interest of the annotation

  • path_class (Optional[QuPathPathClass]) – a paquo QuPathPathClass to mark the annotation type

  • measurements (Optional[dict]) – dict holding static measurements for annotation object

  • path_class_probability (float) – keyword only argument defining the probability of the class (default NaN)

Return type:

TypeVar(PathROIObjectType, bound= _PathROIObject)

classmethod from_geojson(geojson)[source]

create a new Path Object from geojson

Return type:

TypeVar(PathROIObjectType, bound= _PathROIObject)


convert the annotation object to geojson

Return type:


property path_class: QuPathPathClass | None

the annotation path class

property path_class_probability: float

the annotation path class probability

update_path_class(pc, probability=nan)[source]

updating the class or probability has to be done via this method

Return type:


property locked: bool

lock state of the annotation

property is_editable: bool

can the annotation be edited in the qupath UI

property level: int

the annotation’s level

property name: str | None

an optional name for the annotation

property parent: PathROIObjectType | None

the annotation object’s parent annotation object

property roi: BaseGeometry

the roi as a shapely shape


update the roi of the annotation

Return type:


class paquo.pathobjects.QuPathPathAnnotationObject(java_object, *, update_callback=None)[source]

Bases: _PathROIObject


an optional description for the annotation

class paquo.pathobjects.QuPathPathDetectionObject(java_object, *, update_callback=None)[source]

Bases: _PathROIObject

class paquo.pathobjects.QuPathPathTileObject(java_object, *, update_callback=None)[source]

Bases: QuPathPathDetectionObject


Colors in QuPath are represented as non-human-friendly integers. QuPathColor provides a nicer interface to allow more intuitive color handling.

class paquo.colors.QuPathColor(red: int, green: int, blue: int, alpha: int = 255)[source]

color representation in paquo

>>> c = QuPathColor(128, 128, 160, alpha=240)
red: int

Alias for field number 0

green: int

Alias for field number 1

blue: int

Alias for field number 2

alpha: int

Alias for field number 3


tests if a QuPathColor is valid

(there are currently no validation checks performed on __init__)

Return type:



convert to 3 * uint8 rgb tuple

Return type:

Tuple[int, int, int]


convert to 4 * uint8 rgba tuple

Return type:

Tuple[int, int, int, int]


convert to 4 * float rgba tuple (mpl compatible)

Return type:

Tuple[float, float, float, float]


convert to hex color. loses alpha.

Return type:


classmethod from_hex(hex_color)[source]

convert from hex_color

Return type:



“convert to the java rgb integer representation used by qupath

Return type:


classmethod from_java_rgb(java_rgb)[source]

convert from java but ignore the alpha value in java_rgb

Return type:



“convert to the java argb integer representation used by qupath

Return type:


classmethod from_java_rgba(java_rgba)[source]

converts a java integer color into a QuPathColor instance

Return type:


classmethod from_any(value)[source]

try creating a QuPathColor from all supported types

Return type:


And more…

If anything is not documented and you would love to know more about it, open an issue and let us know! We’re happy to provide more documentation and clear things up! 💖