Paquo API

QuPathProjects

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!)

QuPathPathClasses

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

QuPathPathClass

property name

the name of the class

Return type

str

property id

the unique identifier string of the class

Return type

str

property parent

the parent path class of this path class

Return type

Optional[QuPathPathClass]

property origin

the toplevel parent of this path class

Return type

QuPathPathClass

is_derived_from(parent_class)[source]

is this class derived from the parent_class

is_ancestor_of(child_class)[source]

is this class an ancestor of the child_class

property color

return the path color

Return type

Optional[QuPathColor]

property is_valid

check if the path class is valid

Return type

bool

property is_derived_class

check if the class is a derived path class

Return type

bool

QuPathProjectImageEntries

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.

Note

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

QuPathPathObjectHierarchy

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.

QuPathPathObjects

Annotations and detections are encapsulated via QuPathPathAnnotationObjects.

QuPathColor

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

is_valid()[source]

tests if a QuPathColor is valid

(there are currently no validation checks performed on __init__)

Return type

bool

to_rgb()[source]

convert to 3 * uint8 rgb tuple

Return type

Tuple[int, int, int]

to_rgba()[source]

convert to 4 * uint8 rgba tuple

Return type

Tuple[int, int, int, int]

to_mpl_rgba()[source]

convert to 4 * float rgba tuple (mpl compatible)

Return type

Tuple[float, float, float, float]

to_hex()[source]

convert to hex color. loses alpha.

Return type

str

classmethod from_hex(hex_color)[source]

convert from hex_color

Return type

QuPathColor

to_java_rgb()[source]

“convert to the java rgb integer representation used by qupath

Return type

_JClass

classmethod from_java_rgb(java_rgb)[source]

convert from java but ignore the alpha value in java_rgb

Return type

QuPathColor

to_java_rgba()[source]

“convert to the java argb integer representation used by qupath

Return type

_JClass

classmethod from_java_rgba(java_rgba)[source]

converts a java integer color into a QuPathColor instance

Return type

QuPathColor

classmethod from_any(value)[source]

try creating a QuPathColor from all supported types

Return type

QuPathColor

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! 💖