Code Monkey home page Code Monkey logo

nocodeseg's Introduction

License Paper video Downloads Open In Colab

NoCodeSeg: Deep segmentation made easy!

⚠️Latest: Generic multiclass support has been added to the pipeline!

This is the official repository for the manuscript "Code-free development and deployment of deep segmentation models for digital pathology", published open access in Frontiers in Medicine.

The repository contains trained deep models for epithelium segmentation of HE and CD3 immunostained WSIs, as well as source code relevant for importing/exporting annotations/predictions in QuPath, both from DeepMIB and FastPathology.

All relevant scripts for working with our pipeline can be found in the source directory.

See here for how to access the trained models.

See here for how to download the 251 annotated WSIs.

Watch the video.

A video tutorial of the proposed pipeline was published on YouTube. It demonstrates the steps for:

  • Downloading and installing the software
  • QuPath
    • Create a project, then export annotations as patches with label files
    • Export patches from unannotated images for prediction in DeepMIB
    • (later) Import predictions for MIB and FastPathology as annotations
  • MIB
    • Use the annotated patches/labels exported from QuPath
    • Configuring and training deep segmentation models (i.e. U-Net/SegNet)
    • Use the trained U-Net to predict unannotated patches exported from QuPath
    • Export trained models into the ONNX format for use in FastPathology
  • FastPathology
    • Importing and creating a configuration file for the DeepMIB exported ONNX model
    • Create a project and load WSIs into a project
    • Use the U-Net ONNX model to render predictions on top of the WSI in real time
    • Export full sized WSI tiffs for import into QuPath

Note that the version of FastPathology used in the demonstration was v0.2.0 (this exact version can be downloaded from here). The software is continuously in development, and features presented in the video are therefore prone to changes in the near future. To get information regarding changes and new releases, please, visit the FastPathology repository.

The 251 annotated WSIs are made openly available for anyone on DataverseNO. Alternatively, the data can be downloaded directly from Google Drive (click here to access the dataset). Information on how to cite the IBDColEpi dataset can be found on DataverseNO.

The annotations are stored as tiled, pyramidal TIFFs, which makes it easy to generate patches from the data without the need for any preprocessing. Reading these files and working with them to generate training data, is already described in the tutorial video above.

TL;DR: Load TIFF as annotations in QuPath using provided groovy script and exporting these as labelled tiles.

If you wish to use Python, the annotations can be read exactly the same way as regular WSIs (for instance using pyFAST).

I have made a Jupyter Notebook demonstrating how to do this here.

Alternatively, click the CoLab button to access the notebook: Open In Colab

Note that the trained models can only be used for academic purposes due to MIB's license. Trained model files (.mibDeep for MIB and .onnx for FastPathology) are made openly available on Google Drive. Simply download the file "trained-models.zip" and uncompress to get access the respective files.

  • Chiou et al., An immunohistochemical atlas of necroptotic pathway expression (2024), EMBO Molecular Medicine, https://doi.org/10.1038/s44321-024-00074-6
  • Alharbi et al., A Deep Learning–Based Approach to Estimate Paneth Cell Granule Area in Celiac Disease (2023), Arch Pathol Lab Med, https://doi.org/10.5858/arpa.2023-0074-OA
  • Mallén et al., Sex Differences in Glomerular Lesions, in Atherosclerosis Progression, and in the Response to Angiotensin-Converting Enzyme Inhibitors in the ApoE−/− Mice Model (2023), International Journal of Molecular Science, https://doi.org/10.3390/ijms241713442
  • Røyset et al., Deep learning-based image analysis reveals significant differences in the number and distribution of mucosal CD3 and γδ T cells between Crohn's disease and ulcerative colitis, The Journal of Pathology, https://doi.org/10.1002/cjp2.301
  • Pettersen et al., Code-free development and deployment of deep segmentation models for digital pathology (2022), Frontiers in Medicine, https://doi.org/10.3389/fmed.2021.816281

Please, consider citing our paper, if you find the work useful:

@article{pettersen2022codefree,
    title={{Code-Free Development and Deployment of Deep Segmentation Models for Digital Pathology}},
    author={Pettersen, Henrik Sahlin and Belevich, Ilya and Røyset, Elin Synnøve and Smistad, Erik and Simpson, Melanie Rae and Jokitalo, Eija and Reinertsen, Ingerid and Bakke, Ingunn and Pedersen, André},         
    journal={Frontiers in Medicine},      
    volume={8},      
    year={2022},      
    url={https://www.frontiersin.org/article/10.3389/fmed.2021.816281},       
    doi={10.3389/fmed.2021.816281},      
    issn={2296-858X}
}

In addition, if you used the data set in your work, please, cite the following:

@data{pettersen2021ibdcolepi,
    title = {{140 HE and 111 CD3-stained colon biopsies of active and inactivate inflammatory bowel disease with epithelium annotated: the IBDColEpi dataset}},
    author = {Pettersen, Henrik Sahlin and Belevich, Ilya and Røyset, Elin Synnøve and Smistad, Erik and Jokitalo, Eija and Reinertsen, Ingerid and Bakke, Ingunn and Pedersen, André},
    publisher = {DataverseNO},
    year = {2021},
    version = {V2},
    doi = {10.18710/TLA01U},
    url = {https://doi.org/10.18710/TLA01U}
}

We wish to give our praise to Peter Bankhead and the QuPath team for their continuous support and assistance with QuPath and for assisting us in developing the scripts related to this study.

nocodeseg's People

Contributors

andreped avatar cavenel avatar pr4deepr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nocodeseg's Issues

Add instructions on how to run WSI-level predictions

As our TileImporter script does not support multi-class, the alternative method is to run predictions on WSI level.

This requires you to do something slightly different when running predictions from what was done in the tutorial video.

However, I don't see that there is any documentations for this. This should be added to assist users.

generic multi-class support?

The current importTiles script does not seem to support importing patches of multiple labels. This one is quite annoying to add multi-class support for, but is something we could try to do early next week? Let us schedule a session.

There have been implemented multi-class variants for the other scripts (i.e., exportTiles and importPyramidalTIFF), but these have not been tested in various scenarios. Currently, these are split into separate scripts; one for single-class and one for multi-class, but I think the multi-class scripts might actually handle the single-class situation as well. Could you run some checks in your pipeline to see if the multi-class scripts are sufficient?

CI occationally fails

Describe the bug
We are updating the dataverseNO repo download count badge once a week in this workflow.

Occationally, the CI seems to crash. IT seems to fail when running the command sudo apt install wkhtmltopd.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Ubuntu
  • Version [e.g. 22] 20.04

Export Tiles from QuPath with multiple classes

First some context: I am attempting to obtain multi-class segmentation of cerebellum tissue with different cellular layers corresponding to separate classes. I have annotated four classes: 'EGL', 'Molecular layer', 'IGL', and 'WM' on QuPath. I tested export tiles with multiple classes from QuPath using two the two different scripts available. Here are the issues I am having with both:

  1. The script by @andreped is giving me an error:

ERROR: MissingMethodException at line 61: No signature of method: qupath.lib.images.writers.TileExporter.labeledServer() is applicable for argument types: (qupath.lib.images.servers.LabeledImageServer$Builder) values: [qupath.lib.images.servers.LabeledImageServer$Builder@7bf3c609]
Possible solutions: labeledServer(qupath.lib.images.servers.ImageServer)

ERROR: org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
Script16.run(Script16.groovy:62)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:982)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:914)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:829)
qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1345)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.base/java.util.concurrent.FutureTask.run(Unknown Source)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.base/java.lang.Thread.run(Unknown Source)

  1. The script by @pr4deepr is yielding what I need (see below), however, many of the tiles are just background. Is there a way to incorporate the glassthreshold in the script by @andreped to avoid the tiles with too much background? Additionally, in order to get this script to work, I had to edit this line to .multichannelOutput(false).

20211026_Javid_01Image_01 vsi - 20x  d=5 79044,x=10376,y=36318,w=2965,h=2964

Create model multiple classes

Hi @andreped

Thanks for this great software and workflow.
I would like to generate a model which classifies the epithelia in the colon from WSIs into villi (usually at the boundary) and crypts (circular structures). Essentially, there would be 3 classes,

  • background
  • villi and
  • crypts

My plan is to use your models to generate annotations from my WSIs, import into QuPath, correct them, and then split annotations into different classes.

How do I configure image export for 3 different classes from QuPath, train in MIB and then run on FastPathology?

Is it possible to do this and is this a good workflow idea?

Cheers
Pradeep

Download count is not updating

Currently, the current download count in the download shield is fixed.

That is because there was no easy way to catch the current count through markdown.

I attempted to create a JS and Python solution for doing that, which were to be run periodically through github actions, but that would result in lots of redundant commits, that are not relevant for the user.

I'll have it fixed until I have time to come up with a better solution.

Network and config files

Hi Andre,
Would it be possible to share the .mibDeep and .migCfg files for the H&E epithelium model?
Thank you!

Import tiles script QuPath

Hi @andreped
When I try the import pyramidal tiff script to improve annotations generated by FastPathology, the annotations are smaller by 4 times compared to the WSI. I can't enter a value to control for downsample in the new script anymore. It looks like the script has been updated compared to the on in the video I've reused the old version of the script to import annotations for now .

Cheers
Pradeep

Multi-class tile import?

The current tileImport script does not support multiclass tiles, that is produced prediction tiles generated from MIB by a trained multi-class model.

It is possible to import predictions from MIB to QuPath by predicting on the full WSI in MIB which produces a stitched prediction image, which can be imported in QuPath using the importStitchedTIFfromMIBscript, similarly as done for FastPathology. And therefore, for the full pipeline a tile importer is not critical for using our pipeline.

However, there are scenarios where having a tile importer is beneficial over the other alternative, for instance if one only wishes to run prediction on a smaller region of the WSI (based on segmentations in QuPath) - which can be especially helpful if the image is extremely large. This can make inference a lot faster.

It is possible to do such a workflow in FastPathology, given that you provide the region of interest to run inference on. However, no such method has been made easily accessible. It would also require annotations or a model that can produce these ROI segmentation to use as a preprocessing step for the next patch-wise model.

Therefore, having multi-class support for the tile importer could be a valuable feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.