Skip to main content

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:

Christoph Gohlke

License:

BSD 3-Clause

Version:

2024.2.2

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.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 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, tttrlib, picoquantio, ptuparser, trattoria (wrapper of trattoria-core and tttr-toolbox), 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.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:      15258789.123471113
...
>>> 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.2.tar.gz (38.0 kB view details)

Uploaded Source

Built Distributions

ptufile-2024.2.2-cp312-cp312-win_arm64.whl (143.1 kB view details)

Uploaded CPython 3.12 Windows ARM64

ptufile-2024.2.2-cp312-cp312-win_amd64.whl (174.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

ptufile-2024.2.2-cp312-cp312-win32.whl (143.7 kB view details)

Uploaded CPython 3.12 Windows x86

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

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

ptufile-2024.2.2-cp312-cp312-macosx_11_0_arm64.whl (190.8 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

ptufile-2024.2.2-cp312-cp312-macosx_10_9_x86_64.whl (208.0 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

ptufile-2024.2.2-cp311-cp311-win_arm64.whl (142.1 kB view details)

Uploaded CPython 3.11 Windows ARM64

ptufile-2024.2.2-cp311-cp311-win_amd64.whl (171.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

ptufile-2024.2.2-cp311-cp311-win32.whl (141.2 kB view details)

Uploaded CPython 3.11 Windows x86

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ptufile-2024.2.2-cp311-cp311-macosx_11_0_arm64.whl (186.1 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ptufile-2024.2.2-cp311-cp311-macosx_10_9_x86_64.whl (205.3 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

ptufile-2024.2.2-cp310-cp310-win_amd64.whl (169.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

ptufile-2024.2.2-cp310-cp310-win32.whl (141.6 kB view details)

Uploaded CPython 3.10 Windows x86

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ptufile-2024.2.2-cp310-cp310-macosx_11_0_arm64.whl (188.3 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ptufile-2024.2.2-cp310-cp310-macosx_10_9_x86_64.whl (205.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

ptufile-2024.2.2-cp39-cp39-win_amd64.whl (170.2 kB view details)

Uploaded CPython 3.9 Windows x86-64

ptufile-2024.2.2-cp39-cp39-win32.whl (142.2 kB view details)

Uploaded CPython 3.9 Windows x86

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ptufile-2024.2.2-cp39-cp39-macosx_11_0_arm64.whl (188.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ptufile-2024.2.2-cp39-cp39-macosx_10_9_x86_64.whl (206.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: ptufile-2024.2.2.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for ptufile-2024.2.2.tar.gz
Algorithm Hash digest
SHA256 b9988579ef6d2948f7080bddee67ef762a75df9e0689d34b5700fc31bc0722e7
MD5 2baaefb71b57408fdfe5948670762ff4
BLAKE2b-256 59c0263de64c77e479f6053811dfcaca6b0afe5b93b2a3a722630b7018bd02d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 c2aaae81a9fd7af22521b1b32f52909603662dc55b6deaf8bcf33ab83d9a0d24
MD5 52acf06e82e07c75247ba6b95a5dcfc4
BLAKE2b-256 87e313203926d9c7b5ea0452e607bd5681bb4a26e37e0e5c1d1fcc92a6be7509

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c0fcdf5715b98ccc9baac7c0d472a9a02499076c2f4ff0b5fcf63f90bd8766e
MD5 3803fe28167593491f04618aaa896eb6
BLAKE2b-256 c7b2ae9aa02108ab44a1d94aa16983ed98fd7b5a8e55ff82bfe6e717aca52472

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.2-cp312-cp312-win32.whl
  • Upload date:
  • Size: 143.7 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 672d6fd5da12c7a01edc9494b11882b42e15b3b31db361867e74eee815d19c3f
MD5 17db2fa005a5615f5d66da0f9cca2ce6
BLAKE2b-256 499aa5004e21363c5eaf6195d825995635507415230780348e5dc17ad8ea63d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0813ca702ad5c906f070779e90442f0bf75f73ac3ced36b2e660cc81cbd1123
MD5 5f396b1a79164699b241b4d63aba158f
BLAKE2b-256 70cc4b7305be477efd098fa89395c04ac6b5792e2537aa1ec94cc7da63b50910

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14a156e85e41084699ffb19c06f5364926b9bd1d2449c32e3d97fca821de708d
MD5 6372c11cb4f2b529b6eb95fc76e658c5
BLAKE2b-256 75bf8673df9586c36a02bc0225bb23e8fb1aba873c5d27bb9b2aac2f3fecf390

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fe10ceeea2ea1e1893ff5f61543dd70b50bdc605bf93bcb0a6cc56ca78ae8996
MD5 1eb544ecac26a593714458ecd36b9574
BLAKE2b-256 35a0593b09eecf8b65a81973093ef86f30ea331504bbf372340cd27e0ee104b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 18d24518c644142b01580b561aa26b88e7cc7fb2edef991b5ff000453f5d07d2
MD5 f2dbcf650da6d40fcf40353de3248d4f
BLAKE2b-256 56375ea787925f8a9028ee5d6786d6fb924f64df7a9a8df1bb3bef4069b13ade

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6faf5acf599cbad5aa2289f9089f66af9b6273ce4339c63df3d24bb200e0a30e
MD5 86d228165e8f2af701ba686f8fa3d4da
BLAKE2b-256 44f96742c9f36c20385f244b18ef8c6d52f60b179b1595ebff939aeedf05975f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.2-cp311-cp311-win32.whl
  • Upload date:
  • Size: 141.2 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 ae131ac4cde1406d8796fcf6f358da1320022e2cc204a32d6523d9718c752ddb
MD5 ca3735f1f4f02d8893d820bbe931e56f
BLAKE2b-256 54e3b9488d80b3377d8e10b1c88a947da2885505e5111b27707b8e6d558e2adf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19155d28ca57b588a8c77365f6f0e9b4280bd0aaea62e1b0494b185eddc02434
MD5 c34055d270c766ae804cc5988f7e5390
BLAKE2b-256 ba3d5bd6e45d809efda29dfdb54b648b4b4a0f992de8bc7cffa03f9d1f9ad07c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8a0e12e33c235ec3137ff4a8e94063d0febcfa218df48dee72242a1532f6bb4
MD5 35ed3144849ba89a99c864f8ef01ca1b
BLAKE2b-256 c7b3d4d260529f728096bc967e0c4c91d85713276680bf559e7292212dacb68e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4efb1233a40ec94ae637aab8c9f23a755c1f3bd472b40b90775e840e5039f25a
MD5 ebad03f8fac4ddd1a3973d16e53ebb7f
BLAKE2b-256 cd4f2795813cde9a323e7c042c76c3ef7b272d6c1a24ffe9f6214f7ccc02d13c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e2b8255a34dff4e257be3e93268fcae1ca8337f24d8d9019572cb60b73967dfe
MD5 a420070ebf4ee1564141d7995dc2e4ab
BLAKE2b-256 7847fcf633f92e7098c8ef48d02d67874da84636633818e7449e4d68a2d95f5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.2-cp310-cp310-win32.whl
  • Upload date:
  • Size: 141.6 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for ptufile-2024.2.2-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 f8088e03b216866695ff2f85cf5c5c85e1640c1c0e00accd733fb2e4de7d22e2
MD5 c572a23160e4a27ac3bfe6ae3d5771cc
BLAKE2b-256 822d05fa19a8bd78a831bd14084d4410cd40171cd5bca2292e78ea64de026ca1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5419ab42d4c505f35da163222b13aed990936e41cf50a0b50bb703612a0553a3
MD5 f3e0fd62938c858ce3467f495923013c
BLAKE2b-256 079bd7aba452a0a07f2ec50b19a19a2b88dc8a16ef3ddae6d8de572b3a5b7613

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 046820688437d50087c88c672bf61e705a7c487eea49d59b8045460bb010e82d
MD5 3a8b877f1b8c420c479fb748a8851278
BLAKE2b-256 dbe6e70b86577bb817ee38ebbcbef07cef2f5b5c36608cca20fff65a7f7f7fe7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4163d413b002abf19633cf8b5f34b90c9454243971a97666ec13557d40a07966
MD5 b8f493404f701188eb5e12b8d9cbbd69
BLAKE2b-256 1cbf0c7e0a9c199985c8e01be6c7929058c466a9d51cba33b06f72fb2c051606

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b2fe685fc2d5ecc13e424f39ba9f8f9b7f2296d84ade42c2ccd1a0df23ea6d0d
MD5 58085f384472f2f62bd43fe98f25e564
BLAKE2b-256 6b2da17602d6c6104e2afaff3650e64539f7372ca490129017f57aa0113bd245

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.2-cp39-cp39-win32.whl
  • Upload date:
  • Size: 142.2 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for ptufile-2024.2.2-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 315792b5d7720d72f9c912f6793d34211d3772b93214b47f382f72012a851e93
MD5 0269bb656906af69f740fb5a5be8093b
BLAKE2b-256 32fda560187615df91e83f2260bdd639330884c20771a888bfef3617f1228c38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9e187d7e5485be841d6e0da0aa3b009699ee1ece1b30bca566b869767247f6a
MD5 3606d6dcad74a8cc5b5a29cea8e5c0db
BLAKE2b-256 ef208a0c69e3a1cacdf7082c613e1d4dd4facb3c377f6775aed9f35f0d391ebf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 10aff19c2e77c782480acf740fb4f0fa029942fe5da5c28847a4256e3cb2196f
MD5 a4f2f5356977220998fc8729cf0b0c9f
BLAKE2b-256 60e9de93d97cbc3a7483169caf042c7a04b956cf97237a940ebe6d05274a0f41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 04c3cea13d77f4e462586dac51ff67f5abe1be4ad37766b874b1a8688d38c032
MD5 375f733bb5aa90f3cd1de3b5bf65f20b
BLAKE2b-256 4db5d40bad3ba029a703537299e5c019b3ba9cfa8d9113a467abe7c87423161a

See more details on using hashes here.

Supported by

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