Skip to main content

Crate openreadout_hdf5

Crate openreadout_hdf5 

Source
Expand description

HDF5-based formats through the pure-Rust hdf5-pure crate: Imaris .ims volumes (pyramids, LZ4/deflate chunks), NWB 2.x (session fields, plain TimeSeries as traces), NeXus NXmx diffraction images (EIGER master and data files, bitshuffle/LZ4 chunks) and a generic HDF5 fallback whose info --view structure lists groups, datasets and attributes.

Layout and vocabulary: docs/formats/ims.md, docs/formats/hdf5.md, docs/formats/nxmx.md. Provenance: docs/provenance/ims.md, docs/provenance/hdf5.md, docs/provenance/nxmx.md.

§Example

Every reader implements openreadout_core::FormatReader: descriptor says what it reads, sniff recognises a file from its first bytes, and open returns a openreadout_core::Dataset with a header-only info() summary and lazy data access.

use openreadout_core::FormatReader;
use openreadout_hdf5::ImsReader;

let format = ImsReader.descriptor();
assert_eq!(format.id, openreadout_hdf5::IMS_FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::{FormatReader, PlaneIndex};
use openreadout_hdf5::ImsReader;

let mut dataset = ImsReader.open(Path::new("volume.ims"))?;
let info = dataset.info()?; // headers only: fast even on multi-gigabyte files
for image in &info.images {
    println!(
        "image {}: {} x {} px, {} channel(s), {} plane(s)",
        image.index, image.size_x, image.size_y, image.size_c, image.plane_count
    );
}
// Pixels are read one plane at a time: image 0, channel 0, first Z slice, first time point.
let plane = dataset.read_plane(0, PlaneIndex { c: 0, z: 0, t: 0 })?;
assert_eq!(plane.data.len(), plane.expected_len());

Applications that accept any instrument file usually register every reader in an openreadout_core::Registry and let it detect the format; that is what the openreadout command-line tool does.

§API stability

The supported API is what this page documents. The parser modules are public only so that tests and fuzz targets can reach them: they are hidden from this documentation and may change in any release.

Structs§

Hdf5Reader
The generic HDF5 reader (a loose detector: registered after the HDF5-based formats).
ImsReader
The Imaris reader.
NwbExportOptions
What to write.
NwbExportReport
Output of export --format nwb.
NwbReader
The NWB reader.
NwbSeriesReport
One TimeSeries written.
NxmxReader
The NXmx reader.

Constants§

HDF5_FORMAT_ID
Format id used on the command line and in JSON.
IMS_FORMAT_ID
Format id used on the command line and in JSON.
NWB_FORMAT_ID
Format id used on the command line and in JSON.
NWB_VERSION
NWB schema version written in the root nwb_version attribute.
NXMX_FORMAT_ID
Format id used on the command line and in JSON.

Functions§

default_nwb_output
Default output path: <stem>.nwb (<stem>.traceT.nwb, <stem>.sweepS.nwb when selected).
export_nwb
Export the traces of ds to output as NWB 2.x.