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(1, 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.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

numpy2ometiff-0.1.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numpy2ometiff-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 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.3.tar.gz
Algorithm Hash digest
SHA256 03e68b4f96c05afde7ba074f9bc7220ea3f3412f81e99b33c27a7f4f54bb2f34
MD5 8f1c958c4ce6178cdc37e04897fc8b76
BLAKE2b-256 2a4cec33669af71c45a50395703384311aca4d0a135b78629dc2d0e4e9ebe500

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numpy2ometiff-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c393bb7445b13948ca3a214666c0facd1df9cd406129fc42b54efffea0937f72
MD5 410268da3b7c745563d1aebbfb1aff2a
BLAKE2b-256 73546dce9836e5d7c76c9c3fa4f561edd939b6905292270c40a3cd7fd77a968c

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