Class for reading Bitplane imaris files (*.ims) as zarr, adapted from AM Watson imaris_ims_file_reader
Project description
imaris-ims-zarr
Imaris file format (*.ims) reader with zarr v3 support.
pip install imaris-ims-zarr
from imaris_ims_zarr.ims import ims
a = ims('myFile.ims')
# Slice a like a numpy array always with 5 axes to access the highest resolution - level 0 - (t,c,z,y,x)
a[0,0,5,:,:] # Time point 0, Channel 0, z-layer 5
# Slice in 6 axes to designate the desired resolution level to work with - 0 is default and the highest resolution
a[3,0,0,5,:,:] # Resolution Level 3, Time point 0, Channel 0, z-layer 5
print(a.ResolutionLevelLock)
print(a.ResolutionLevels)
print(a.TimePoints)
print(a.Channels)
print(a.shape)
print(a.chunks)
print(a.dtype)
print(a.ndim)
# A 'resolution lock' can be set when making the class which allows for 5 axis slicing that always extracts from that resoltion level
a = ims('myFile.ims', ResolutionLevelLock=3)
# Change ResolutionLevelLock after the class is open
a.change_resolution_lock(2)
print(a.ResolutionLevelLock)
# The 'squeeze_output' option returns arrays in their reduced form similar to a numpy array. This is True by default to maintain behavior similar to numpy; however, some applications may benefit from predictably returning a 5 axis array. For example, napari prefers to have outputs with the same number of axes as the input.
a = ims('myFile.ims')
print(a[0,0,0].shape)
#(1024,1024)
a = ims('myFile.ims', squeeze_output=False)
print(a[0,0,0].shape)
#(1,1,1,1024,1024)
#########################################################
### Open the Imaris file as a Zarr Store (read only) ###
#########################################################
from imaris_ims_zarr.ims import ims
import zarr
store = ims('myFile.ims', ResolutionLevelLock=2, aszarr=True)
print(store)
#<imaris_ims_zarr.ims_zarr_store.ims_zarr_store object at 0x7f48965f9ac0>
# The store object is NOT a sliceable array, but it does have attributes that describe what to expect after opening the store.
print(store.ResolutionLevelLock)
print(store.ResolutionLevels)
print(store.TimePoints)
print(store.Channels)
print(store.shape)
print(store.chunks)
print(store.dtype)
print(store.ndim)
zarray = zarr.open_array(store=store, mode='r')
print(zarray.shape)
print(zarray.chunks)
print(zarray.dtype)
print(zarray.ndim)
print(zarray[0,0,0].shape)
#(1024,1024)
###############################################################
### Process-safe store for multiprocessing / Dask workers ###
###############################################################
# The standard ims_zarr_store holds an open HDF5 file handle which is
# not picklable. ImsProcessSafeStore wraps it so that the store can be
# safely serialized across process boundaries (Dask, joblib, etc.).
from imaris_ims_zarr import ImsProcessSafeStore
import zarr
import pickle
store = ImsProcessSafeStore('myFile.ims', ResolutionLevelLock=0)
# Metadata attributes are available immediately
print(store.ResolutionLevelLock)
print(store.ResolutionLevels)
print(store.TimePoints)
print(store.Channels)
print(store.shape)
print(store.chunks)
print(store.dtype)
print(store.ndim)
print(store.resolution) # (x_res, y_res, z_res) in micrometres
zarray = zarr.open_array(store=store, mode='r')
print(zarray[0, 0, :, :, :].shape)
# Round-trip through pickle works transparently
store2 = pickle.loads(pickle.dumps(store))
zarray2 = zarr.open_array(store=store2, mode='r')
print(zarray2[0, 0, :, :, :].shape)
Historical Change Log (from imaris_ims_file_reader this was adapted from):
v0.1.3:
Class name has been changed to all lowercase ('ims') to be compatible with many other dependent applications.
v0.1.4:
Bug Fix: Issue #4, get_Volume_At_Specific_Resolution does not extract the desired time point and color
v0.1.5:
-Compatibility changes for Napari.
-Default behaviour changed to always return a 5-dim array. squeeze_output=True can be specified to remove all single dims by automatically calling np.squeeze on outputs.
v0.1.6:
-Return default behaviour back to squeeze_output=True so that the reader performance more like a normal numpy array.
v0.1.7:
-Add warnings when HistogramMax and HistogramMin values are not present in channel data. This is an issue when writing time series with PyImarisWriter. The absence of these values may cause compatibility issues with programs that use this library.
v0.1.8:
-Changed resolution rounding behaviour to make resolution calculation on ResolutionLevels > 0 more accurate
-Added option 'resolution_decimal_places' which enables the user to choose the number of decimal places to round resolutions (default:3). 'None' will NOT round the output.
-Added a new ims convenience function. This aims to be a drop in replacement with all previous versions of the library, but adds an 'aszarr' option. If aszarr=True (default:False), the object returned is a zarr store. zarr.open(store,mode='r') to interact with the array.
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 imaris_ims_zarr-0.2.0.tar.gz.
File metadata
- Download URL: imaris_ims_zarr-0.2.0.tar.gz
- Upload date:
- Size: 57.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef9ed4093c461f602eca64952dec6d4e725513b23142bff13f4b1800fc6a9502
|
|
| MD5 |
b57bb5eb5fe49f9b2c8e09e6ce1ea631
|
|
| BLAKE2b-256 |
203ef6404c3e16bbe56085dc7d4f814e5ee2d579d2cf0602e7f8b56a5236b3de
|
Provenance
The following attestation bundles were made for imaris_ims_zarr-0.2.0.tar.gz:
Publisher:
release.yml on khanlab/imaris_ims_zarr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imaris_ims_zarr-0.2.0.tar.gz -
Subject digest:
ef9ed4093c461f602eca64952dec6d4e725513b23142bff13f4b1800fc6a9502 - Sigstore transparency entry: 1510018396
- Sigstore integration time:
-
Permalink:
khanlab/imaris_ims_zarr@2a0e6a178057e23f6bd629fdda5233bfc4e9f490 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/khanlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a0e6a178057e23f6bd629fdda5233bfc4e9f490 -
Trigger Event:
push
-
Statement type:
File details
Details for the file imaris_ims_zarr-0.2.0-py3-none-any.whl.
File metadata
- Download URL: imaris_ims_zarr-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00ae95d4caa6449b3838a0540f6ca94afabaed9532afcfc9d9a32b69a45a1f87
|
|
| MD5 |
ff21d88f1a295c51a92202bd2474af02
|
|
| BLAKE2b-256 |
c0477dbdec41b18f4c9aa90240c8804482a8c4ada6db3d2844e287695cd42109
|
Provenance
The following attestation bundles were made for imaris_ims_zarr-0.2.0-py3-none-any.whl:
Publisher:
release.yml on khanlab/imaris_ims_zarr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imaris_ims_zarr-0.2.0-py3-none-any.whl -
Subject digest:
00ae95d4caa6449b3838a0540f6ca94afabaed9532afcfc9d9a32b69a45a1f87 - Sigstore transparency entry: 1510018478
- Sigstore integration time:
-
Permalink:
khanlab/imaris_ims_zarr@2a0e6a178057e23f6bd629fdda5233bfc4e9f490 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/khanlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a0e6a178057e23f6bd629fdda5233bfc4e9f490 -
Trigger Event:
push
-
Statement type: