Read PicoQuant(r) PTU and related files
Project description
Ptufile is a Python library to read image and metadata from PicoQuant PTU and related files: PHU, PCK, PCO, PFS, PUS, and PQRES. PTU files contain time correlated single photon counting (TCSPC) measurement data and instrumentation parameters.
PicoQuant GmbH is a manufacturer of photonic components and instruments.
- Author:
- License:
BSD 3-Clause
- Version:
2023.11.13
- DOI:
Quickstart
Install the ptufile package and all dependencies from the Python Package Index:
python -m pip install -U ptufile[all]
See Examples 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.9.13, 3.10.11, 3.11.6, 3.12.0 (64-bit)
Numpy 1.26.1
Xarray 2023.10.1 (recommended)
Matplotlib 3.8.1 (optional)
Tifffile 2023.9.26 (optional)
Revisions
2023.11.13
Change image histogram dimension order to TYXCH (breaking).
Change frame start to start of first line in frame (breaking).
Improve trimming of incomplete frames (breaking).
Remove trim_dtime option (breaking).
Fix selection handling in PtuFile.decode_image.
Add option to trim T, C, and H axes of image histograms.
Add option to decode histograms to memory-mapped or user-provided arrays.
Add __getitem__ interface to image histogram.
2023.11.1
Initial alpha release.
Notes
The API is not stable yet and might change between revisions.
This library has been tested with a limited number of files only.
The following features are currently not implemented: PT2 and PT3 files, decoding images from T2 formats, bidirectional scanning, sinusoidal correction, and deprecated image reconstruction.
The PicoQuant unified file formats are documented at the PicoQuant-Time-Tagged-File-Format-Demos.
Other Python modules for reading PicoQuant files are Read_PTU.py, readPTU_FLIM, PyPTU, picoquantio, ptuparser, and napari-flim-phasor-plotter.
The development of this library was supported by the Chan Zuckerberg Initiative.
Examples
Read properties and tags from any type of PicoQuant unified tagged file:
>>> pq = PqFile('tests/Settings.pfs') >>> pq.magic <PqFileMagic.PFS: ...> >>> pq.guid UUID('86d428e2-cb0b-4964-996c-04456ba6be7b') >>> pq.tags {...'CreatorSW_Name': 'SymPhoTime 64', 'CreatorSW_Version': '2.1'...} >>> pq.close()
Read metadata from a PicoQuant PTU FLIM file:
>>> ptu = PtuFile('tests/FLIM.ptu') >>> ptu.magic <PqFileMagic.PTU: ...> >>> ptu.type <PtuRecordType.PicoHarpT3: 66307> >>> ptu.measurement_mode <PtuMeasurementMode.T3: 3> >>> ptu.measurement_submode <PtuMeasurementSubMode.IMAGE: 3>
Decode TTTR records from the PTU file to numpy.recarray. Get global times of frame changes from markers:
>>> decoded = ptu.decode_records() >>> decoded['time'][(decoded['marker'] & ptu.frame_change_mask) > 0] array([1571185680], dtype=uint64)
Decode TTTR records to overall delay-time histograms per channel:
>>> ptu.decode_histogram(dtype='uint8') array([[ 5, 7, 7, ..., 10, 9, 2]], dtype=uint8)
Get information about the FLIM image histogram in the PTU file:
>>> ptu.shape (1, 256, 256, 2, 3126) >>> ptu.dims ('T', 'Y', 'X', 'C', 'H') >>> ptu.coords {'T': ..., 'Y': ..., 'X': ..., 'H': ...} >>> ptu.dtype dtype('uint16')
Decode parts of the image histogram to numpy array using slice notation. Slice step sizes define binning, -1 being used to integrate along axis:
>>> ptu[:, ..., 0, ::-1] array([[[103, ..., 38], ... [ 47, ..., 30]]], dtype=uint16)
Alternatively, decode the first channel and integrate all histogram bins to a xarray.DataArray, keeping reduced axes:
>>> ptu.decode_image(channel=0, dtime=-1, asxarray=True) <xarray.DataArray (T: 1, Y: 256, X: 256, C: 1, H: 1)> array([[[[[103]], ... [[ 30]]]]], dtype=uint16) Coordinates: * T (T) float64 0.05625 * Y (Y) float64 -0.0001304 ... 0.0001294 * X (X) float64 -0.0001304 ... 0.0001294 * H (H) float64 0.0 Dimensions without coordinates: C Attributes... frequency: 15258789.123471113 ... >>> ptu.close()
Preview the image and metadata in a PTU file from the console:
$ python -m ptufile tests/FLIM.ptu
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 Distributions
Hashes for ptufile-2023.11.13-pp310-pypy310_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2a25d2be9ae4140570b0afcfeae8846108e8c536de9580ba08a52daa13edc3 |
|
MD5 | dcce32e83b93e3512ee5f73087a6f5ff |
|
BLAKE2b-256 | a40eb1789b96b8e9d9fbd5ed19e1d0cbb46569e41543b0980b45af466c1791bd |
Hashes for ptufile-2023.11.13-cp312-cp312-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3082906abd246bb199f265a78bc92bba1661500999aa6e9dcf1ba033c69224 |
|
MD5 | ced9e827bd97d3aaa45244e3fd1d3462 |
|
BLAKE2b-256 | 0e6763efcbd4d4d072f222f0eff12236b7cadc8040ab8e95f335dc1d5597b877 |
Hashes for ptufile-2023.11.13-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf097dbc23715424870e7f83c834b4b5b59a1005e575dd51c4ef08214d262f6f |
|
MD5 | f9432205793464520295ba45f0b95b3d |
|
BLAKE2b-256 | aa4135852c2523debd7d62917af844220f546f232fd42e9030c3d5f1982ce66e |
Hashes for ptufile-2023.11.13-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3bbc63d1aa5e0a91c6f5caf2342ff5f5ebe3ae5e5faaf65a9eb9aad11cdd1de |
|
MD5 | 7ebdec31e60de937a74930ead254160e |
|
BLAKE2b-256 | 614373c50f099ed945cc7265e1d7782b7e87f608b59583465014237d8ef292cc |
Hashes for ptufile-2023.11.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1614f1db4526ec66769602946bb6857a143d5872735e5e82451c27a5c09ae61f |
|
MD5 | 8d1dd1b1bf52513a4b632936e6819b48 |
|
BLAKE2b-256 | f466ded1e801efd39e047b936149eeb877782c570d11ac19349302326e392ecf |
Hashes for ptufile-2023.11.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77418e45632ad594ff3e4df1d18355ada187138230849b33607bdee5f16ffb99 |
|
MD5 | 4b6aa0479a344a8147a9e7acab67cbca |
|
BLAKE2b-256 | b5f774224e90907d900d093f99fd9159f5ba38855b274368b56d919a01b4d533 |
Hashes for ptufile-2023.11.13-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 543f51126a6e573d01d414ffbc7042c155fa9f1e52c18d10a633c1317f74e54d |
|
MD5 | 020d7ef3b32e009cd6bd528cbe377e40 |
|
BLAKE2b-256 | a4b6e0797afabf7ccc79d7105ec9166bf204cddda3d69dfc5d5cd57c9b564e9c |
Hashes for ptufile-2023.11.13-cp311-cp311-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74381202acde3bc15323d46e47783f66214e2885c1fef5f155ba9dfe236b9a0 |
|
MD5 | 76b0e3658a527c4af0a4974a26af511f |
|
BLAKE2b-256 | cf224bd557c7a01e247a747d4590acf23fb805bda6b9102f4c1e786f7d8fbe77 |
Hashes for ptufile-2023.11.13-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b7c8854d20284b418a193e6c081803befc14526c1bcebffba77f9ba3579727b |
|
MD5 | 8324767e0b36bcfad75cb8763c656466 |
|
BLAKE2b-256 | a7326a1687636e55650e6fad61d20220f2e1c929bc0982179708e9109e2c0d90 |
Hashes for ptufile-2023.11.13-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7297bf46dba11c3da5dba4063f83e9da74f5d185f23447cf2fd4f5534872fdf4 |
|
MD5 | ab6256a88c6e52843f9b5e5306dd34bc |
|
BLAKE2b-256 | df15f21f21ddc3f75be372b4d2ee8a0be6f00bead685cb89879d16af01a61cd2 |
Hashes for ptufile-2023.11.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62f300826a5992aef20460b4e91d72487564cee7d4aee2bb3a08eabb669c59b0 |
|
MD5 | f960bfae5d10f6cdc04bc33714839897 |
|
BLAKE2b-256 | 89e04c25f6611348fd3722f0b09fef71c2c663931ab6af37c44a11b63da9e6f5 |
Hashes for ptufile-2023.11.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4daf1dedb84dd9e6058d32c34d25859f5a6ca2e4f1e13504bacb1ef3a4990fca |
|
MD5 | 966f543f1006a036907d82cab971c16c |
|
BLAKE2b-256 | a31034e8339167153bb2ab184555c5cc2b5dfd9a58c82c915f6766d9cbed66bc |
Hashes for ptufile-2023.11.13-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a45d4dba7ba4cbf27624105955897075f8d944c34c1dfd67777d89e3d3582bb |
|
MD5 | ee42fa06c9495f60d1970302d02a89f4 |
|
BLAKE2b-256 | 85f9041c5bf64591c1198855409907182a5b8f06af00a90af1ecbca065405dd4 |
Hashes for ptufile-2023.11.13-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4b70c04c5a33c2af505541b8ab707ce3773922d3b1bc34663c304a63c960981 |
|
MD5 | b8d2bc286eec25eddcfa088d44b5afb1 |
|
BLAKE2b-256 | b56ff8cdb5fe953551f28c721d1d47690923a647b2ca7036403b16b9d9b84c9a |
Hashes for ptufile-2023.11.13-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d526ebe7da3a8d979f77d46d268ab6890d0363bd3bf7f2adc2711509e69e4d7b |
|
MD5 | 8f7110b03b8de62b4fdc02f21f5bd1b0 |
|
BLAKE2b-256 | d80e3fc1ca152f2b8931a01075b566b69097c88e369e4baef01db078b33f1524 |
Hashes for ptufile-2023.11.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 106b207c49f3d553a7bf642dd9cb6eec890d2e6b8a4e9530e1c1f814ef113e6e |
|
MD5 | 6f62bb83337b0e45e7109a798adc19ba |
|
BLAKE2b-256 | 705e7c2f488a080e974cd81937233b5955edf021579990213a1a54b59e88a30f |
Hashes for ptufile-2023.11.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55af0a3aca14a30b93c97975a865a300094253dda2c4d463f379fb84dfff166b |
|
MD5 | 097e7089585bde8bc865d920c5d74ab2 |
|
BLAKE2b-256 | 2c32c6e5b8af63b14567f21eaa033c8829c4a4b6758597160597665619a1748e |
Hashes for ptufile-2023.11.13-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fad448dae663d883ba3c60831d58e7c8c488341a5492642770e577b802062b1 |
|
MD5 | 6d972be45d0319f3ef324f705a0f7c14 |
|
BLAKE2b-256 | 1c556c8ab55fb42b9e12b03af194f30dfc7152ba4913ee04823c70fb7714c311 |
Hashes for ptufile-2023.11.13-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f15065a46a160450f9d783a75d0c6b3c3d0136fb5dcc28ed13c1993da1ecb044 |
|
MD5 | 964f1e3f8adee548f2d413e698f75798 |
|
BLAKE2b-256 | 561d1b8f600e10b979f263326628f08775a2b0f79c591a5b3313f00058a6b4d9 |
Hashes for ptufile-2023.11.13-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6de55c1444cdf41e2498864c01dcc6cb7ee023ac2a2d9dde8d50281deba09f03 |
|
MD5 | 52cf4feace051081b2bbf7943ae20b47 |
|
BLAKE2b-256 | 37b302a1d46b1fa542f6d261370b203ef48aa3658f1297c0a845584319b24ced |
Hashes for ptufile-2023.11.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f326f4a8581560c08ace7af62fbbe5c64161227672e954d151d7d62f81cac67 |
|
MD5 | b901ed5b6a1d82dfac6e014e536d839a |
|
BLAKE2b-256 | 48e57ed36c77066fb8e41496b0e09355437b6f0e9d6b77566902e66a63312173 |
Hashes for ptufile-2023.11.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc202d086dafaed58bb9d70ed04ddaf93b5020aa439913017e536c690f65153a |
|
MD5 | 7756f43cb05275790526d661d38dc5f0 |
|
BLAKE2b-256 | 353a791fa1614e46a50b972461a44426cc38a4574ab22166ca5676b484e8b522 |
Hashes for ptufile-2023.11.13-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 502c1a9164da2c3210aa03d92091bdc871feba5ce9bdd8d27909379df57f4878 |
|
MD5 | 7646eb57c319f9c9d1a124b7da622ec0 |
|
BLAKE2b-256 | 2bbc70503c1f12d9b437e4d8601c1e785d02fd0abc52b7e3eeb39afe8eec200b |