Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0ab3a0f
BLD/STY: Set up cli for command line interface
May 30, 2020
3a24650
BLD: Added slide information feature
May 31, 2020
3477f52
BLD: Add multiproc decorator for toolbox
Jun 1, 2020
6921300
STY: Run black for style formatting
Jun 1, 2020
c67d8b0
DOC: Add Docstring to multiproc.py
Jun 1, 2020
6a6845e
BUG: Update requirements_dev.txt to fix bugs with Travis
Jun 1, 2020
f7b0c0c
BUG: Update requirements_dev.txt to fix bugs opencv-python with Travis
Jun 1, 2020
7381339
BUG: Travis error fix setuptools
Jun 1, 2020
eb4a990
BUG: Travis error fix setuptools
Jun 1, 2020
f06b659
BUG: Fix Travis error History.rst
Jun 1, 2020
1ba8c42
BUG: Fix Travis libopenslide.so.0: error
Jun 1, 2020
02747bb
BUG: Update test_tiatoolbox.py to fix pytest errors
Jun 1, 2020
5f63b4a
BUG: FIX travis error for python3.8
Jun 2, 2020
34b9bd6
BUG: FIX travis error for python3.8
Jun 2, 2020
6f3ffaa
BUG: Fix Travis python 3.8 issue
Jun 2, 2020
68d2177
BUG: Fix Travis python 3.8 issue
Jun 2, 2020
6811a98
BUG: Fix Travis python 3.8 issue
Jun 2, 2020
ab43935
BUG: Roll back multiprocessing changes for python 3.8
Jun 2, 2020
045ef83
BUG: Fix Travis error for multiprocessing
Jun 2, 2020
a24e4a5
BUG: Fix Multiprocessing bug for python 3.8
Jun 2, 2020
e837fb7
BUG: Fix Multiprocessing bug for python 3.8
Jun 2, 2020
1285e6b
Merge branch 'develop' into feature-slide-info
shaneahmed Jun 2, 2020
abfa632
DOC: Update docstring test_tiatoolbox.py
Jun 2, 2020
eabf091
DOC: Update README
Jun 3, 2020
ee19869
DOC: Update README.rst
shaneahmed Jun 3, 2020
5b1c768
DEV: Add conda requirements file
Jun 3, 2020
3b78fc1
TST: Add test for version information
Jun 3, 2020
a70831d
DEP: Remove tiatoolbox_Structure.jpg
Jun 4, 2020
82cf63c
DOC: Update to README.rst according to address PR comments
Jun 4, 2020
60e7d69
DEV: Update travis yml for openslide tools
Jun 4, 2020
08ab342
DOC: Update cli docstring
Jun 4, 2020
573fa08
BUG: Reverting back to python3-openslide for travis
Jun 4, 2020
f547d2d
BUG: Reverting back to python3-openslide for travis
Jun 4, 2020
b0ff26e
DEV: Update wsireader
Jun 4, 2020
3d9f6e4
TST: Modify tests to using setup/teardown functions
Jun 4, 2020
2ed615e
STY: Update the style using black
Jun 4, 2020
2661de6
DEV: Update travis yml for openslide tools
Jun 5, 2020
e180dd6
DOC: Update instructions for pip
Jun 15, 2020
0847184
STY: Format import on one line
Jun 15, 2020
a2e2a81
MAINT: Rename misc_utils.py to misc.py
Jun 15, 2020
66dac0f
DOC: Update docstring to add file type
Jun 15, 2020
b49ec89
DOC: Update docstring to add file type
Jun 15, 2020
e80e860
DOC: Update README.rst to include TIA logo
Jun 15, 2020
b9b6dd5
DOC: Update misc.py docstring to ammend Returns
Jun 15, 2020
ff3073b
DEP: output only dictionary from slide_info
Jun 15, 2020
ad355c4
STY: Run black on python code
Jun 15, 2020
d7ea162
MAINT: Update multiproc to raise error instead of print
Jun 15, 2020
dc5d144
DOC: Update slide_info docstring
Jun 15, 2020
d3af79a
DOC: Update save_yaml doc in misc.py
Jun 15, 2020
322286c
DOC: Update docstring for sphinx
Jun 16, 2020
8849f62
STY: Update style using black
Jun 16, 2020
3970513
DOC: Update usage.rst to reformat html and pdf
Jun 17, 2020
8b11fc8
DOC: Update docstring with space to make it consistent
Jun 17, 2020
9cbb54b
MAINT: Update location of logo
Jun 17, 2020
3fbd942
DOC: Update docstring to fix One-line docstring error
Jun 17, 2020
90b7140
DOC: Update docstring to fix Doc line too long error
Jun 17, 2020
84187a8
MAINT: Modify if statement to remove unnecessary else error
Jun 17, 2020
00b0c28
MAINT: Modify if statement to remove unnecessary else error
Jun 17, 2020
8a459f0
MAINT: Fix spaces after ,
Jun 17, 2020
5dfa112
DOC: Fix docstring line too long
Jun 17, 2020
bd45034
DOC: Fix docstring line too long
Jun 17, 2020
bc81b2b
DOC: Fix whitespace before comma
Jun 17, 2020
72f2b5d
STY: Update black styling
Jun 17, 2020
2726d98
MAINT: Use `is` instead of `==` for test
Jun 17, 2020
7e8dcf4
MAINT: Unused arguments should start with _
Jun 17, 2020
4614f7f
TST: Update test_tiatoolbox.py for slide_info
Jun 17, 2020
eff04cf
MAINT: Remove __exit__ to fix errors with Deepsource
Jun 17, 2020
8fc06d6
Merge branch 'develop' into feature-slide-info
shaneahmed Jun 18, 2020
8398bb4
DOC: Update docstrings
Jun 18, 2020
8af253a
BUG: Fix .travis.yml indentation
Jun 18, 2020
1d99de1
BUG: Fix .travis.yml openslide-tools
Jun 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ python:
- 3.8
- 3.7
- 3.6
- 3.5

before_install:
- sudo apt-get -y install openslide-tools

# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox-travis
Expand All @@ -15,13 +17,13 @@ script: tox

# Upload test coverage reports (codecov and deepsource)
after_success:
# Upload coverage to codecov
- bash <(curl -s https://codecov.io/bash)
# Install deepsource CLI
- curl https://deepsource.io/cli | sh
- export DEEPSOURCE_DSN=https://sampledsn@deepsource.io
# Report coverage artifact to 'test-coverage' analyzer
-./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml
# Upload coverage to codecov
- bash <(curl -s https://codecov.io/bash)
# Install deepsource CLI
- curl https://deepsource.io/cli | sh
- export DEEPSOURCE_DSN=https://sampledsn@deepsource.io
# Report coverage artifact to 'test-coverage' analyzer
- ./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml

# Assuming you have installed the travis-ci CLI tool, after you
# create the Github repo and add it to Travis, run the
Expand Down
49 changes: 40 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
.. raw:: html

<p align="center">
<img width="450" height="200" src=https://warwick.ac.uk/fac/sci/dcs/research/tia/tiatoolbox/files/tialab_logo.png>
</p>

===========
TIA Toolbox
===========

Computational Pathology Toolbox developed by TIA Lab

Please try

::

python -m tiatoolbox -h

Getting Started
===============

First, install OpenSlide `here <https://openslide.org/download/>`__. Then, create and
activate the conda environment:

pip
----

::

pip install -r requirements_dev.txt

Computational pathology toolbox developed by TIA Lab.
conda
-----
::

conda env create --name tiatoolbox --file requirements.conda.yml
conda activate tiatoolbox

tiatoolbox --help
=======================

Features
--------
::

* TODO
usage: tiatoolbox [-h] [--version] [--verbose VERBOSE]
{slide_info}
...

Credits
-------
positional arguments:
{slide_info}
slide_info usage: python -m tiatoolbox slide_info -h

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
optional arguments:
-h, --help show this help message and exit
--version show program`s version number and exit
--verbose VERBOSE

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Welcome to TIA Toolbox's documentation!
======================================
=======================================

.. toctree::
:maxdepth: 2
Expand Down
Binary file added docs/tialab_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,47 @@ Usage
To use TIA Toolbox in a project::

import tiatoolbox


----------
Dataloader
----------
.. automodule:: tiatoolbox.dataloader

^^^^^^^^^^^^^^^^^^^^
dataloader.wsireader
^^^^^^^^^^^^^^^^^^^^

.. automodule:: tiatoolbox.dataloader.wsireader
:members: WSIReader
:special-members: __init__

^^^^^^^^^^^^^^^^^^^^^
dataloader.slide_info
^^^^^^^^^^^^^^^^^^^^^

.. automodule:: tiatoolbox.dataloader.slide_info
:members: slide_info

----------
Decorators
----------
.. automodule:: tiatoolbox.decorators

^^^^^^^^^^^^^^^^^^^^
decorators.multiproc
^^^^^^^^^^^^^^^^^^^^
.. automodule:: tiatoolbox.decorators.multiproc
:members: TIAMultiProcess
:special-members: __init__, __call__

------
Utils
------
.. automodule:: tiatoolbox.utils

^^^^^^^^^^
utils.misc
^^^^^^^^^^
.. automodule:: tiatoolbox.utils.misc
:members: save_yaml, split_path_name_ext, grab_files_from_dir
22 changes: 22 additions & 0 deletions requirements.conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: tiatoolbox
channels:
- conda
- conda-forge
- defaults
dependencies:
- python=3.6
- setuptools==45.1.0
- Click==7.0
- cython=0.29.15
- h5py=2.8.0
- matplotlib-base=3.1.3
- numpy=1.18.1
- opencv=4.2
- pillow=7.0.0
- pip=20.0.2
- pyyaml=5.3.1
- requests=2.23.0
- pathos==0.2.5
- pip:
- openslide-python==1.1.1

10 changes: 7 additions & 3 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==19.2.3
pip==20.0.2
bump2version==0.5.11
wheel==0.33.6
watchdog==0.9.0
Expand All @@ -8,6 +8,10 @@ coverage==5.1
Sphinx==1.8.5
twine==1.14.0
Click==7.0
pytest==4.6.5
pytest-runner==5.1
setuptools==45.1.0
pytest==5.4.2
pytest-runner==5.2
opencv-python==4.2.0.34
pathos==0.2.5
openslide-python==1.1.1
pytest-cov==2.9.0
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@
setup(
author="TIA Lab",
author_email="tialab@dcs.warwick.ac.uk",
python_requires=">=3.5",
python_requires=">=3.6",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
description="Computational pathology toolbox developed by TIA Lab.",
entry_points={"console_scripts": ["tiatoolbox=tiatoolbox.cli:main",],},
entry_points={"console_scripts": ["tiatoolbox=tiatoolbox.cli:main", ], },
install_requires=requirements,
long_description=readme + "\n\n" + history,
include_package_data=True,
Expand Down
105 changes: 88 additions & 17 deletions tests/test_tiatoolbox.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,108 @@
#!/usr/bin/env python

"""Tests for `tiatoolbox` package."""

import pytest

from click.testing import CliRunner

from tiatoolbox import tiatoolbox
from tiatoolbox.dataloader.slide_info import slide_info
from tiatoolbox import utils
from tiatoolbox import cli
from tiatoolbox import __version__

from click.testing import CliRunner
import requests
import os
import pathlib


@pytest.fixture
def response():
"""Sample pytest fixture.
def _response_ndpi(request):
"""
Sample pytest fixture for ndpi images
Download ndpi image for pytest
"""
ndpi_file_path = pathlib.Path(__file__).parent.joinpath("CMU-1.ndpi")
if not pathlib.Path.is_file(ndpi_file_path):
r = requests.get(
"http://openslide.cs.cmu.edu/download/openslide-testdata"
"/Hamamatsu/CMU-1.ndpi"
)
with open(ndpi_file_path, "wb") as f:
f.write(r.content)

def close_ndpi():
if pathlib.Path.is_file(ndpi_file_path):
os.remove(str(ndpi_file_path))

request.addfinalizer(close_ndpi)
return _response_ndpi

See more at: http://doc.pytest.org/en/latest/fixture.html

@pytest.fixture
def _response_svs(request):
"""
# import requests
# return requests.get('https://github.com/audreyr/cookiecutter-pypackage')
Sample pytest fixture for svs images
Download ndpi image for pytest
"""
svs_file_path = pathlib.Path(__file__).parent.joinpath("CMU-1.svs")
if not pathlib.Path.is_file(svs_file_path):
r = requests.get(
"http://openslide.cs.cmu.edu/download/openslide-testdata"
"/Hamamatsu/CMU-1.ndpi"
)
with open(svs_file_path, "wb") as f:
f.write(r.content)

def close_ndpi():
if pathlib.Path.is_file(svs_file_path):
os.remove(str(svs_file_path))

request.addfinalizer(close_ndpi)
return _response_svs


def test_content(response):
"""Sample pytest test function with the pytest fixture as an argument."""
# from bs4 import BeautifulSoup
# assert 'GitHub' in BeautifulSoup(response.content).title.string
def test_slide_info(_response_ndpi, _response_svs):
"""pytest for slide_info as a python function"""
file_types = ("*.ndpi", "*.svs", "*.mrxs")
files_all = utils.misc.grab_files_from_dir(
input_path=str(pathlib.Path(r".")), file_types=file_types,
)
slide_params = slide_info(input_path=files_all, workers=2)

for slide_param in slide_params:
utils.misc.save_yaml(slide_param, slide_param["file_name"] + ".yaml")

def test_command_line_interface():
"""Test the CLI."""

def test_command_line_help_interface():
"""Test the CLI help"""
runner = CliRunner()
result = runner.invoke(cli.main)
assert result.exit_code == 0
assert "tiatoolbox.cli.main" in result.output
help_result = runner.invoke(cli.main, ["--help"])
assert help_result.exit_code == 0
assert "--help Show this message and exit." in help_result.output
assert help_result.output == result.output


def test_command_line_version():
"""pytest for version check"""
runner = CliRunner()
version_result = runner.invoke(cli.main, ["-V"])
assert __version__ in version_result.output


def test_command_line_slide_info(_response_ndpi, _response_svs):
"""Test the Slide information CLI."""
runner = CliRunner()
slide_info_result = runner.invoke(
cli.main,
[
"slide-info",
"--wsi_input",
".",
"--file_types",
'"*.ndpi, *.svs"',
"--workers",
"2",
],
)

assert slide_info_result.exit_code == 0
7 changes: 7 additions & 0 deletions tiatoolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
"""Top-level package for TIA Toolbox."""
from tiatoolbox import tiatoolbox
from tiatoolbox import dataloader
from tiatoolbox import utils


__author__ = """TIA Lab"""
__email__ = "tialab@dcs.warwick.ac.uk"
__version__ = "0.1.1"

if __name__ == "__main__":
pass
5 changes: 5 additions & 0 deletions tiatoolbox/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""__main__ file invoked with `python -m tiatoolbox` command"""

from tiatoolbox.cli import main

main()
Loading