roifile 2025.12.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roifile/__init__.py +9 -0
- roifile/__main__.py +9 -0
- roifile/py.typed +0 -0
- roifile/roifile.py +1403 -0
- roifile-2025.12.12.dist-info/METADATA +229 -0
- roifile-2025.12.12.dist-info/RECORD +10 -0
- roifile-2025.12.12.dist-info/WHEEL +5 -0
- roifile-2025.12.12.dist-info/entry_points.txt +2 -0
- roifile-2025.12.12.dist-info/licenses/LICENSE +30 -0
- roifile-2025.12.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roifile
|
|
3
|
+
Version: 2025.12.12
|
|
4
|
+
Summary: Read and write ImageJ ROI format
|
|
5
|
+
Home-page: https://www.cgohlke.com
|
|
6
|
+
Author: Christoph Gohlke
|
|
7
|
+
Author-email: cgohlke@cgohlke.com
|
|
8
|
+
License: BSD-3-Clause
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/cgohlke/roifile/issues
|
|
10
|
+
Project-URL: Source Code, https://github.com/cgohlke/roifile
|
|
11
|
+
Platform: any
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/x-rst
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: matplotlib; extra == "all"
|
|
28
|
+
Requires-Dist: tifffile; extra == "all"
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: author-email
|
|
31
|
+
Dynamic: classifier
|
|
32
|
+
Dynamic: description
|
|
33
|
+
Dynamic: description-content-type
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: license
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: platform
|
|
38
|
+
Dynamic: project-url
|
|
39
|
+
Dynamic: provides-extra
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+
Read and write ImageJ ROI format
|
|
45
|
+
================================
|
|
46
|
+
|
|
47
|
+
Roifile is a Python library to read, write, create, and plot `ImageJ`_ ROIs,
|
|
48
|
+
an undocumented and ImageJ application specific format to store regions of
|
|
49
|
+
interest, geometric shapes, paths, text, and whatnot for image overlays.
|
|
50
|
+
|
|
51
|
+
.. _ImageJ: https://imagej.net
|
|
52
|
+
|
|
53
|
+
:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
|
|
54
|
+
:License: BSD-3-Clause
|
|
55
|
+
:Version: 2025.12.12
|
|
56
|
+
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_
|
|
57
|
+
|
|
58
|
+
Quickstart
|
|
59
|
+
----------
|
|
60
|
+
|
|
61
|
+
Install the roifile package and all dependencies from the
|
|
62
|
+
`Python Package Index <https://pypi.org/project/roifile/>`_::
|
|
63
|
+
|
|
64
|
+
python -m pip install -U "roifile[all]"
|
|
65
|
+
|
|
66
|
+
View overlays stored in a ROI, ZIP, or TIFF file::
|
|
67
|
+
|
|
68
|
+
python -m roifile file.roi
|
|
69
|
+
|
|
70
|
+
See `Examples`_ for using the programming interface.
|
|
71
|
+
|
|
72
|
+
Source code, examples, and support are available on
|
|
73
|
+
`GitHub <https://github.com/cgohlke/roifile>`_.
|
|
74
|
+
|
|
75
|
+
Requirements
|
|
76
|
+
------------
|
|
77
|
+
|
|
78
|
+
This revision was tested with the following requirements and dependencies
|
|
79
|
+
(other versions may work):
|
|
80
|
+
|
|
81
|
+
- `CPython <https://www.python.org>`_ 3.11.9, 3.12.10, 3.13.11 3.14.2 64-bit
|
|
82
|
+
- `NumPy <https://pypi.org/project/numpy>`_ 2.3.5
|
|
83
|
+
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2025.10.16 (optional)
|
|
84
|
+
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.10.7 (optional)
|
|
85
|
+
|
|
86
|
+
Revisions
|
|
87
|
+
---------
|
|
88
|
+
|
|
89
|
+
2025.12.12
|
|
90
|
+
|
|
91
|
+
- Move tests to separate module.
|
|
92
|
+
|
|
93
|
+
2025.5.10
|
|
94
|
+
|
|
95
|
+
- Support Python 3.14.
|
|
96
|
+
|
|
97
|
+
2025.2.20
|
|
98
|
+
|
|
99
|
+
- Drop support for Python 3.9.
|
|
100
|
+
|
|
101
|
+
2024.9.15
|
|
102
|
+
|
|
103
|
+
- Improve typing.
|
|
104
|
+
- Deprecate Python 3.9, support Python 3.13.
|
|
105
|
+
|
|
106
|
+
2024.5.24
|
|
107
|
+
|
|
108
|
+
- Fix docstring examples not correctly rendered on GitHub.
|
|
109
|
+
|
|
110
|
+
2024.3.20
|
|
111
|
+
|
|
112
|
+
- Fix writing generator of ROIs (#9).
|
|
113
|
+
|
|
114
|
+
2024.1.10
|
|
115
|
+
|
|
116
|
+
- Support text rotation.
|
|
117
|
+
- Improve text rendering.
|
|
118
|
+
- Avoid array copies.
|
|
119
|
+
- Limit size read from files.
|
|
120
|
+
|
|
121
|
+
2023.8.30
|
|
122
|
+
|
|
123
|
+
- Fix linting issues.
|
|
124
|
+
- Add py.typed marker.
|
|
125
|
+
|
|
126
|
+
2023.5.12
|
|
127
|
+
|
|
128
|
+
- Improve object repr and type hints.
|
|
129
|
+
- Drop support for Python 3.8 and numpy < 1.21 (NEP29).
|
|
130
|
+
|
|
131
|
+
2023.2.12
|
|
132
|
+
|
|
133
|
+
- Delay import of zipfile.
|
|
134
|
+
- Verify shape of coordinates on write.
|
|
135
|
+
|
|
136
|
+
2022.9.19
|
|
137
|
+
|
|
138
|
+
- Fix integer coordinates to -5000..60536 conforming with ImageJ (breaking).
|
|
139
|
+
- Add subpixel_coordinates in frompoints for out-of-range integer coordinates.
|
|
140
|
+
|
|
141
|
+
2022.7.29
|
|
142
|
+
|
|
143
|
+
- …
|
|
144
|
+
|
|
145
|
+
Refer to the CHANGES file for older revisions.
|
|
146
|
+
|
|
147
|
+
Notes
|
|
148
|
+
-----
|
|
149
|
+
|
|
150
|
+
The ImageJ ROI format cannot store integer coordinate values outside the
|
|
151
|
+
range of -5000..60536.
|
|
152
|
+
|
|
153
|
+
Refer to the ImageJ `RoiDecoder.java
|
|
154
|
+
<https://github.com/imagej/ImageJ/blob/master/ij/io/RoiDecoder.java>`_
|
|
155
|
+
source code for a reference implementation.
|
|
156
|
+
|
|
157
|
+
Other Python packages handling ImageJ ROIs:
|
|
158
|
+
|
|
159
|
+
- `ijpython_roi <https://github.com/dwaithe/ijpython_roi>`_
|
|
160
|
+
- `read-roi <https://github.com/hadim/read-roi/>`_
|
|
161
|
+
- `napari_jroitools <https://github.com/jayunruh/napari_jroitools>`_
|
|
162
|
+
|
|
163
|
+
Examples
|
|
164
|
+
--------
|
|
165
|
+
|
|
166
|
+
Create a new ImagejRoi instance from an array of x, y coordinates:
|
|
167
|
+
|
|
168
|
+
>>> roi = ImagejRoi.frompoints([[1.1, 2.2], [3.3, 4.4], [5.5, 6.6]])
|
|
169
|
+
>>> roi.roitype = ROI_TYPE.POINT
|
|
170
|
+
>>> roi.options |= ROI_OPTIONS.SHOW_LABELS
|
|
171
|
+
|
|
172
|
+
Export the instance to an ImageJ ROI formatted byte string or file:
|
|
173
|
+
|
|
174
|
+
>>> out = roi.tobytes()
|
|
175
|
+
>>> out[:4]
|
|
176
|
+
b'Iout'
|
|
177
|
+
>>> roi.tofile('_test.roi')
|
|
178
|
+
|
|
179
|
+
Read the ImageJ ROI from the file and verify the content:
|
|
180
|
+
|
|
181
|
+
>>> roi2 = ImagejRoi.fromfile('_test.roi')
|
|
182
|
+
>>> roi2 == roi
|
|
183
|
+
True
|
|
184
|
+
>>> roi.roitype == ROI_TYPE.POINT
|
|
185
|
+
True
|
|
186
|
+
>>> roi.subpixelresolution
|
|
187
|
+
True
|
|
188
|
+
>>> roi.coordinates()
|
|
189
|
+
array([[1.1, 2.2],
|
|
190
|
+
[3.3, 4.4],
|
|
191
|
+
[5.5, 6.6]], dtype=float32)
|
|
192
|
+
>>> roi.left, roi.top, roi.right, roi.bottom
|
|
193
|
+
(1, 2, 7, 8)
|
|
194
|
+
>>> roi2.name = 'test'
|
|
195
|
+
|
|
196
|
+
Plot the ROI using matplotlib:
|
|
197
|
+
|
|
198
|
+
>>> roi.plot()
|
|
199
|
+
|
|
200
|
+
Write the ROIs to a ZIP file:
|
|
201
|
+
|
|
202
|
+
>>> roiwrite('_test.zip', [roi, roi2], mode='w')
|
|
203
|
+
|
|
204
|
+
Read the ROIs from the ZIP file:
|
|
205
|
+
|
|
206
|
+
>>> rois = roiread('_test.zip')
|
|
207
|
+
>>> assert len(rois) == 2 and rois[0] == roi and rois[1].name == 'test'
|
|
208
|
+
|
|
209
|
+
Write the ROIs to an ImageJ formatted TIFF file:
|
|
210
|
+
|
|
211
|
+
>>> import numpy
|
|
212
|
+
>>> import tifffile
|
|
213
|
+
>>> tifffile.imwrite(
|
|
214
|
+
... '_test.tif',
|
|
215
|
+
... numpy.zeros((9, 9), 'u1'),
|
|
216
|
+
... imagej=True,
|
|
217
|
+
... metadata={'Overlays': [roi.tobytes(), roi2.tobytes()]},
|
|
218
|
+
... )
|
|
219
|
+
|
|
220
|
+
Read the ROIs embedded in an ImageJ formatted TIFF file:
|
|
221
|
+
|
|
222
|
+
>>> rois = roiread('_test.tif')
|
|
223
|
+
>>> assert len(rois) == 2 and rois[0] == roi and rois[1].name == 'test'
|
|
224
|
+
|
|
225
|
+
View the overlays stored in a ROI, ZIP, or TIFF file from a command line::
|
|
226
|
+
|
|
227
|
+
python -m roifile _test.roi
|
|
228
|
+
|
|
229
|
+
For an advanced example, see `roifile_demo.py` in the source distribution.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
roifile/__init__.py,sha256=AsK--1p3Z33qFLqChDMKTCqey-LDT_vGCf92RGl9Pe0,207
|
|
2
|
+
roifile/__main__.py,sha256=Mfn3wm-4cRRChIRonbEcZZT7eRX6RFlS31S8wS1JAVM,132
|
|
3
|
+
roifile/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
roifile/roifile.py,sha256=3UBvkfSGu5RzsbjbJni4L_fMQD6uDJgw9kXDtUnnPsw,44918
|
|
5
|
+
roifile-2025.12.12.dist-info/licenses/LICENSE,sha256=1yXweb-z6uE6JaIRMz2UpNOF-sYNbqTyHYhmRHWjyEI,1559
|
|
6
|
+
roifile-2025.12.12.dist-info/METADATA,sha256=LSbdXby1cHiZf9GnFDyUkWPFqfU5_hxQjz8lEePWcjE,5955
|
|
7
|
+
roifile-2025.12.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
+
roifile-2025.12.12.dist-info/entry_points.txt,sha256=xP8cwEUbAUeROLXNRanJnAIl13tagbjSSDGfVWf2vh0,49
|
|
9
|
+
roifile-2025.12.12.dist-info/top_level.txt,sha256=QlfLomxPxuYNU0TTR7MXoVBAEAXCj2WJyKvoCJxNwek,8
|
|
10
|
+
roifile-2025.12.12.dist-info/RECORD,,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
BSD-3-Clause license
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2025, Christoph Gohlke
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
24
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
26
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
27
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
28
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
29
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
30
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
roifile
|