Skip to main content

Convert NumPy arrays to OME-TIFF

Project description

numpy2ometiff

numpy2ometiff is a Python library designed to convert NumPy arrays into OME-TIFF files. This library facilitates exporting scientific imaging data to the OME-TIFF format, which is ideal for microscopy and bioimaging applications.

Features

  • Simple API: Convert NumPy arrays to OME-TIFF with a single function call.
  • Flexible Input: Supports single and multi-dimensional arrays (2D, 3D, 4D) representing multiple channels and z-slices.
  • Customizable Metadata: Allows users to specify pixel sizes and channel information.
  • Optional Pyramid Creation: Enable pyramid OME-TIFF files for large datasets, improving performance in compatible viewers.

Installation

You can install numpy2ometiff directly via pip:

pip install numpy2ometiff

Example Usage

This example demonstrates how to convert a NumPy array into an OME-TIFF file using the numpy2ometiff library. It assumes you have already installed numpy2ometiff as described in the installation section.

import numpy as np
from numpy2ometiff import write_ome_tiff

# Generate a dummy numpy array
data = np.random.rand(5, 3, 256, 256).astype(np.float32)  # 1 z-slice, 3 channels, 256x256 pixels

# Define channel names
channel_names = ['DAPI', 'GFP', 'RFP']

# Define pixel sizes and physical size in Z
pixel_size_x = 0.65  # micron
pixel_size_y = 0.65  # micron
physical_size_z = 0.2  # micron

# Specify the output filename
output_filename = 'output_test_image.ome.tiff'

# Write the OME-TIFF file
write_ome_tiff(data=data,
               output_filename=output_filename,
               channel_names=channel_names,
               pixel_size_x=pixel_size_x,
               pixel_size_y=pixel_size_y,
               physical_size_z=physical_size_z,
               Unit='µm',
               imagej=False, 
               create_pyramid=True,
               compression='zlib')

print("The OME-TIFF file has been successfully written.")

Contributing

Contributions to numpy2ometiff are welcome! Feel free to fork the repository, make your changes, and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numpy2ometiff-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

numpy2ometiff-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file numpy2ometiff-0.1.1.tar.gz.

File metadata

  • Download URL: numpy2ometiff-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for numpy2ometiff-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a5c86c58957ece58710319d6a41472971767e5a397946887237ddf8763479788
MD5 f735e64002fdac2f24957482e0d0a26a
BLAKE2b-256 0bb3d1580ce011e4ba13ec84b15c5203954e4532390294fe541bfba2b7cbc808

See more details on using hashes here.

File details

Details for the file numpy2ometiff-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for numpy2ometiff-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6571819f54d2789e57a8ec04b3bbba93e993f8e3972bdb5a8f2a39b57e85ebd6
MD5 99177802f0474e69bcd51c3228650193
BLAKE2b-256 7564b2b0410d0aa43cd46b9f142d3178a5c58492f80174537d89a2e9483f99c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page