Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
afrendeiro committed Oct 19, 2024
1 parent 06fb396 commit e17b7d0
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .readthedocs.yaml
version: 2
sphinx:
configuration: docs/source/conf.py
build:
os: ubuntu-22.04
apt_packages:
- openslide-tools
tools:
python: "3.10"
python:
install:
- method: pip
path: .[doc]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
WSI
====

[![Documentation Status](https://readthedocs.org/projects/wsi/badge/?version=stable&style=flat-square)](https://wsi.readthedocs.io/en/stable)


This is a fork of the repository from [Mahmood lab's CLAM repository](https://github.com/mahmoodlab/CLAM).
It is made available under the GPLv3 License and is available for non-commercial academic purposes.

Expand Down
24 changes: 24 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

clean:
rm -rf "$(BUILDDIR)"
rm -rf $(SOURCEDIR)/api/_autogen/*

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
API reference
---------------

.. currentmodule:: wsi

.. autoclass:: WholeSlideImage

.. automethod:: __init__

.. rubric:: Methods

.. autosummary::

~WholeSlideImage.__init__
~WholeSlideImage.get_thumbnail
~WholeSlideImage.segment
~WholeSlideImage.plot_segmentation
~WholeSlideImage.save_segmentation
~WholeSlideImage.load_segmentation
~WholeSlideImage.tile
~WholeSlideImage.plot_tile_graph
~WholeSlideImage.save_tile_images
~WholeSlideImage.has_tile_coords
~WholeSlideImage.has_tile_images
~WholeSlideImage.has_tissue_contours
~WholeSlideImage.get_tile_coordinate_level_size
~WholeSlideImage.get_tile_coordinates
~WholeSlideImage.get_tile_graph
~WholeSlideImage.get_tile_images
~WholeSlideImage.get_tile_polygons
~WholeSlideImage.get_tile_tissue_piece
~WholeSlideImage.inference
~WholeSlideImage.as_tile_bag
~WholeSlideImage.as_data_loader
~WholeSlideImage.as_torch_geometric_data
45 changes: 45 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from datetime import datetime

import wsi

project = "wsi"
copyright = f"{datetime.now().year}, Rendeiro Lab"
author = "wsi contributors"
release = wsi.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"numpydoc",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
]
autoclass_content = "class"
autodoc_docstring_signature = True
autodoc_default_options = {"members": None, "undoc-members": None}
autodoc_typehints = "none"
# setting autosummary
autosummary_generate = True
numpydoc_show_class_members = False
add_module_names = False

templates_path = ["_templates"]
exclude_patterns = []


html_theme = "pydata_sphinx_theme"
html_sidebars = {"installation": [], "api": []}
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5," r"8}: "
copybutton_prompt_is_regexp = True

# Plot directive
plot_include_source = True
plot_html_show_source_link = False
plot_html_show_formats = False
plot_formats = [("png", 200)]

intersphinx_mapping = {
"torch": ("https://pytorch.org/docs/stable/", None),
"torch_geometric": ("https://pytorch-geometric.readthedocs.io/en/stable/", None),
}
44 changes: 44 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
wsi
===

**wsi** is a Python library for processing whole slide images (WSI).

It is a simple library with an object-oriented interface where all operations are performed with a WholeSlideImage object.

It has the goal of doing basic processing of WSIs with reasonable defaults, but high customizability.

For example, to go from a slide remotely hosted to a torch geometric graph with ResNet50 features, the following lines suffice:

.. code-block:: python
from wsi import WholeSlideImage
slide = WholeSlideImage("https://brd.nci.nih.gov/brd/imagedownload/GTEX-O5YU-1426")
slide.segment()
slide.tile()
data = slide.as_torch_geometric_data(model_name='resnet50')
Head over to the `Installation <install.html>`_ and `API reference <api.html>`_ pages to learn more.


.. toctree::
:maxdepth: 1
:hidden:

install
api


.. grid:: 1 2 2 2
:gutter: 2

.. grid-item-card:: Installation
:link: install
:link-type: doc

Instructions for installation

.. grid-item-card:: API
:link: api
:link-type: doc

API documentation
21 changes: 21 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Installation
============

To install the package from the GitHub repository, follow the steps below.

1. Ensure you have Python 3.10 or higher installed.
2. Install the package using `pip` by running the following command:

.. code-block:: bash
pip install git+https://github.com/rendeirolab/wsi.git
3. Verify that the package is correctly installed by importing it in Python:

.. code-block:: python
import wsi
If the installation was successful, you should not encounter any errors.

For further details, please visit our `GitHub repository <https://github.com/rendeirolab/wsi>`_.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ doc = [
"Sphinx",
"sphinx-issues",
"sphinx-rtd-theme",
"sphinx-autodoc-typehints"
"sphinx-autodoc-typehints",
"pydata-sphinx-theme",
"numpydoc",
]

[project.urls]
Expand Down

0 comments on commit e17b7d0

Please sign in to comment.