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.4.24

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.4.24

  • Build wheels with numpy 2.

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.4.24.tar.gz (45.2 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.4.24-cp312-cp312-win_arm64.whl (147.5 kB view details)

Uploaded CPython 3.12Windows ARM64

ptufile-2024.4.24-cp312-cp312-win_amd64.whl (177.6 kB view details)

Uploaded CPython 3.12Windows x86-64

ptufile-2024.4.24-cp312-cp312-win32.whl (147.4 kB view details)

Uploaded CPython 3.12Windows x86

ptufile-2024.4.24-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.4.24-cp312-cp312-macosx_11_0_arm64.whl (195.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.9+ x86-64

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

Uploaded CPython 3.11Windows ARM64

ptufile-2024.4.24-cp311-cp311-win_amd64.whl (174.2 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

ptufile-2024.4.24-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.4.24-cp311-cp311-macosx_11_0_arm64.whl (190.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ptufile-2024.4.24-cp311-cp311-macosx_10_9_x86_64.whl (208.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ptufile-2024.4.24-cp310-cp310-win_amd64.whl (174.1 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

ptufile-2024.4.24-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.4.24-cp310-cp310-macosx_11_0_arm64.whl (192.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 10.9+ x86-64

ptufile-2024.4.24-cp39-cp39-win_amd64.whl (174.5 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9Windows x86

ptufile-2024.4.24-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.4.24-cp39-cp39-macosx_11_0_arm64.whl (193.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ptufile-2024.4.24-cp39-cp39-macosx_10_9_x86_64.whl (207.8 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.4.24.tar.gz
Algorithm Hash digest
SHA256 c8053ce5ba1af696ce9ea42db5ed1701e242f2d222a5a4a39cb01a2f0d2e57f8
MD5 00a2f37deb58998e5a70a641b95e4df5
BLAKE2b-256 091b4ccbbd05696aade530eee2626bc99696f17630b9fd9ba3a55dddcabdb666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 46bd652cd98bcb7e9f689ffd32a121f54b71b27ef1dbd55babb79686c60c6906
MD5 b50547f257b7eb5ed6b4741ee15d62b9
BLAKE2b-256 6415530760d9e2a74383e32768e65142009f56885af1291626c7803a4d9355a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fa8d178efdd7bc033600438e66bd95815d4ae177cf205d20fb325e015d712441
MD5 5a3044750d66a35a112bc678fc0ecf13
BLAKE2b-256 8b3ac3446930469eb3c3e07416eff1f33024f41519bbd8f9fcd047d4badc7c77

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 81dd20d74ff3d5a11104d856596e401854fd2b7a80c21158bd05c3085a4b5af4
MD5 0f37b95f78c60e96e2e089203a7506f7
BLAKE2b-256 e54c4e16638674edc4849d10d28fe4c25174da254b3b796fa293cc953d29df3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd4c2546507a1ec485cb2a7d735df1af61412b2ec8fce92b09284cbe3142c214
MD5 4863281483ba70e6b55d20e2ea7ebf8a
BLAKE2b-256 75c081f5fc55652a8dc33a03a656379897083e3392204c47a88dfb7e4e40d1f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84354acde3e57fb443aab3c25060a5eda580c2a07e8af35d41a6b2498a46c7a5
MD5 929c52966663748232c2689a8bb41efd
BLAKE2b-256 ca5e555abda783fd6e8a005c651b3d5061a32e31d8ea17e3cb360eb8bb97da40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f701a93ef73622615a58bbd1bca5caa76bee05ef7c3652108d091983cfedf6b2
MD5 f4fc9194581eef2d50db40421ca8a7aa
BLAKE2b-256 ebd1043ea97e1a45726f9e3e18c5bcd2c53ebc42ebb2b708291b5b5f9700bef0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 9a7383e3527bf7e4bd481daccf951cf20dea21e7d4a88030c3f40a6ed32bfd4d
MD5 727cd821264cb9f45cc0e1ca311e0f00
BLAKE2b-256 cd86fe8e694fb878c72f6ed0dba3f159995a56bfcc483a06029db3fe9730d4b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4ef447d27bb3982ebcbd02381d775adcdd6ace73d764c72d561fd84f7db4c592
MD5 1580a822bc22471cd60c21ab2fd46fa0
BLAKE2b-256 80a52e3705824f7fd073e103cb7f1c0b48a79073f3942c106f6057f31f136ab9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.4.24-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.12.3

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 8095d1b69b16dc406b7fc8afd47adeb4b71e1404e2ac92abcc07dcf1dddbf424
MD5 ccdcb509a76a297a57ffd1973e097209
BLAKE2b-256 03649f178fb89cade58ed55401bf4f5d9accedccaedca0d56b9060e8d5c60fb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89afcdd11f65e77f3a91d319482a8c6ce3053562532eae3d07fde4aa2992a2e3
MD5 b2c143f746c36911f51c8a914076ca0f
BLAKE2b-256 c1cae8df252986763156f11b539968167daf109f709b7030a2990fa70f87eb18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66e8025d27ac51b11e07435d4d9f1a1fddf23f09a3de6d28b17d2fb2ac6617bb
MD5 c2978f7efd04a85a1bbb1a18ed9ad6bf
BLAKE2b-256 95259a1bf4cfe198e8553e276bca63f1a0b1f12d95966f95bc9623fc387e8d1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c5a7f167d4d5b40406647505447f5aa2ce2ac53381042b8e42816776ef1c8a74
MD5 15f0ab4465c46ac92682939843ae0191
BLAKE2b-256 83c84edb1de1f00093870e04bf58ad26ed28a6c477b86e589ee90d037f5ac369

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f36227b36b522b02ae75f2dba3338d2490648db87af7a7f0da0f2e50acdb7a94
MD5 76beb14ad9f1a7634e81892500bd92c3
BLAKE2b-256 5118beb68fbcd109f45e5eedbfa5b12e3e58076d1dd22497ab806c58b36828a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.4.24-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.12.3

File hashes

Hashes for ptufile-2024.4.24-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 292e52dff67b5a2f08c95c06ce40aea652b594afa21f19602ab69bdc21a2ba40
MD5 4aa3be0e53741a502a234f30c8b3356b
BLAKE2b-256 ca7b18b6aa25c2f973921529f430fcc10d7361fcdb12b9d819ce84107ed3bf36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 536d7091132a30a8ba7bfdaa7c3aef2f88a6d263918bd27e8e52d0baca44cf0d
MD5 d3c25215aa4c5c4d5009981a32b144fd
BLAKE2b-256 5035a573e3602ba0914c028bdaed3a7d855ce19911a550bda44558c422b87a68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36f4fa9ee9da6a90449a7dd765d2f56aae9838876daa660f09c8ec6ad2051e9c
MD5 fd2b5d324d8ff9dede64097115052747
BLAKE2b-256 788d220612eeece7f54cd6945231fa2357c84ae99983a6c7b44978d1ce356a84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 10c28f0637e37f25b461f1401d89f7d273ec99793c75f2bc21b511c6a406c7ee
MD5 331f0b3f3001c642215f3c7674ba9427
BLAKE2b-256 b2f38f8982a3e330bbe80c80df3dc6ca94f9ccdd056204afa325e08ca3ad5676

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.4.24-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 139be7ba1888e3dcc7c42095c1460e8d2cff4daf1dcf806accf012d46247efd9
MD5 97a901bc22eb15f1ad21975634e7286a
BLAKE2b-256 177052b29d90c0bd18c481a06bfbafc994ff153177a9cb5e89df572e357f1580

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.4.24-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.12.3

File hashes

Hashes for ptufile-2024.4.24-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 7e3f195415f9dc2275cbd161ac81a4540b751f044f08e5f06eedb5aa63d06f92
MD5 742cfca64e455c374602238b02449040
BLAKE2b-256 86d50b31e42cfdd3bb9a5808bc3a86f430bc34802774ec40259cb6b630126236

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc1a7e6a3d9598773ea170f6d610912d57e485a3bd58d1fd5788680043ac09d9
MD5 78bafcb4e8b989eb0fddfdaa39cb7a71
BLAKE2b-256 70c1c6934c703008a12a7ccb4ec53f7745614c9c7951a479252847e289867d42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de544db70a9a7d11591e3bafb462a8cb87d86a0479372a015a866650080cb180
MD5 c63faadfc453623ee8409d99ea3bf91b
BLAKE2b-256 298012ff0d1d646dd01444db44f8954b53aa67bb7fe209bbcea4a665b947cae0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.4.24-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e5c85fd5f384da8eca44d784dca87efdf70c724c1d5f1abab77d2523534a5cf6
MD5 02c3fc8f2c45e5d66c3cc6524b21e702
BLAKE2b-256 ddebec6891b8d53bef8c32dc0e9a407afa9e49d35ba8806a3a7985b04eef1175

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