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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: numpy2ometiff-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 da1d164d75cbbd259083058b07aad33d17d6f0b1b39d0570ab030d536d6b3d78
MD5 8b694cd5e1169c0ce04e4ec4cfdd628e
BLAKE2b-256 612620377761aaf09c65d94df513672d92f16af87764450675b12666077a61f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numpy2ometiff-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f14710695c68738d69c0e135fbe14e77cca2b925f1326d8fddf15defbb50ff99
MD5 9e1604d2902ee6aa30520ddb99e27d41
BLAKE2b-256 f9949aab0b2e4c94fd309ab46c6df67a61d124ec7e133308478d19e9ac4dafef

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