qupath_to_domain#

qupath_to_domain(qupath_json_file, domain_name='a_qupath_domain', add_cells_as_points=True, pixel_size=[1, 1], properties_to_ignore=['isLocked', 'objectType', 'color'], specific_properties_as_labels=[], simplify_shapes=False, simplify_shapes_kwargs={'algorithm': 'Visvalingam-Whyatt', 'epsilon': 10}, print_summary=True)#

Import a QuPath GeoJSON file to a muspan domain. All metadata from the GeoJSON file is added as labels to the domain object. Only scalar and categorical metadata is supported.

Parameters:
qupath_json_filestr

Path to the QuPath GeoJSON file.

domain_namestr, optional

Name of the domain, by default ‘a_qupath_domain’.

add_cells_as_pointsbool, optional

Whether to add cells as points, by default True.

pixel_sizelist, optional

Pixel size for scaling coordinates with x and y respectively, by default [1, 1].

properties_to_ignorelist, optional

List of properties to ignore, by default [‘isLocked’, ‘objectType’, ‘color’].

specific_properties_as_labelslist, optional

List of properties to be added as labels, by default [].

simplify_shapesbool, optional

Whether to simplify shapes, by default False.

simplify_shapes_kwargsdict, optional

Additional arguments for shape simplification, by default dict(algorithm=’Visvalingam-Whyatt’, epsilon=10).

print_summarybool, optional

If True, print a summary of the resulting domain, by default True.

Returns:
domainmuspan domain

The muspan domain created from the QuPath GeoJSON file.

Raises:
ValueError

If qupath_json_file is not a string or if the GeoJSON file does not contain the expected structure output by QuPath.

Notes

Important

MuSpAn shapes objects do not self-intersect. If the QuPath annotations contain self-intersecting shapes, these will need to be corrected in QuPath before export to GeoJSON to avoid errors when adding to the MuSpAn domain.

Tip

For annotation generated on a pixel-by-pixel basis (e.g. tissue segmentation), it is recommended to simplify the shapes within QuPath before exporting to GeoJSON to reduce computation cost in loading. This can be done by using the ‘Objects -> Annotation -> Simplify shape…’ function in QuPath.

Shape boundaries are simplified by default using the Visvalingam-Whyatt algorithm with an epsilon of 10. This can be disabled by setting simplify_shapes to False. See domain.simplify_shape_boundaries for more information.

Currently, line collections are not supported via import and will be ignored if present in the GeoJSON file.

If objects have multiple labels under the same property (e.g. name), only the first label will be added.