insitupy.io.read_qupath_project

insitupy.io.read_qupath_project#

insitupy.io.read_qupath_project(path, pixel_size=None, export_folder='insitupy', method_name='mIF')#

Load and process a full QuPath project directory into an InSituExperiment object.

This function scans a QuPath project directory for sample subfolders containing exported spatial data. Each sample is processed using read_qupath, and the resulting InSituData objects are aggregated into a single InSituExperiment instance.

Parameters:
  • path (Union[str, PathLike, Path]) – Path to the root directory of the QuPath project.

  • pixel_size (Optional[Number] (default: None)) – Pixel size used to scale coordinates from annotation geometry.

  • method_name (str (default: 'mIF')) – Name of the imaging method used. Defaults to multiplexed IF (“mIF”).

Returns:

An object containing all samples and modalities from the project.

Return type:

InSituExperiment

Raises:
  • FileNotFoundError – If any required files are missing in the sample directories.

  • ValueError – If any annotation file contains more than one geometry.

Notes

Each sample folder within the project directory is expected to follow the structure described in read_qupath, including:

  • annotation.geojson

  • measurements.tsv

  • cells.geojson

  • image.ome.tif

To generate data in the correct format from QuPath, use the following export script: SpatialPathology/InSituPy-QuPath

Example

>>> exp = read_qupath_project(
...     path="/data/qupath_project",
...     pixel_size=0.65
... )