Read and Write OME-TIFFs in Python
Project description
About
pyometiff is a Python library for reading and writing OME-TIFF files that
are compliant with the OME-XML specifications.
pyometiff tries to cover most of the tags in the latest OMEXML format specification, while most of the available Python conversion tools are often missing key tags like PhysicalSizeXUnit which are fundamental in any microscopy environment.
Installation
Run the following to install:
pip install pyometiff
Usage
pyometiff exposes two main classes: OMETIFFReader and OMETIFFWriter which
you can use to read and write OME TIFF files.
To open a OME-TIFF image you can create an OMETIFFReaderobject and call its .read() method.
import pathlib
from pyometiff import OMETIFFReader
img_fpath = pathlib.Path("/path/to/img.ome.tiff")
reader = OMETIFFReader(fpath=img_fpath)
img_array, metadata, xml_metadata = reader.read()
similarly, to write an OME-TIFF file, we use the OMETIFFWriter class and its .write() method as in the example.
import pathlib
import numpy as np
from pyometiff import OMETIFFWriter
output_fpath = pathlib.Path.cwd().joinpath("test_out.ome.tiff")
# a template metadata dict is available at OMETIFFReader._get_metadata_template()
metadata_dict = {
"PhysicalSizeX" : "0.88",
"PhysicalSizeXUnit" : "µm",
"PhysicalSizeY" : "0.88",
"PhysicalSizeYUnit" : "µm",
"PhysicalSizeZ" : "3.3",
"PhysicalSizeZUnit" : "µm",
"Channels" : {
"405" : {
"Name" : "405nm",
"SamplesPerPixel": 1,
"ExcitationWavelength": 405.,
"ExcitationWavelengthUnit": "nm"
},
"488" : {
"Name" : "488nm",
"SamplesPerPixel": 1,
"ExcitationWavelength": 488.,
"ExcitationWavelengthUnit": "nm"
},
"638" : {
"Name" : "638nm",
"SamplesPerPixel": 1,
"ExcitationWavelength": 638.,
"ExcitationWavelengthUnit": "nm"
},
}
}
# our data in npy format
npy_array_data = np.random.randint(0, 255, (2, 10, 3, 512, 512), dtype=np.uint8)
# a string describing the dimension ordering
dimension_order = "ZTCYX"
writer = OMETIFFWriter(
fpath=output_fpath,
dimension_order=dimension_order,
array=npy_array_data,
metadata=metadata_dict,
explicit_tiffdata=False)
writer.write()
Licensing
pyometiff is distributed under the GNU General Public License v3.0 (GNU GPLv3),
see the LICENSE file for more info.
This implementation is partially based on aicsimageio by the Allen Institute for Cell Science and python-bioformats by the Broad Institute, part of the CellProfiler project.
The relative licensing and copyright notices are included in the LICENSE file.
External Resources
- The Open Microscopy Environment - OME
- OME-TIFF format
- OME-TIFF specification
- OME-XML format
- OME-XML schema specification
Cite
Zenodo DOI: 10.5281/zenodo.7520378
@software{filippo_castelli_2024_10612149,
author = {Filippo Castelli and
Giacomo Mazzamuto},
title = {filippocastelli/pyometiff: 1.0.0},
month = feb,
year = 2024,
publisher = {Zenodo},
doi = {10.5281/zenodo.10612149},
url = {https://doi.org/10.5281/zenodo.10612149}
}
Contacts
Author:
Filippo Maria Castelli, PhD
[formerly] LENS, European Laboratory for Non-linear Spectroscopy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyometiff-1.1.4.tar.gz.
File metadata
- Download URL: pyometiff-1.1.4.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d2f354c971caad5b46f2ce603fccf6265d5c88f15f2d8df6e87c2118ca53869
|
|
| MD5 |
c4d9d2fa4986ab79ccb84eda87697974
|
|
| BLAKE2b-256 |
a5556680b4a84ef634c43154500471f26fc7f7c68017aaec41b621610a3a97df
|
Provenance
The following attestation bundles were made for pyometiff-1.1.4.tar.gz:
Publisher:
python-publish.yml on filippocastelli/pyometiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyometiff-1.1.4.tar.gz -
Subject digest:
4d2f354c971caad5b46f2ce603fccf6265d5c88f15f2d8df6e87c2118ca53869 - Sigstore transparency entry: 195097153
- Sigstore integration time:
-
Permalink:
filippocastelli/pyometiff@e217b8b3d796fc2f5628e16011a883f291d6edc5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/filippocastelli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e217b8b3d796fc2f5628e16011a883f291d6edc5 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyometiff-1.1.4-py3-none-any.whl.
File metadata
- Download URL: pyometiff-1.1.4-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22bf23a22e797e99cea5e7ec30aaf1c6b3824fddf45671b15aa97e11f0f26def
|
|
| MD5 |
24a94e4f261b6ce295a621c7000c5961
|
|
| BLAKE2b-256 |
c2a7494396d9890f193b8088d865f756346923199b92e90ee2c1f4638ec5ca41
|
Provenance
The following attestation bundles were made for pyometiff-1.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on filippocastelli/pyometiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyometiff-1.1.4-py3-none-any.whl -
Subject digest:
22bf23a22e797e99cea5e7ec30aaf1c6b3824fddf45671b15aa97e11f0f26def - Sigstore transparency entry: 195097155
- Sigstore integration time:
-
Permalink:
filippocastelli/pyometiff@e217b8b3d796fc2f5628e16011a883f291d6edc5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/filippocastelli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e217b8b3d796fc2f5628e16011a883f291d6edc5 -
Trigger Event:
workflow_dispatch
-
Statement type: