-
Notifications
You must be signed in to change notification settings - Fork 102
Feature slide info #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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
3a24650
BLD: Added slide information feature
3477f52
BLD: Add multiproc decorator for toolbox
6921300
STY: Run black for style formatting
c67d8b0
DOC: Add Docstring to multiproc.py
6a6845e
BUG: Update requirements_dev.txt to fix bugs with Travis
f7b0c0c
BUG: Update requirements_dev.txt to fix bugs opencv-python with Travis
7381339
BUG: Travis error fix setuptools
eb4a990
BUG: Travis error fix setuptools
f06b659
BUG: Fix Travis error History.rst
1ba8c42
BUG: Fix Travis libopenslide.so.0: error
02747bb
BUG: Update test_tiatoolbox.py to fix pytest errors
5f63b4a
BUG: FIX travis error for python3.8
34b9bd6
BUG: FIX travis error for python3.8
6f3ffaa
BUG: Fix Travis python 3.8 issue
68d2177
BUG: Fix Travis python 3.8 issue
6811a98
BUG: Fix Travis python 3.8 issue
ab43935
BUG: Roll back multiprocessing changes for python 3.8
045ef83
BUG: Fix Travis error for multiprocessing
a24e4a5
BUG: Fix Multiprocessing bug for python 3.8
e837fb7
BUG: Fix Multiprocessing bug for python 3.8
1285e6b
Merge branch 'develop' into feature-slide-info
shaneahmed abfa632
DOC: Update docstring test_tiatoolbox.py
eabf091
DOC: Update README
ee19869
DOC: Update README.rst
shaneahmed 5b1c768
DEV: Add conda requirements file
3b78fc1
TST: Add test for version information
a70831d
DEP: Remove tiatoolbox_Structure.jpg
82cf63c
DOC: Update to README.rst according to address PR comments
60e7d69
DEV: Update travis yml for openslide tools
08ab342
DOC: Update cli docstring
573fa08
BUG: Reverting back to python3-openslide for travis
f547d2d
BUG: Reverting back to python3-openslide for travis
b0ff26e
DEV: Update wsireader
3d9f6e4
TST: Modify tests to using setup/teardown functions
2ed615e
STY: Update the style using black
2661de6
DEV: Update travis yml for openslide tools
e180dd6
DOC: Update instructions for pip
0847184
STY: Format import on one line
a2e2a81
MAINT: Rename misc_utils.py to misc.py
66dac0f
DOC: Update docstring to add file type
b49ec89
DOC: Update docstring to add file type
e80e860
DOC: Update README.rst to include TIA logo
b9b6dd5
DOC: Update misc.py docstring to ammend Returns
ff3073b
DEP: output only dictionary from slide_info
ad355c4
STY: Run black on python code
d7ea162
MAINT: Update multiproc to raise error instead of print
dc5d144
DOC: Update slide_info docstring
d3af79a
DOC: Update save_yaml doc in misc.py
322286c
DOC: Update docstring for sphinx
8849f62
STY: Update style using black
3970513
DOC: Update usage.rst to reformat html and pdf
8b11fc8
DOC: Update docstring with space to make it consistent
9cbb54b
MAINT: Update location of logo
3fbd942
DOC: Update docstring to fix One-line docstring error
90b7140
DOC: Update docstring to fix Doc line too long error
84187a8
MAINT: Modify if statement to remove unnecessary else error
00b0c28
MAINT: Modify if statement to remove unnecessary else error
8a459f0
MAINT: Fix spaces after ,
5dfa112
DOC: Fix docstring line too long
bd45034
DOC: Fix docstring line too long
bc81b2b
DOC: Fix whitespace before comma
72f2b5d
STY: Update black styling
2726d98
MAINT: Use `is` instead of `==` for test
7e8dcf4
MAINT: Unused arguments should start with _
4614f7f
TST: Update test_tiatoolbox.py for slide_info
eff04cf
MAINT: Remove __exit__ to fix errors with Deepsource
8fc06d6
Merge branch 'develop' into feature-slide-info
shaneahmed 8398bb4
DOC: Update docstrings
8af253a
BUG: Fix .travis.yml indentation
1d99de1
BUG: Fix .travis.yml openslide-tools
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
simongraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") | ||
simongraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.