Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Roifile is a Python library to read, write, create, and plot ImageJ
_ ROIs,
an undocumented and ImageJ application specific format to store regions of
interest, geometric shapes, paths, text, and whatnot for image overlays.
.. _ImageJ: https://imagej.net
:Author: Christoph Gohlke <https://www.cgohlke.com>
_
:License: BSD 3-Clause
:Version: 2024.9.15
:DOI: 10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>
_
Install the roifile package and all dependencies from the
Python Package Index <https://pypi.org/project/roifile/>
_::
python -m pip install -U "roifile[all]"
View overlays stored in a ROI, ZIP, or TIFF file::
python -m roifile file.roi
See Examples
_ for using the programming interface.
Source code, examples, and support are available on
GitHub <https://github.com/cgohlke/roifile>
_.
This revision was tested with the following requirements and dependencies (other versions may work):
CPython <https://www.python.org>
_ 3.10.11, 3.11.9, 3.12.5, 3.13.0rc2Numpy <https://pypi.org/project/numpy/>
_ 2.2.1Tifffile <https://pypi.org/project/tifffile/>
_ 2024.8.30 (optional)Matplotlib <https://pypi.org/project/matplotlib/>
_ 3.9.2 (optional)2024.9.15
2024.5.24
2024.3.20
2024.1.10
2023.8.30
2023.5.12
2023.2.12
2022.9.19
2022.7.29
Refer to the CHANGES file for older revisions.
The ImageJ ROI format cannot store integer coordinate values outside the range of -5000..60536.
Refer to the ImageJ RoiDecoder.java <https://github.com/imagej/ImageJ/blob/master/ij/io/RoiDecoder.java>
_
source code for a reference implementation.
Other Python packages handling ImageJ ROIs:
ijpython_roi <https://github.com/dwaithe/ijpython_roi>
_read-roi <https://github.com/hadim/read-roi/>
_napari_jroitools <https://github.com/jayunruh/napari_jroitools>
_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
Export the instance to an ImageJ ROI formatted byte string or file:
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) roi2.name = 'test'
Plot the ROI using matplotlib:
roi.plot()
Write the ROIs to a ZIP file:
roiwrite('_test.zip', [roi, roi2], mode='w')
Read the ROIs from the ZIP file:
rois = roiread('_test.zip') assert len(rois) == 2 and rois[0] == roi and rois[1].name == 'test'
Write the ROIs to an ImageJ formatted TIFF file:
import tifffile tifffile.imwrite( ... '_test.tif', ... numpy.zeros((9, 9), 'u1'), ... imagej=True, ... metadata={'Overlays': [roi.tobytes(), roi2.tobytes()]}, ... )
Read the ROIs embedded in an ImageJ formatted TIFF file:
rois = roiread('_test.tif') assert len(rois) == 2 and rois[0] == roi and rois[1].name == 'test'
View the overlays stored in a ROI, ZIP, or TIFF file from a command line::
python -m roifile _test.roi
For an advanced example, see roifile_demo.py
in the source distribution.
FAQs
Read and write ImageJ ROI format
We found that roifile demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.