Skip to main content

Read PicoQuant 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.

Author:

Christoph Gohlke

License:

BSD 3-Clause

Version:

2024.2.20

DOI:

10.5281/zenodo.10120021

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):

Revisions

2024.2.20

  • Change definition of PtuFile.frequency (breaking).

  • Add option to specify number of bins returned by decode_histogram.

  • Add option to return histograms of one period.

2024.2.15

  • Add PtuFile.scanner property.

  • Add numcodecs compatible PTU codec.

2024.2.8

  • Support sinusoidal scanning correction.

2024.2.2

  • Change positive dtime parameter from index to size (breaking).

  • Fix segfault with ImgHdr_TimePerPixel = 0.

  • Rename MultiHarp to Generic conforming with changes in PicoQuant reference.

2023.11.16

  • Fix empty line when first record is start marker.

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 Chan Zuckerberg Initiative financially supported the development of this library.

PicoQuant GmbH is a manufacturer of photonic components and instruments.

The PicoQuant unified file formats are documented at the PicoQuant-Time-Tagged-File-Format-Demos.

The following features are currently not implemented: PT2 and PT3 files, decoding images from T2 formats, bidirectional scanning, and deprecated image reconstruction.

Other Python modules for reading PicoQuant files are:

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.

>>> decoded = ptu.decode_records()

Get global times of frame changes from markers:

>>> 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.ndarray 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:      19999200.0
...
>>> ptu.close()

Preview the image and metadata in a PTU file from the console:

python -m ptufile tests/FLIM.ptu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ptufile-2024.2.20.tar.gz (45.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ptufile-2024.2.20-cp312-cp312-win_arm64.whl (147.5 kB view details)

Uploaded CPython 3.12Windows ARM64

ptufile-2024.2.20-cp312-cp312-win_amd64.whl (177.5 kB view details)

Uploaded CPython 3.12Windows x86-64

ptufile-2024.2.20-cp312-cp312-win32.whl (147.3 kB view details)

Uploaded CPython 3.12Windows x86

ptufile-2024.2.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ptufile-2024.2.20-cp312-cp312-macosx_11_0_arm64.whl (195.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ptufile-2024.2.20-cp312-cp312-macosx_10_9_x86_64.whl (211.2 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

ptufile-2024.2.20-cp311-cp311-win_arm64.whl (146.3 kB view details)

Uploaded CPython 3.11Windows ARM64

ptufile-2024.2.20-cp311-cp311-win_amd64.whl (174.0 kB view details)

Uploaded CPython 3.11Windows x86-64

ptufile-2024.2.20-cp311-cp311-win32.whl (143.9 kB view details)

Uploaded CPython 3.11Windows x86

ptufile-2024.2.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ptufile-2024.2.20-cp311-cp311-macosx_11_0_arm64.whl (190.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ptufile-2024.2.20-cp311-cp311-macosx_10_9_x86_64.whl (208.5 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ptufile-2024.2.20-cp310-cp310-win_amd64.whl (173.9 kB view details)

Uploaded CPython 3.10Windows x86-64

ptufile-2024.2.20-cp310-cp310-win32.whl (144.8 kB view details)

Uploaded CPython 3.10Windows x86

ptufile-2024.2.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ptufile-2024.2.20-cp310-cp310-macosx_11_0_arm64.whl (192.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ptufile-2024.2.20-cp310-cp310-macosx_10_9_x86_64.whl (207.1 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

ptufile-2024.2.20-cp39-cp39-win_amd64.whl (174.4 kB view details)

Uploaded CPython 3.9Windows x86-64

ptufile-2024.2.20-cp39-cp39-win32.whl (145.4 kB view details)

Uploaded CPython 3.9Windows x86

ptufile-2024.2.20-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ptufile-2024.2.20-cp39-cp39-macosx_11_0_arm64.whl (193.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ptufile-2024.2.20-cp39-cp39-macosx_10_9_x86_64.whl (207.7 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file ptufile-2024.2.20.tar.gz.

File metadata

  • Download URL: ptufile-2024.2.20.tar.gz
  • Upload date:
  • Size: 45.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20.tar.gz
Algorithm Hash digest
SHA256 b1c2d78e914929b5fda204afff1b6ee096a6c3dccaf72af97f626bb23bb8d73c
MD5 3a3ca59036071f2e33aed8c1fb744fe3
BLAKE2b-256 2dd9322903e21d872f120f7399326ba9349e35e4366c8018eea833a52e284fe3

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-win_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 aea34925d908fb401627ba976aeaddb3e3697db357fc24784b1e98cbb2cbacae
MD5 41be5ac3f7ad899d4c01e6d84ef4dc0f
BLAKE2b-256 060d4d2ea6abff91ba91f71998f91728e6aff5d298b499084b3ce1b68035a93c

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3ae05641a87f49fc153552772155eceb6b50ef240a44c20fb467326289e17837
MD5 88143ebea71381f1173994fe3a793cbb
BLAKE2b-256 d734c9deec7d40af591c467366d68bf0f81a95d4e7a23885aa75fb69b81533ea

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-win32.whl.

File metadata

  • Download URL: ptufile-2024.2.20-cp312-cp312-win32.whl
  • Upload date:
  • Size: 147.3 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 206cf45a685ec53b6dec7860b07006b077f75d3d0bdecfa0a2570a75a15e32fa
MD5 a49f7e56df5dfe1b8ab48a96d4729bef
BLAKE2b-256 91d7b86b8fc14ebaa6880737866fd6f133d7880e91e6667fed4c265059ba0fae

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3d7b3930c8758689d48cf8891bca18814389466d6eee1e57e3bf3dab36d2cdc
MD5 6073cc7943706446215572d38c47823d
BLAKE2b-256 9d2c88efb7148989aa0690587deac97bb70a65e557e3796b2bd613c5b925b573

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 037472d1ef81b3318330fcfc927ddd108c1baafdff5f67b41d164a4521fe609e
MD5 10fe822c8829b67326aa2f94a35f4701
BLAKE2b-256 8d88e0280cc12232d1891c1792aaa74cdf7c1707b7d634e6e45d48103d640219

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cd47ba6f735ab8433fe37b3426a4fdd620c1885503bb8f6be8da46daddcf68c5
MD5 b7ea43a0ab683a8f9b4534000ddee8ec
BLAKE2b-256 98d7487f8b69074d58eb8c4a8b12eac17ab08cdddb4fca67cfe4acd0d30caf87

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-win_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 6d5f6a3fd6c737a316d728b63e0de947f6d3695a7700cb57f3bd5a9cebabf74d
MD5 f4d8d6ec2bff338de6132f6a28c3e8aa
BLAKE2b-256 38527dd4789cb1831b9182c8fce96a208232ebb9cec14d8fcdb26dba11624028

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 caef6c16e458de494278e4bb7877ad07d8718be1694c6a419b97279ff1bfcc3c
MD5 3dc1b9a460f714037dfa1b1de5b7865d
BLAKE2b-256 a4d41d0c85280b6ab19721636b7e4094783da7a745f5fa8346693d6b9d3dc859

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-win32.whl.

File metadata

  • Download URL: ptufile-2024.2.20-cp311-cp311-win32.whl
  • Upload date:
  • Size: 143.9 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 159f44302dfb677f8f0d586814e526ca050c1c515de2788b7cf1ece52b4e0c9e
MD5 df96885a42adb9c23853f8ddff368074
BLAKE2b-256 1c10279877ceefd2713931aced924eb38d562f5db084a6773cacc2859f35b19a

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30079344ff971325cfa64d76815de022491725bc97380783685ac1ddabb20d50
MD5 34689177a7c6bed79b338319ffb9a503
BLAKE2b-256 a91828b2d845b70753680c0a6e9bc4a61e3ec99f89a396f8e18cc3fca3627953

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24c360be858a847603b24c8951e078b92b89ada6bcf95e45540dade220c4a06d
MD5 80342f137a83e1f575b86b6b1aa53eba
BLAKE2b-256 97f6b9720630784ec4cbdd9ae54de2455de024c9dc98d35ea0e1cc024478a36e

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b397b706206fd93b27b4716ecaf99ec75b9032b45454ef435426f12298e19d9c
MD5 935e72331094747286854925e0f5c12e
BLAKE2b-256 97e0c40ff75b528435527a90937c9176f2d9407103e2487709fccb05898eb6f1

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1079516739e8f31ca51096015999e762b08855c99edce85e103d6dc71d86942e
MD5 0c2ba4a8c53a7b6136f36cf5beaf6eb1
BLAKE2b-256 e0f0668453ccd758ecbb358198b91a5c9f7c58f2fdb7289918c196c5cbd1648c

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp310-cp310-win32.whl.

File metadata

  • Download URL: ptufile-2024.2.20-cp310-cp310-win32.whl
  • Upload date:
  • Size: 144.8 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 c5fc2f4614edeaecd3b5190a37679c1130b357a3c76305c707aef7b7751c6c88
MD5 eda75f5251a21011aff3d9641f3aa115
BLAKE2b-256 8e4c138c1969745dfe5254eb4049cc1dcacbd1ff635accb8b96cc59188853b05

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fbd1516db4e2a4425c5923ef8404eb8f1405089bd33d7e9456191ef2e69d620
MD5 f12951d72ce2905804d884ee5c5b1f5e
BLAKE2b-256 4d569aa484cd33db0c2eed69ebed9d6ba17f0b730cf78bd2f0c68aa99b17e194

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2bbc825b55e93956b1a8fab6e9c57ce071187402ee6612d2fa6f547aeb877430
MD5 ac2112dae70076ba91ca78b848c09c2e
BLAKE2b-256 dd7ddad9923bf68307ac653c9f2dc48f9c5bc97d685ccd7648429e1f4c9b6ee3

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dadcfcdeb904c97ed36f3a0f25b2026d637afca760bf8cbc6131ebee791723f4
MD5 2d43fdcc13ee1c3ceaa319539471d061
BLAKE2b-256 60a4c045716d62409fe338f6de8b3d4b134c14fac5d9144fbc9e8d3fddfd4538

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ptufile-2024.2.20-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 174.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 72d870b563f52d4a5b1670a7c7a5fecd45d5ad30665f7371867090dab0725982
MD5 de77936bd236b34f7543c501fc39ca86
BLAKE2b-256 674ecd6e8b00f76a26519e28ff4757878baed66a2c7e1c9e0a918b36cebd0c96

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp39-cp39-win32.whl.

File metadata

  • Download URL: ptufile-2024.2.20-cp39-cp39-win32.whl
  • Upload date:
  • Size: 145.4 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ptufile-2024.2.20-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 fdcb93278c264487feb59e99ff8a78fa4b3287024f32653d4110931dabf0a2c6
MD5 6f7c2c8ffd6e5d9a694df335e95514fe
BLAKE2b-256 c32a0a1b0b9faeb17ad7b1804d4b173daa1cada7a48b8c6077c6bfa301157699

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0797bc4b264f68e5659d83483b888378fec1efa170b88f1aaa5f70a51aba3b69
MD5 84c46b4ef7e5ddda45ea9c232ec3d0d6
BLAKE2b-256 69059adaf2c9f5b41a536c0c5b5bdc151de37d4d7b0b2f738b6fee684ef922e5

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c81f057ab7477508a55f1938895bfe7ac5f4a48e48acad9484b330876e40b62
MD5 8eb1b5ba616990aad61aaf04eaa4288c
BLAKE2b-256 d39acbd137603a318bcfbfd3ce403749a8ff7053ee2b4a306bddc83236c9bd3c

See more details on using hashes here.

File details

Details for the file ptufile-2024.2.20-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ptufile-2024.2.20-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6dd0d6882e75e29d99bc3cd2318ec408b4407a9076493beaf3c24544eec70b26
MD5 f4c2ac60c4cf124b4d765872cc4971f7
BLAKE2b-256 668ea2e8358c35e3c70ee7e7fc74209af7ba8470b5c1582643d14d28a9b6fd7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page