Skip to main content

Crate openreadout_dcimg

Crate openreadout_dcimg 

Source
Expand description

Clean-room reader for Hamamatsu DCIMG camera streams (ORCA-Flash, ORCA-Fusion).

A DCIMG file is one camera stream: a file header, a session header with the frame geometry, the frames, and each frame’s camera counter and time stamp — in tables after the last frame (format version 7) or in a trailer after every frame (version 0x1000000). Frames are exposed as the time points of one image. Some cameras overwrite the first pixels of one sensor row in every frame and store their real values separately; the reader puts them back.

Derived from hex dumps of corpus files and the documentation of the dcimg Python package (MIT, Giacomo Mazzamuto); Bio-Formats is run only as a black-box oracle. Layout and vocabulary: docs/formats/dcimg.md. Provenance: docs/provenance/dcimg.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_dcimg::DcimgReader;

let format = DcimgReader.descriptor();
assert_eq!(format.id, openreadout_dcimg::FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::{FormatReader, PlaneIndex};
use openreadout_dcimg::DcimgReader;

let mut dataset = DcimgReader.open(Path::new("stream.dcimg"))?;
let info = dataset.info()?; // headers only
let image = &info.images[0];
println!("{} x {} px, {} frames", image.size_x, image.size_y, image.size_t);
// Frames are time points: read the third one.
let plane = dataset.read_plane(0, PlaneIndex { c: 0, z: 0, t: 2 })?;
assert_eq!(plane.data.len(), plane.expected_len());
// Camera frame counters and time stamps, one record per frame.
let (total, records) = dataset.frames(0, Some(10))?;
println!("{total} frames; first: {}", records[0]);

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§

DcimgReader
The DCIMG reader.

Constants§

FORMAT_ID
Format id used on the command line and in JSON.