Language Selection

Get healthy now with MedBeds!
Click here to book your session

Protect your whole family with Orgo-Life® Quantum MedBed Energy Technology® devices.

Advertising by Adpathway

         

 Advertising by Adpathway

4DZip compresses 4D-STEM vendor files losslessly into verifiable standard HDF5 archives

3 days ago 29

PROTECT YOUR DNA WITH QUANTUM TECHNOLOGY

Orgo-Life the new way to the future

  Advertising by Adpathway

A December 2, 2026 Applied Microscopy technical report by Hang Sik Kim, Hyun-Woong Park, and Young-Min Kim introduces 4DZip, a tool compressing Gatan DigitalMicrograph (.dm4) four-dimensional scanning transmission electron microscopy (4D-STEM) files into one standard Hierarchical Data Format version 5 (HDF5) file readable via h5py and hdf5plugin, restoring originals byte for byte. 4DZip hashes every restoration byte and verifies each archive in a separate process before acceptance on the instrument computer. Across 11 test files, every restoration reproduced the original SHA-256 digest, and none of 32,294 injected faults caused silent corruption. At a matched nominal dose of 75,400 electrons per pattern, an integrating camera’s floating-point output required 12.6 times (12.0 to 13.1 across the common dose range) the bits per pattern of a counting camera’s unsigned-integer output, while a lossy count-rounding copy reduced counting storage from 1.10 to 0.641 bits per pixel on one region at one dose.

4D-STEM records a two-dimensional diffraction pattern at each two-dimensional probe-scan position, enabling afterward computation of virtual bright-field (VBF) and annular dark-field (ADF) images, center-of-mass (CoM) maps, and nanobeam electron diffraction (NBED) strain maps. A 256 × 256 scan of 256 × 256-pixel patterns holds 4.3 billion values, or 17 GB at 32 bits each, while fast direct electron detectors record 1,000 to 120,000 patterns per second. Converters like py4DSTEM and HyperSpy convert .dm4 files to HDF5 without writing .dm4 or retaining all bytes to regenerate originals, forcing labs to keep both files for vendor software, raw-data policies, or unconverted metadata. Storage faults can also cause crashes or silent corruption in scientific software, and no prior report quantified the matched-dose storage gap between counting detectors registering individual electron events and integrating cameras whose processed values contain readout noise.

4DZip stores each .dm4 file as one .4dz HDF5 archive, tiling original bytes without gaps or overlaps into segments tracked by offset, length, kind, and 128-bit XXH3 digest (xxh3-128). In default array mode, the main four-dimensional array forms one segment while remaining bytes, including tag tree and thumbnails, stay verbatim as raw segments; ambiguous files use opaque mode as one raw segment. The array keeps native axis order and data type—unsigned 32-bit integers for the Metro counting camera and 32-bit floats for the OneView integrating camera—in chunks of eight consecutive fast-scan patterns. Chunks use Blosc1 with Zstandard (zstd) level 3 and byte shuffle under HDF5 filter 32001, exposing /data/frames to external readers. Preliminary tests favored byte shuffle over bit shuffle (0.670 to 0.934 times bit-shuffle size for Metro; 0.976 to 1.04 for OneView), while a sparse layout failed to shrink median Metro chunks.

Five integrity layers detect accidental corruption from disk errors, truncation, or inadvertent edits: the original SHA-256 digest; per-segment xxh3-128 digests; each chunk’s encoded-byte and decoded valid-region digests; a metadata digest covering every HDF5 object plus tag-tree and provenance digests; and a digest for optional preview and metric datasets. Because h5py with hdf5plugin skips these checks, 4DZip verifies them before decoding. Compression writes a temporary file, flushes via fsync, and verifies in a new process that rereads the archive, reconstructs segments and chunks without writing them, and recomputes all digests before renaming. Failed archives get an .unverified suffix, and archive-opening commands run in a watchdog-monitored child process in case corrupted files stall HDF5. Written in Python 3.12 as a self-contained Windows executable, 4DZip launches from Gatan Microscopy Suite (GMS 3.62) on JEM-ARM200CF and JEM-ARM300F computers without modifying or deleting originals.

Lossless evaluation used 11 .dm4 files from a JEM-ARM200CF at 200 or 80 kV on SrTiO3 [001] and hexagonal boron nitride (hBN) in NBED and convergent-beam electron diffraction (CBED) modes: six Metro scans (M1 to M6, about 31.5 stored units per detected count) and five OneView scans (O1 to O5, 26% to 48% negative values). With v1.0.0, all 11 files compressed in array mode and restored exact SHA-256 digests, while repeated round trips across worker counts reproduced original digests and byte-identical archives under the reproducible option. All 32 interrupted-write trials—31 killed mid-run—kept originals intact, blocked unverified files from final names, and reran cleanly. Load, path, permission, and synthetic 100 GiB round-trip tests passed except one inconclusive exFAT case, while h5py with hdf5plugin alone restored every archive’s SHA-256 across HDF5 2.0.0, 1.12.1, and 1.10.5.

For integrity testing, the authors injected 32,294 faults into three small archives from M5 and O3, applying single and multiple bit flips, burst overwrites, zero-filled 4,096-byte sectors, and truncation across every region, including HDF5 metadata and two unread regions, up to 300 injections per combination. None caused silent corruption: 29,035 were caught before restoration, and 3,259 were benign, leaving outputs unchanged. Across 103 combinations with 300 injections, the exact one-sided 95% upper bound on silent-corruption rate was 0.99%, with wider bounds in small metadata regions permitting fewer injections. Under bit flips, HDF5 caught superblock, object-header, and chunk-index errors; chunk digests caught chunk and digest-table damage; metadata, tag-tree, and provenance digests caught most global-heap damage; preview or metric corruption failed verification while reporting intact source data; and benign outcomes occurred solely in unused bytes, attribute and global heaps, and object headers.

Across the 11 datasets, storage cost differed 4.8- to 25-fold between detectors: Metro archives used 1.13 to 5.77 bits per pixel (ratios 5.56 to 28.3; data-basis 5.72 at 46% zeros to 1.08 at 92%), whereas OneView used 27.5 to 28.7 bits per pixel (ratios 1.12 to 1.16). Metro data-basis costs were 1.03 to 1.34 times stored-value entropy, while OneView costs were 1.03 to 1.07 times summed byte-plane entropies because its three lower mantissa byte planes held 7.95 to 8.00 bits of entropy. On Metro, byte shuffle drove gains over whole-file zstd level 3 (1.25 to 1.41 times 4DZip size), HDF5 zstd (1.26 to 1.41), and bitshuffle-LZ4 (1.35 to 2.60), while whole-file xz level 6 hit 0.892 to 0.952 times and 4DZip level 5 hit 0.917 to 0.979 times. On OneView, other coders spanned 1.00 to 1.07 times; xz suits rarely reopened archives, while 4DZip replaces vendor and analysis copies with direct chunk access.

For direct comparison, both cameras scanned the same BaTiO3/SrTiO3 [001] thin film in NBED mode at 200 kV on different days with the same probe (96 × 96 positions, 256 × 256-pixel patterns). Metro dose varied via dwell time (2.03 to 16.3 ms) and OneView via emission current (5.1 and 15.3 µA), giving nominal doses scaled from 2.5 pA at 15 µA. At three metadata-fixed reference doses with log-log slope correction, OneView’s floating-point output at 75,400 electrons per pattern required 12.6 times Metro’s unsigned-integer bits per pattern (95% spatial block bootstrap interval 12.4 to 12.7 with 32 × 32 blocks, versus 12.5 to 12.8 under the correlation-length rule). Because Metro cost rose with dose while OneView barely changed, the ratio was 13.1 at 70,100 and 12.0 at 81,100 electrons per pattern, and rounded Metro counts used 0.0410 times OneView’s bits—showing camera output mattered far more than coder choice.

For counting data, 4DZip also creates a lossy-count analysis copy storing rounded interior counts, original border-ring and saturated pixels, a mean-preserving per-pixel scale, and exact pattern sums and first moments. On the second of three 4.06 ms Metro scans of another BaTiO3/SrTiO3 region—spanning amorphous carbon, BaTiO3, and SrTiO3—the authors ran a prespecified equivalence test across VBF, ADF, CoM x and y, and four strain components from two registration algorithms, committing code, margins, and region of interest (ROI) beforehand. Against binomial-thinning noise estimates, all 24 tests and validity checks passed: added-variance ratios spanned 0.00400 to 0.0115 (upper bound at most 0.0120 versus 0.10), bias stayed within ±0.00314 noise units (margin ±0.1), and data-basis cost fell from 1.10 to 0.641 bits per pixel. A post hoc check on 5,487 SrTiO3 positions also passed (ratios 0.00452 to 0.0111). Unable to restore .dm4 files, this copy suits analysis and transfer alongside lossless archives.

Several limitations constrain these findings. The matched-dose comparison used one scan per camera with nominal doses assuming constant probe-current scaling across days, while high-dose-rate count loss—observed in M5 and M6—went unquantified in comparison and lossy-test scans. Integrity layers detect accidental damage without repairing corruption or catching deliberate tampering with recomputed digests; fault injection omitted large-archive structures like multi-level chunk indices; readers beyond h5py with hdf5plugin went untested; and interrupted-write trials omitted power loss, operating-system crashes, and network-share renames. Only OneView’s gain-normalized floating-point output was tested, lossy mode covers counting data only, and equivalence applies solely to eight metrics in one crystal ROI at one dose, excluding vacuum, thin edges, saturated pixels, ptychography, and quantitative CBED.

Subject of Research: Verifiable lossless and lossy compression of 4D-STEM electron microscopy data from counting and integrating detectors

Article Title: 4DZip: a verifiable lossless compression tool for 4D-STEM data from counting and integrating detectors

Article References: Kim, H. S., Park, H.-W., & Kim, Y.-M. (2026). 4DZip: a verifiable lossless compression tool for 4D-STEM data from counting and integrating detectors. Applied Microscopy, 56(1), Article 30. https://doi.org/10.1186/s42649-026-00150-w

Image Credits: AI Generated

DOI: 10.1186/s42649-026-00150-w

Keywords: 4D-STEM, 4DZip, lossless compression, HDF5, Gatan DigitalMicrograph, counting detectors, integrating detectors, Metro camera, OneView camera, Blosc, Zstandard, SHA-256 verification, fault injection, nanobeam electron diffraction, lossy count rounding, center-of-mass mapping, strain mapping, Applied Microscopy

Read Entire Article

         

        

Start the new Vibrations with a Medbed Franchise today!  

Protect your whole family with Quantum Orgo-Life® devices

  Advertising by Adpathway