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

Uploaded Source

Built Distribution

numpy2ometiff-0.1.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numpy2ometiff-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 90058a08f7e8e0e333420cd9595ea06a16ae1333670ab24fefa59ee0ba8432a6
MD5 5d99b93406feb6ed56f6ea5c1177a298
BLAKE2b-256 2eabfea4ca1f7aedd5c265811fea51ef97f748bef9aa20ea9d6abf247c221075

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numpy2ometiff-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 23339127a675a2054309430b0afb8de60142249a4868177a12b5e7e2c4ae6665
MD5 930e688eedbc2214ea66262ef79aa063
BLAKE2b-256 a7ea9c2d36c1d67bf12a22cdf45ee1746cd2684e41075938c57d65417dd9d7c8

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