Skip to content

Commit

Permalink
Release v2024.5.24
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed May 23, 2024
1 parent 54f9ac6 commit c966c36
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
..
This file is generated by setup.py
Read and write ImageJ ROI format
================================

Expand All @@ -9,7 +12,7 @@ interest, geometric shapes, paths, text, and whatnot for image overlays.

:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
:License: BSD 3-Clause
:Version: 2024.3.20
:Version: 2024.5.24
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_

Quickstart
Expand All @@ -35,14 +38,18 @@ Requirements
This revision was tested with the following requirements and dependencies
(other versions may work):

- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.8, 3.12.2
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.4
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.2.12 (optional)
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.3 (optional)
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.5.22 (optional)
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.4 (optional)

Revisions
---------

2024.5.24

- Fix GitHub not correctly rendering docstring examples.

2024.3.20

- Fix writing generator of ROIs (#9).
Expand Down Expand Up @@ -101,37 +108,45 @@ Examples

Create a new ImagejRoi instance from an array of x, y coordinates:

>>> roi = ImagejRoi.frompoints([[1.1, 2.2], [3.3, 4.4], [5.5, 6.6]])
>>> roi.roitype = ROI_TYPE.POINT
>>> roi.options |= ROI_OPTIONS.SHOW_LABELS
.. code-block:: python
>>> roi = ImagejRoi.frompoints([[1.1, 2.2], [3.3, 4.4], [5.5, 6.6]])
>>> roi.roitype = ROI_TYPE.POINT
>>> roi.options |= ROI_OPTIONS.SHOW_LABELS
Export the instance to an ImageJ ROI formatted byte string or file:

>>> out = roi.tobytes()
>>> out[:4]
b'Iout'
>>> roi.tofile('_test.roi')
.. code-block:: python
>>> out = roi.tobytes()
>>> out[:4]
b'Iout'
>>> roi.tofile('_test.roi')
Read the ImageJ ROI from the file and verify the content:

>>> roi2 = ImagejRoi.fromfile('_test.roi')
>>> roi2 == roi
True
>>> roi.roitype == ROI_TYPE.POINT
True
>>> roi.subpixelresolution
True
>>> roi.coordinates()
array([[1.1, 2.2],
[3.3, 4.4],
[5.5, 6.6]], dtype=float32)
>>> roi.left, roi.top, roi.right, roi.bottom
(1, 2, 7, 8)
.. code-block:: python
>>> roi2 = ImagejRoi.fromfile('_test.roi')
>>> roi2 == roi
True
>>> roi.roitype == ROI_TYPE.POINT
True
>>> roi.subpixelresolution
True
>>> roi.coordinates()
array([[1.1, 2.2],
[3.3, 4.4],
[5.5, 6.6]], dtype=float32)
>>> roi.left, roi.top, roi.right, roi.bottom
(1, 2, 7, 8)
Plot the ROI using matplotlib:

>>> roi.plot()
.. code-block:: python
>>> roi.plot()
View the overlays stored in a ROI, ZIP, or TIFF file from a command line::

python -m roifile _test.roi
python -m roifile _test.roi

0 comments on commit c966c36

Please sign in to comment.