Skip to main content

Read Becker & Hickl SDT files

Sdtfile is a Python library to read SDT files produced by Becker & Hickl SPCM software. SDT files contain time correlated single photon counting instrumentation parameters and measurement data.

Becker & Hickl GmbH is a manufacturer of equipment for photon counting.

Author:

Christoph Gohlke

License:

BSD-3-Clause

Version:

2026.11.6

DOI:

10.5281/zenodo.10125608

Quickstart

Install the sdtfile package and all dependencies from the Python Package Index:

python -m pip install -U sdtfile[all]

See Examples and Documentation for using the programming interface.

Source code and support are available on GitHub.

Requirements

This revision was tested with the following requirements and dependencies (other versions may work):

  • CPython 3.12.10, 3.13.17, 3.14.10, 3.15.2 64-bit

  • Numpy 2.5.4

  • Imagecodecs 2026.10.10 (optional for LZ4 compressed data blocks)

  • Lz4 4.4.5 (optional alternative to imagecodecs for LZ4 compressed data blocks)

Revisions

2026.11.6

  • Fix reading files with more than 32767 data blocks.

  • Fix BlockNo.module bit mask and repr (breaking).

  • Pad truncated uncompressed data blocks with zeros.

  • Return writable arrays for compressed data blocks.

  • Read compressed data block to end of file if next_block_offs is invalid.

  • Raise ValueError for invalid meas_desc_block_no, info, and setup blocks.

  • Sanitize contents and validate adc_re in sdtwrite.

2026.10.14

  • Limit decompressed data block size to block_length.

  • Log warnings and recover data for unexpected block sizes.

  • Raise ValueError for invalid meas_mode in sdtwrite.

2026.7.30

  • Add sdtwrite function.

  • Support SET files without measurement description and data blocks.

2026.7.17

  • Fix decompression of LZ4-compressed data blocks.

  • Add fallback to lz4 module if imagecodecs is not installed.

2026.7.12

  • Fix BlockNo attribute names (breaking).

  • Try power-of-two padded image shapes when block/adc_re > image_y * image_x.

  • Support LZ4 compressed and larger than 4 GB data blocks (not tested).

  • Update MeasureInfoExt structure with MeasStopInfoExt and MWL fields.

  • Use BinaryFile for file I/O.

  • Add simple CLI to preview data and metadata in SDT files.

2026.6.29

  • Fix reading SDT files with truncated embedded ZIP files (#8).

2026.6.6

  • Fix potential file handle leak in SdtFile init.

  • Add options for memory-mapping and locked reading to BinaryFile.

  • Add option to memory-map SDT files.

  • Drop support for Python 3.11 and numpy 2.0 (SPEC0).

  • Support Python 3.15.

2026.2.8

  • Derive SdtFile from BinaryFile (breaking).

  • Rename MEASURE_INFO.MeasHISTInfo to HISTInfo to match C struct (breaking).

  • Revise shaping of FCS_BLOCK data (breaking).

  • Fix code review issues.

2026.1.14

  • …

Refer to the CHANGES file for older revisions.

Notes

SDT files begin with a FILE_HEADER containing byte offsets to four sections: an ASCII info block, a setup block (ASCII and/or binary instrument parameters), one or more MEASURE_INFO records (CFD/TAC/ADC settings, scan geometry, timestamps, module identity), and one or more data blocks each preceded by a BLOCK_HEADER encoding the creation mode, content type (FLIM image, FCS, MCS, etc.), and element dtype. The data blocks are photon-count histograms shaped from MEASURE_INFO fields, typically (image_y, image_x, adc_re) of type uint16/uint32, and may be ZIP or LZ4-compressed.

Currently “Flow Data” are not supported.

References

  1. W Becker. The bh TCSPC Handbook. 9th Edition. Becker & Hickl GmbH 2021. pp 879. https://www.becker-hickl.com/literature/documents/flim/the-bh-tcspc-handbook-9th-edition-2021/

  2. SPC_data_file_structure.h header file. Part of the Becker & Hickl SPCM software installation. https://www.becker-hickl.com/products/spcm-data-acquisition-software/

Examples

Import functions and classes used in these examples:

>>> from sdtfile import SdtFile, sdtwrite

Read image and metadata from an “SPC Setup & Data File”:

>>> sdt = SdtFile('image.sdt')
>>> int(sdt.header.revision)
588
>>> sdt.info.id[1:-1]
'SPC Setup & Data File'
>>> mi = sdt.measure_info[0]
>>> float(mi.tac_r)  # doctest: +NUMBER
5.0e-08
>>> len(sdt.data)
1
>>> image = sdt.data[0]
>>> image.shape
(128, 128, 256)
>>> sdt.times[0].shape
(256,)
>>> sdt.close()

Write image and select metadata to an SDT file:

>>> sdtwrite(
...     'image_out.sdt',
...     image,
...     tac_r=mi.tac_r,  # required
...     tac_g=mi.tac_g,
...     col_t=mi.col_t,
...     pix_time=mi.pix_time,
...     compress=True,
... )

Read data and metadata from an “SPC Setup & Data File” with multiple data sets:

>>> sdt = SdtFile('fluorescein.sdt')
>>> len(sdt.data)
4
>>> sdt.data[3].shape
(1, 1024)
>>> sdt.times[3].shape
(1024,)
>>> int(sdt.setup.bh_bin_hdr['soft_rev'])
850
>>> sdt.close()

Read image data from an “SPC FCS Data File” as numpy array:

>>> sdt = SdtFile('fcs.sdt')
>>> sdt.info.id[1:-1]
'SPC FCS Data File'
>>> len(sdt.data)
1
>>> sdt.data[0].shape
(512, 512, 256)
>>> sdt.times[0].shape
(256,)
>>> sdt.close()

View the image and metadata in an SDT file from the console:

$ python -m sdtfile image.sdt

Metadata

Release files for sdtfile 2026.11.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sdtfile 2026.11.6
File Size Uploaded Provenance Actions
sdtfile-2026.11.6.tar.gz 35.5 kB Without provenance Details for sdtfile-2026.11.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sdtfile 2026.11.6
File Interpreter ABI Platform Actions
sdtfile-2026.11.6-py3-none-any.whl Python 3 none any Details for sdtfile-2026.11.6-py3-none-any.whl

Total release size: 68.8 kB

Release files / sdtfile-2026.11.6.tar.gz

Download URL sdtfile-2026.11.6.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0955e285fb619425f6efe5dd589bc93f011b662af9e84ea40fc308a6bb1d6db3
BLAKE2b-256 checksum
How to use checksums
92319c5be9def162859fa3094cd292f0de2f4f0bd9197d2e891f0e5c40c5a390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / sdtfile-2026.11.6-py3-none-any.whl

Download URL sdtfile-2026.11.6-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8b120eac3bfc3de32970b682d287c282d9a10eaf92fccdda1bef8722ddf388f
BLAKE2b-256 checksum
How to use checksums
75c2e108c502531adc60635177689e7d59c25a6b91056b4f67d6bf4827aa75a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for sdtfile 2026.11.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2026.11.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page