Skip to content

Commit

Permalink
Merge pull request #219 from scottclowe/api_ROI-to-polygons
Browse files Browse the repository at this point in the history
API: Rename module ROI -> polygons
  • Loading branch information
scottclowe committed Jun 29, 2021
2 parents f95fef1 + 375cf6c commit f061d4e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CREDITS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Testing

External Code
-------------
* `ROI.py <https://github.com/rochefort-lab/fissa/blob/master/fissa/ROI.py>`_
* `polygons.py <https://github.com/rochefort-lab/fissa/blob/master/fissa/polygons.py>`_
was adapted from code contained in the `SIMA <http://www.losonczylab.org/sima/>`_ package
under the `GNU GPL v2 License <https://www.gnu.org/licenses/gpl-2.0.html>`_.
* `NIH ImageJ ROI parsing <https://github.com/rochefort-lab/fissa/blob/master/fissa/readimagejrois.py>`_
Expand Down
12 changes: 8 additions & 4 deletions fissa/ROI.py → fissa/polygons.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""
Polygon tools.
.. versionchanged:: 1.0.0
Module renamed from ``fissa.ROI`` to ``fissa.polygons``.
The functions below were adapted from the sima package
http://www.losonczylab.org/sima version 1.3.0.
http://www.losonczylab.org/sima, version 1.3.0.
https://github.com/losonczylab/sima/blob/1.3.0/sima/ROI.py
**License**
License
-------
This file is Copyright (C) 2014 The Trustees of Columbia University in the
City of New York.
Expand Down Expand Up @@ -34,7 +38,7 @@ def poly2mask(polygons, im_size):
"""
Convert polygons to a sparse binary mask.
>>> from fissa.ROI import poly2mask
>>> from fissa.polygons import poly2mask
>>> poly1 = [[0, 0], [0, 1], [1, 1], [1, 0]]
>>> poly2 = [[0, 1], [0, 2], [2, 2], [2, 1]]
>>> mask = poly2mask([poly1, poly2], (3, 3))
Expand Down
2 changes: 1 addition & 1 deletion fissa/roitools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
except ImportError:
import collections as abc

from .polygons import poly2mask
from .readimagejrois import read_imagej_roi_zip
from .ROI import poly2mask


def get_mask_com(mask):
Expand Down
9 changes: 4 additions & 5 deletions fissa/tests/test_ROI.py → fissa/tests/test_polygons.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
Tests for the ROI module.
Tests for the polygons module.
This test was taken from the sima package
http://www.losonczylab.org/sima
version 1.3.0
http://www.losonczylab.org/sima, v1.3.0:
https://github.com/losonczylab/sima/blob/6d2cd4f071e4/sima/tests/test_ROI.py
License
Expand Down Expand Up @@ -34,13 +33,13 @@
# run properly, regardless of how python is started.
from numpy.testing import assert_equal

from .. import ROI
from .. import polygons


def test_poly2mask():
poly1 = [[0, 0], [0, 1], [1, 1], [1, 0]]
poly2 = [[0, 1], [0, 2], [2, 2], [2, 1]]
masks = ROI.poly2mask([poly1, poly2], (3, 3))
masks = polygons.poly2mask([poly1, poly2], (3, 3))
assert_equal(
masks[0].todense(),
np.array(
Expand Down

0 comments on commit f061d4e

Please sign in to comment.