Skip to content

Commit

Permalink
imporve tissueloc code quality according to codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
PingjunChen committed Feb 19, 2019
1 parent a43e2c8 commit fcc2abc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
8 changes: 4 additions & 4 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -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
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -10,7 +10,8 @@ tissueloc: Whole slide digital pathology image tissue localization

<img src="tissuelocDemo.png" width="800" height="320" alt="Banner">

## Installation
Installation
-------------
1. Install [OpenSlide](https://openslide.org/download/).
```
$ sudo apt-get install openslide-tools
Expand All @@ -26,7 +27,8 @@ $ pip install openslide-python
$ pip install tissueloc
```

## Usage example
Usage example
-------------
#### Interface
```
def locate_tissue_cnts(slide_path,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/test_load_slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions test/test_locate_tissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
5 changes: 2 additions & 3 deletions tissueloc/load_slide.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

import os, sys
import openslide
from PIL import Image
import numpy as np
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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

0 comments on commit fcc2abc

Please sign in to comment.