From fcc2abcf30aac44128a159010c09f2a166e6e352 Mon Sep 17 00:00:00 2001 From: PingjunChen Date: Mon, 18 Feb 2019 22:40:17 -0500 Subject: [PATCH] imporve tissueloc code quality according to codacy --- AUTHORS.md | 8 ++++---- README.md | 24 +++++++++++++++--------- test/test_load_slide.py | 3 ++- test/test_locate_tissue.py | 6 +++--- tissueloc/load_slide.py | 5 ++--- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index f540780..e97a687 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,7 +1,7 @@ -#### Main author: +#### Main author -- [Pingjun Chen](https://github.com/PingjunChen) + - [Pingjun Chen](https://github.com/PingjunChen) -#### Contributors (alphabetical last name): +#### Contributors (alphabetical last name) -- Lin Yang + - Lin Yang diff --git a/README.md b/README.md index 353f950..4c8322d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ tissueloc: Whole slide digital pathology image tissue localization -======== +============= [![Build Status](https://travis-ci.org/PingjunChen/tissueloc.svg?branch=master)](https://travis-ci.org/PingjunChen/tissueloc) [![Documentation Status](https://readthedocs.org/projects/tissueloc/badge/?version=latest)](https://tissueloc.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/tissueloc.svg)](https://badge.fury.io/py/tissueloc) @@ -10,7 +10,8 @@ tissueloc: Whole slide digital pathology image tissue localization Banner -## Installation +Installation +------------- 1. Install [OpenSlide](https://openslide.org/download/). ``` $ sudo apt-get install openslide-tools @@ -26,7 +27,8 @@ $ pip install openslide-python $ pip install tissueloc ``` -## Usage example +Usage example +------------- #### Interface ``` def locate_tissue_cnts(slide_path, @@ -70,23 +72,27 @@ cnts, d_factor = locate_tissue_cnts(slide_path, ``` - -## Documentation +Documentation +------------- Hosted in [https://tissueloc.readthedocs.io](https://tissueloc.readthedocs.io), powered by [readthedocs](https://readthedocs.org) and [Sphinx](http://www.sphinx-doc.org). -## Contributing +Contributing +------------- ``tissueloc`` is an open source project and anyone is welcome to contribute. An easy way to get started is by suggesting a new enhancement on the [Issues](https://github.com/PingjunChen/tissueloc/issues). If you have found a bug, then either report this through [Issues](https://github.com/PingjunChen/tissueloc/issues), or even better, make a fork of the repository, fix the bug and then create a [Pull Requests](https://github.com/PingjunChen/tissueloc/pulls) to get the fix into the master branch. We would like to test this package on more diversified digital slides. Slides (low level images would be better) and their corresponding results are also very welcome as [Pull Requests](https://github.com/PingjunChen/tissueloc/pulls). -## License +License +------------- [tissueloc](https://github.com/PingjunChen/tissueloc) is free software made available under the MIT License. For details see the [LICENSE](LICENSE) file. -## Contributors +Contributors +------------- See the [AUTHORS.md](AUTHORS.md) file for a complete list of contributors to the project. -## Citing +Citing +------------- ``tissueloc`` is published in the Journal of Open Source Software - if it's ever useful for your research please consider citing it: ``` @article{chen2019tissueloc, diff --git a/test/test_load_slide.py b/test/test_load_slide.py index c4e6d66..2b74c7b 100644 --- a/test/test_load_slide.py +++ b/test/test_load_slide.py @@ -7,7 +7,8 @@ TEST_PATH = os.path.abspath(os.path.dirname(__file__)) PRJ_PATH = os.path.dirname(TEST_PATH) sys.path.insert(0, PRJ_PATH) -from tissueloc.load_slide import select_slide_level, load_slide_img +# from tissueloc.load_slide import select_slide_level +from tissueloc.load_slide import load_slide_img # def test_select_slide_level(): diff --git a/test/test_locate_tissue.py b/test/test_locate_tissue.py index 9b7fec6..7c5fa07 100644 --- a/test/test_locate_tissue.py +++ b/test/test_locate_tissue.py @@ -10,11 +10,11 @@ PRJ_PATH = os.path.dirname(TEST_PATH) sys.path.insert(0, PRJ_PATH) - -from tissueloc.load_slide import select_slide_level, load_slide_img +# from tissueloc.load_slide import select_slide_level +from tissueloc.load_slide import load_slide_img from tissueloc.locate_tissue import rgb2gray, thresh_slide, fill_tissue_holes from tissueloc.locate_tissue import remove_small_tissue, find_tissue_cnts -from tissueloc.locate_tissue import locate_tissue_cnts +# from tissueloc.locate_tissue import locate_tissue_cnts diff --git a/tissueloc/load_slide.py b/tissueloc/load_slide.py index 06c6dd1..30a44ac 100644 --- a/tissueloc/load_slide.py +++ b/tissueloc/load_slide.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import os, sys import openslide from PIL import Image import numpy as np @@ -35,7 +34,7 @@ def select_slide_level(slide_path, max_size=2048): level_dims = slide_head.level_dimensions d_factors = slide_head.level_downsamples - assert len(level_dims) > 1, "This slide doesnot have mutliple levels" + # assert len(level_dims) > 1, "This slide doesnot have mutliple levels" select_level = len(level_dims) - 1 for ind in np.arange(len(level_dims)): cur_w, cur_h = level_dims[ind] @@ -77,7 +76,7 @@ def load_slide_img(slide_path, level=0): img_size = slide_head.level_dimensions[level] slide_img = slide_head.read_region((0, 0), level, img_size) if isinstance(slide_img, Image.Image): - slide_img = im = np.asarray(slide_img) + slide_img = np.asarray(slide_img) if slide_img.shape[2] == 4: slide_img = slide_img[:, :, :-1] return slide_img