PAthological QUpath Obsession - QuPath and Python conversations

Overview

PAQUO: PAthological QUpath Obsession

PyPI Version Read the Docs GitHub Workflow Status Codecov PyPI - Python Version GitHub issues

Welcome to paquo 👋 , a library for interacting with QuPath from Python.

paquo's goal is to provide a pythonic interface to important features of QuPath, and to make creating and working with QuPath projects intuitive for Python programmers.

We strive to make your lives as easy as possible: If paquo is not pythonic, unintuitive, slow or if its documentation is confusing, it's a bug in paquo. Feel free to report any issues or feature requests in the issue tracker!

Development happens on github :octocat:

Documentation

You can find paquo's documentation at paquo.readthedocs.io ❤️

Development Installation

  1. Install conda and git
  2. Clone paquo git clone https://github.com/bayer-science-for-a-better-life/paquo.git
  3. Run conda env create -f environment.yaml
  4. Activate the environment conda activate paquo

Note that in this environment paquo is already installed in development mode, so go ahead and hack.

Contributing Guidelines

  • Please follow pep-8 conventions but:
    • We allow 120 character long lines (try anyway to keep them short)
  • Please use numpy docstrings.
  • When contributing code, please try to use Pull Requests.
  • tests go hand in hand with modules on tests packages at the same level. We use pytest.

You can setup your IDE to help you adhering to these guidelines.
(Santi is happy to help you setting up pycharm in 5 minutes)

Acknowledgements

Build with love by Andreas Poehlmann and Santi Villalba from the Machine Learning Research group at Bayer. In collaboration with the Pathology Lab 2 and the Mechanistic and Toxicologic Pathology group.

paquo: copyright 2020 Bayer AG, licensed under GPL-3.0

Comments
  • Adding image on Windows network share fails:

    Adding image on Windows network share fails: "java.lang.IllegalArgumentException: URI has an authority component"

    Hello Paquo team,

    First, thank you very much for your work on this piece of software!

    When I use add_image with a new project, and the image is located on a Windows share, I am getting java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: URI has an authority component. This is the case when the file name is of any of the following forms:

    • //example/path/to subdirectory/image.png
    • M:/path/to subdirectory/image.png (i.e., using a network drive mapping instead)
    • file:/M:/path/to subdirectory/image.png

    (If I use file:///example/path/to subdirectory/image.png), I get a different error, FileNotFoundError: image_provider can't provide URI for requested image_id.

    To confirm, is this expected? Should I be using a different approach to adding images on a network share?

    I am using Paquo v0.4.0 with QuPath v0.2.3, Python v3.8.12, and Windows 10.

    with QuPathProject('//example/path/to project directory', mode="a") as project:  # This works.
        tile = project.add_image(
                    '//example/path/to subdirectory/image.png',  # This raises the above error.
                    image_type=QuPathImageType.BRIGHTFIELD_H_E,
                )
    

    The full traceback:

    Exception                                 Traceback (most recent call last)
    ~\Miniconda3\envs\example\lib\site-packages\_jpype.cp38-win_amd64.pyd in qupath.lib.images.servers.ImageServerProvider.getPreferredUriImageSupport()
    
    ~\Miniconda3\envs\example\lib\site-packages\_jpype.cp38-win_amd64.pyd in qupath.lib.images.servers.ImageServerProvider.getServerBuilders()
    
    ~\Miniconda3\envs\example\lib\site-packages\_jpype.cp38-win_amd64.pyd in java.io.File.<init>()
    
    Exception: Java Exception
    
    The above exception was the direct cause of the following exception:
    
    java.lang.IllegalArgumentException        Traceback (most recent call last)
    l:\home\path\to\qupath.py in <module>
    ----> 175 tile = project.add_image(
          176     '//example/path/to subdirectory/image.png',
          177     # image_type=QuPathImageType.BRIGHTFIELD_H_E,
          178 )
          179 
    
    ~\Miniconda3\envs\example\lib\contextlib.py in inner(*args, **kwds)
         73         def inner(*args, **kwds):
         74             with self._recreate_cm():
    ---> 75                 return func(*args, **kwds)
         76         return inner
         77 
    
    ~\Miniconda3\envs\example\lib\site-packages\paquo\projects.py in add_image(self, image_id, image_type, allow_duplicates)
        302         # first get a server builder
        303         try:
    --> 304             support = ImageServerProvider.getPreferredUriImageSupport(
        305                 BufferedImage,
        306                 String(str(img_uri))
    
    java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: URI has an authority component
    

    I would be grateful for any advice. Thank you again!

    bug 
    opened by jglev 23
  • Installation on Windows 10: Error by the Java Runtime Environment

    Installation on Windows 10: Error by the Java Runtime Environment

    Hello, I am struggeling with the proper installation of Paquo, Following error is always shown as soon as I import paquo to a python script:

    A fatal error has been detected by the Java Runtime Environment:

    EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000000000000, pid=5276, tid=11108

    JRE version: (16.0.2+7) (build ) Java VM: OpenJDK 64-Bit Server VM (16.0.2+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64) Problematic frame: C 0x0000000000000000

    No core dump will be written. Minidumps are not enabled by default on client versions of Windows

    This is my current operating system:

    • Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz, 6 cores, 15G, Windows 10 , 64 bit Build 17763 (10.0.17763.2300)
    • Python 3.8.12

    I installed Paquo using pip install paquo and placed the ".paquo.toml" file including the path to my QuPath directory in one directory which was listed as possible locations.

    Does one know how to debug my installation? Thanks, Hannes

    bug 
    opened by roxhannes 15
  • Glib error when accessing images

    Glib error when accessing images

    Hello, when I try to access an image I get an GLib error that crashes the program.

    qp = paquo.projects.QuPathProject("./qp/project.qpproj")
    img = qp.images[0]
    

    This produces the output: (process:14712): GLib-GObject-CRITICAL **: 11:20:36.970: _g_enum_types_init: assertion 'initialized == FALSE' failed (process:14712): GLib-GObject-CRITICAL **: 11:20:36.970: _g_object_type_init: assertion 'initialized == FALSE' failed

    I am running Linux. I was unable to fix this so far. Does someone have an idea what could cause this?

    opened by LeoMH 8
  • Display and manage heatmaps

    Display and manage heatmaps

    This requires both:

    • [x] ~verbatim display~
    • [x] ~converting into polygons~

    We're using Tiles (PathDetectionObjects) to display heatmaps for now. See https://forum.image.sc/t/best-way-to-display-additional-information-as-overlay/40901/6 for more information

    enhancement 
    opened by ap-- 8
  • add_image() for multi-scene images

    add_image() for multi-scene images

    Issue

    Some image files like .czi files and .vsi files hold multiple scenes. For .czi files this can be multiple regions imaged on a slide, while for .vsi files this can be an overview image (scene 1) + the full pyramidal image (scene 2). When images are added to a project with the QuPath GUI with add images, all scenes are loaded. But when loaded through Paquo with qp.add_image(), only the first scene is loaded.

    Expected behaviour

    qp.add_image() loads all scenes from an image file, or at least gives the option to specifiy which scene is loaded

    Context

    This was mentioned on https://forum.image.sc/t/paquo-read-write-qupath-projects-from-python/41892/29?u=merrick but I don't think raised as a github issue so I raise it here myself

    bug 
    opened by mezwick 7
  • Generate docs

    Generate docs

    This can wait until just before we have the first paquo release.

    We could generate docs via sphinx or something else. Is there any strong preference?

    And should these be hosted on gh-pages or readthedocs or ...?

    documentation 
    opened by ap-- 5
  • Add possibility to remove image from QuPath project

    Add possibility to remove image from QuPath project

    Draft of pull request related to #78.

    Some time ago I implemented the possibility to remove an image from a QuPath project, although now I noticed that it is no longer working properly. In any case, maybe you can provide some feedback so I can figure out what I am doing wrong.

    Points for review:

    • Calling project.java_object.removeImage(image_entry_to_be_removed.java_object, True) used to do the job, but now when I call that method the image is not deleted correctly. Instead, if I open the project in QuPath after "deleting" an image, I see that its thumbnail is gone (see attached screenshot), and when I click on it QuPath asks me to set the image type (as if the image was never opened before).

    Screen Shot 2022-11-08 at 14 38 31

    • Currently, the new project.remove_image method takes an image path as input and checks if it is indeed part of the project. Not sure if it makes more sense to pass the entry_id of the image to be deleted instead. If we pass the path, then we should also handle possible duplicates in the project (currently only the first instance with a given path is removed)
    opened by abailoni 4
  • Access detections by index

    Access detections by index

    Really cool project!

    I had a quick question that I suspect you know the answer to.

    If I know exactly the detection I want to access, is there a way to get to it?

    >>> type(qpitem.hierarchy.detections)
    paquo.hierarchy._PathObjectSetProxy
    
    
    >>>qpitem.hierarchy.detections
    QuPathPathDetectionObjectSet(n=40865)
    
    >>>qpitem.hierarchy.detections[1]
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-58-ee8b4cffc9d4> in <module>
    ----> 1 qpitem.hierarchy.detections[1]
    
    TypeError: '_PathObjectSetProxy' object is not subscriptable
    

    I'm thinking about the case of where I know which subset of 1,000 detections i want inside of a list of 40,000

    I could instantiate the entire list, or use something like this: https://stackoverflow.com/questions/2300756/get-the-nth-item-of-a-generator-in-python

    But was wondering if there was something more elegant you were thinking?

    Thanks

    enhancement 
    opened by choosehappy 4
  • Provide simple way to configure paquo's settings

    Provide simple way to configure paquo's settings

    we need to decide what's nicest for the user.

    Best would probably be to auto discover in the default installation paths for qupath, and then verify if the qupath version is compatible.

    override could be done via envvar and/or provide some pre java import interface to set the path: (possible way this could be implemented --- it's not yet)

    import paquo
    paquo.cue_qupath_path("~/my_custom_qupath_installation")  # :P
    
    from paquo.projects import QuPathProject
    ...
    
    enhancement 
    opened by ap-- 4
  • paquo's naming convention for java and python

    paquo's naming convention for java and python

    We want to be internally consistent in paquo so that it's immediately clear which parts access the java world and which parts are native to the python world.

    Toplevel options are all combinations of prefixing or not prefixing Java classes and Python classes.

    Examples could be:

    • Java classes get prefixed with "J", python wrapper classes get the original name (java: JPathClass and py: PathClass)
    • Java classes keep their names, python wrapper classes get a prefix (java: PathClass and py: QuPathPathClass)
    • both get prefixed (java: JPathClass, py: QuPathPathClass)

    Note: maybe "Paquo" might be a prefix for python classes that keeps better readability (PaquoPathClass vs QuPathPathClass)

    I have no strong opinion. As long as we stay consistent. 😃

    opened by ap-- 4
  • Decide on versioning schema

    Decide on versioning schema

    I do not know how well this would work with setuptools_scm, but should we try to sync with the qupath version we are targeting? e.g. since now we are developing against 0.2.1, should we have our version be 0.2.1-something as well?

    opened by sdvillal 4
  • Example to show how to add annotations as children of other annotations

    Example to show how to add annotations as children of other annotations

    Hi, I would like to know if there is a way I can use Paquo to add annotations as children of other annotations as described here: https://qupath.readthedocs.io/en/stable/docs/concepts/object_hierarchy.html

    The documentation does a good job of explaining how to add annotations as children of the image root (all having the same level in the hierarchy). It would be great to have a way to add annotations while specifying the parent that they belong to, as seen in the image below: Screen Shot 2022-09-16 at 4 07 56 PM

    question 
    opened by Mena-SA-Kamel 2
  • Getting Current Qupath Program

    Getting Current Qupath Program

    Hi,

    Really excellent work with this, just a quick question. Is there an easy way to get the file path of the QuPath Program directory that is being used in the paquo environment??

    Hope this makes sense, Many thanks

    question 
    opened by HistoCleanQUB 4
  • Importing QuPathProject taking up >100GB memory

    Importing QuPathProject taking up >100GB memory

    I am trying to use paquo on a linux cluster. I login to a node with 200GB of memory.

    Once on the node I use tmux to open two terminals on the same node. In one of the terminals I activate a conda environment and open up a python window and run

    import os
    os.getpid()
    

    I then go to my other window and run

    top -p <my_pid>

    which, as I understand it, allows me to see how much memory I am using. At this point it shows 134060 under VIRT.

    In the python window I then run

    from paquo.projects import QuPathProject
    

    and then it shows 102.7g under VIRT. As I understand it, this means the QuPathProject object is currently using 102.7GB of memory. This is then giving me errors further down in my pipeline where I try and do much smaller operations but I don't have any memory left.

    Here is my conda environment environment(1).txt

    bug 
    opened by hwarden162 8
  • Support writing annotations as segmentation mask

    Support writing annotations as segmentation mask

    See this post on image.sc

    We could expose this functionality for the PathObjectHierarchy. We already support to_geojson and to_ome_xml. Could maybe offer to_image or to_segmentation_mask.

    enhancement 
    opened by ap-- 0
  • Slide tile generation

    Slide tile generation

    Hi paquo team. I wondered whether it would be useful to extend paquo's functionality by, e.g. option to create .jpeg/.png tiles from slides. This summer, I finished one medical image segmentation/classification deep learning project, so I could implement such functionality in the fork.

    I would use OpenSlide, though, which creates an additional dependency.

    Are you interested?

    opened by RhDm 6
Owner
Bayer AG
Science for a better life
Bayer AG
This repo contains the code and data used in the paper "Wizard of Search Engine: Access to Information Through Conversations with Search Engines"

Wizard of Search Engine: Access to Information Through Conversations with Search Engines by Pengjie Ren, Zhongkun Liu, Xiaomeng Song, Hongtao Tian, Zh

null 19 Oct 27, 2022
Official repository for "Action-Based Conversations Dataset: A Corpus for Building More In-Depth Task-Oriented Dialogue Systems"

Action-Based Conversations Dataset (ABCD) This respository contains the code and data for ABCD (Chen et al., 2021) Introduction Whereas existing goal-

ASAPP Research 49 Oct 9, 2022
DSTC10 Track 2 - Knowledge-grounded Task-oriented Dialogue Modeling on Spoken Conversations

DSTC10 Track 2 - Knowledge-grounded Task-oriented Dialogue Modeling on Spoken Conversations This repository contains the data, scripts and baseline co

Alexa 51 Dec 17, 2022
Code for SIMMC 2.0: A Task-oriented Dialog Dataset for Immersive Multimodal Conversations

The Second Situated Interactive MultiModal Conversations (SIMMC 2.0) Challenge 2021 Welcome to the Second Situated Interactive Multimodal Conversation

Facebook Research 81 Nov 22, 2022
Source code for our paper "Improving Empathetic Response Generation by Recognizing Emotion Cause in Conversations"

Source code for our paper "Improving Empathetic Response Generation by Recognizing Emotion Cause in Conversations" this repository is maintained by bo

Yuhan Liu 24 Nov 29, 2022
This repo contains implementation of different architectures for emotion recognition in conversations.

Emotion Recognition in Conversations Updates ?? ?? ?? Date Announcements 03/08/2021 ?? ?? We have released a new dataset M2H2: A Multimodal Multiparty

Deep Cognition and Language Research (DeCLaRe) Lab 1k Dec 30, 2022
Python-experiments - A Repository which contains python scripts to automate things and make your life easier with python

Python Experiments A Repository which contains python scripts to automate things

Vivek Kumar Singh 11 Sep 25, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 23.6k Dec 31, 2022
Python Library for learning (Structure and Parameter) and inference (Statistical and Causal) in Bayesian Networks.

pgmpy pgmpy is a python library for working with Probabilistic Graphical Models. Documentation and list of algorithms supported is at our official sit

pgmpy 2.2k Jan 3, 2023
High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.

What is xLearn? xLearn is a high performance, easy-to-use, and scalable machine learning package that contains linear model (LR), factorization machin

Chao Ma 3k Jan 3, 2023
This repository is related to an Arabic tutorial, within the tutorial we discuss the common data structure and algorithms and their worst and best case for each, then implement the code using Python.

Data Structure and Algorithms with Python This repository is related to the Arabic tutorial here, within the tutorial we discuss the common data struc

Mohamed Ayman 33 Dec 2, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 20.6k Feb 13, 2021
High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.

What is xLearn? xLearn is a high performance, easy-to-use, and scalable machine learning package that contains linear model (LR), factorization machin

Chao Ma 2.8k Feb 12, 2021
All the essential resources and template code needed to understand and practice data structures and algorithms in python with few small projects to demonstrate their practical application.

Data Structures and Algorithms Python INDEX 1. Resources - Books Data Structures - Reema Thareja competitiveCoding Big-O Cheat Sheet DAA Syllabus Inte

Shushrut Kumar 129 Dec 15, 2022