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

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.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:      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.15.tar.gz (44.0 kB view details)

Uploaded Source

Built Distributions

ptufile-2024.2.15-cp312-cp312-win_arm64.whl (147.0 kB view details)

Uploaded CPython 3.12 Windows ARM64

ptufile-2024.2.15-cp312-cp312-win_amd64.whl (177.0 kB view details)

Uploaded CPython 3.12 Windows x86-64

ptufile-2024.2.15-cp312-cp312-win32.whl (146.8 kB view details)

Uploaded CPython 3.12 Windows x86

ptufile-2024.2.15-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.15-cp312-cp312-macosx_11_0_arm64.whl (194.7 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

ptufile-2024.2.15-cp312-cp312-macosx_10_9_x86_64.whl (210.7 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

ptufile-2024.2.15-cp311-cp311-win_arm64.whl (145.8 kB view details)

Uploaded CPython 3.11 Windows ARM64

ptufile-2024.2.15-cp311-cp311-win_amd64.whl (173.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

ptufile-2024.2.15-cp311-cp311-win32.whl (143.4 kB view details)

Uploaded CPython 3.11 Windows x86

ptufile-2024.2.15-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.15-cp311-cp311-macosx_11_0_arm64.whl (189.9 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ptufile-2024.2.15-cp311-cp311-macosx_10_9_x86_64.whl (208.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

ptufile-2024.2.15-cp310-cp310-win_amd64.whl (173.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

ptufile-2024.2.15-cp310-cp310-win32.whl (144.3 kB view details)

Uploaded CPython 3.10 Windows x86

ptufile-2024.2.15-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.15-cp310-cp310-macosx_11_0_arm64.whl (191.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ptufile-2024.2.15-cp310-cp310-macosx_10_9_x86_64.whl (206.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

ptufile-2024.2.15-cp39-cp39-win_amd64.whl (173.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

ptufile-2024.2.15-cp39-cp39-win32.whl (144.9 kB view details)

Uploaded CPython 3.9 Windows x86

ptufile-2024.2.15-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.15-cp39-cp39-macosx_11_0_arm64.whl (192.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ptufile-2024.2.15-cp39-cp39-macosx_10_9_x86_64.whl (207.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: ptufile-2024.2.15.tar.gz
  • Upload date:
  • Size: 44.0 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.15.tar.gz
Algorithm Hash digest
SHA256 ab11d6ed396a4d8e92d5688ae92fc964761cbf412eb25c59713e28d244b2cff0
MD5 f4e10d0930fe87f51735f6667d4c719a
BLAKE2b-256 0d3d255a8881a986285957f654776891226a85479efaaa9ab2326e7081ad713c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 beb3dd85c66ae3a07db2111e01dc1047e382c1be398c1aefe82898b071715523
MD5 1bee29d51016fb9842160b72ce2740a5
BLAKE2b-256 4fb07fdf4e129ebe5d4b42f6354ba400440bd3e3b8f628190628c866b85d370f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1c012b113b79c1e1807b5b62bcd16c4ef87ba759999c2f64feceb54844d566eb
MD5 2a883511362649ac43fd1090aa198104
BLAKE2b-256 588b81cec4c87cc7843b946e8dca15be15c9369eb159d06bcc26e243965fa3a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.15-cp312-cp312-win32.whl
  • Upload date:
  • Size: 146.8 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.15-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 de6afd21203626934a2fffd2958bc0142dd8eb8e3980f04e2ec11853c7d86497
MD5 0eb4bd250f2c7e101cc31ce55c12d7b3
BLAKE2b-256 f7dd4891e70597ea76174a8f61ebfe7a083b6395ff6dafa338fbcdc7276fbd69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6befbe24d48e3060c3914b75f2683819fbfb55eab8885e5f636bf30310d5a55c
MD5 aed5d109dff4fc04112e930889a5ec23
BLAKE2b-256 88bb80a0db81e1ea9c373dfc80c0f172ccfddfd279105a7aa55938a83c2013c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8c95fb71125444baec2dcf6550891b6589431016fc5cbd380cf8149c6dde554
MD5 e0c4973c9cbe7ec1efe5850192899b9e
BLAKE2b-256 842ce7d80e031d5b3737832e1dd7ce65c5d6d1421d18daff38f9d7bb25ac065a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 81c98c2f8d0da3ca6b17e1070bff7f267693cfa482c09a88d13a6e540c533e63
MD5 b5d2597c4b8a78c735ee2f5d9211fdd6
BLAKE2b-256 1ae21bc2244451f845e32d8e0629f8a24a5bba8d5025fb1996681a96883af0dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 67ede0f815eefbdc24f3611c97c4ce2c15e7bc656316161cc294017b36f42c17
MD5 0f6f84231ba8b619feb748338a869d7d
BLAKE2b-256 b4fc5a1d9d65e4741760a12f3c75956c125ff55e23c68e9dc9195caa61cd5ab4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4f772800b1460d5f18645aec79b40bf95e3de85ca725e8c88c97d9d88e77bfe3
MD5 ec4dd6ebecd3cae7441a3aad3689f26b
BLAKE2b-256 ae2f7aebb7fa1b19f71883ce270a2ead372468c617033bfc01e43f13576ca1dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.15-cp311-cp311-win32.whl
  • Upload date:
  • Size: 143.4 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.15-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 a68000ee57547941bf5f79b7e7caab8f6a1dd175ecf999f25e134072ea324cdb
MD5 18426555ac14cd9220c33901ddae1d2e
BLAKE2b-256 f076e14a0f951709baf8eac8659b9e6720fb504c5e4f79084d8dc3c1835e959b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 13e7415e0a9333d113e82c6d58b26ecdee9c35133654982cb3592ca1e876e85b
MD5 efb51fa370cfdaf32c159ccd3c72b165
BLAKE2b-256 36305de3f5d6cac69845743b0eb763d9e074d5a018df7b9a277473e7bbc4555c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc78463d4f05806e0105bf39f5df9a3ca395d706dbd7a26b430b6db304fb4a03
MD5 7336d011a19f936dbe2537b762aca721
BLAKE2b-256 3ca1db1a22443efe9356614b7cf42877378b3808b1d0318359f740e6436b03d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 299f8894147422cd1756582fbd020fc7fe9cd9853b5126578a678bc37e6cae77
MD5 566c2cb4e00a8112bbe51714b361973c
BLAKE2b-256 85859d186d3a61c7fdc7cbbcc866e8696ddf84e5321781f5f78236276971cc9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0109e63e1e559f0b1835fc0a47f764a7ae3f1841f280084d6cdacc12c47efde1
MD5 c35fd482979e0af82a4f2b178fed0857
BLAKE2b-256 4d2bc2b87771a6dcf25c9dc00d63c529a4bc574ecd73190be2acb83d30481898

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.15-cp310-cp310-win32.whl
  • Upload date:
  • Size: 144.3 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.15-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 953b07f68ec5c0da7b4b48ac1bef54690fd6cf9ef2e03d2c894a7fbaad74ca35
MD5 b48ddd6a8f9f3426b482db8a232c57d1
BLAKE2b-256 a58059d8db902644dde4904715601fb84f06a4af8edc03d97911a8d6fd030ef1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26274af4f4c460bbb05fbc88233d3497c780fa47775ce0490d8ff3770f0505a2
MD5 a3fb412e2c46d2dc48b853d3bdb33628
BLAKE2b-256 c515bb55bf3e188c8f43504bce4b6072f9b0fb5a6fc49447176b6f69d616776e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5926737e528d855f9a1245bc0cc32c5be0cc1e5318a69b5b6935a95c582a5e6
MD5 8ff1a843c744d80fdae27a57062becb7
BLAKE2b-256 2cb9d70d06cd3b1b33dec2d5888dab932c967571ac104169f9fdcc42a4afa3bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 99391b0914de60cb961ac33d4ccecdf85132516786be7c0845e9ad51f2dbf155
MD5 915f8240e08b57aa5b188862e16fb176
BLAKE2b-256 7bd1c0ecf1791e60cf6e8755e2fc0c5458c75fefbd8e1b4ff3d8e7e2a0bf25eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1055f4ea5e13379a53b5c2607664e312a0c24a134d42b205568c83c29385ca77
MD5 d5647be750266022b6c1dfb298c755bc
BLAKE2b-256 935eda7addf2582108ac346ffab315a35b539a3a93713a24d6399f279bb68e03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.2.15-cp39-cp39-win32.whl
  • Upload date:
  • Size: 144.9 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.15-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 9b391cb6c228380e3e2a85d7d2375dcfffd69e5bfc335e57a3ce501a1bafc9af
MD5 9337d32a20e9f5666992397937f4eb0d
BLAKE2b-256 9d4674cf7b3dbf794bf7efc819a9c82e9b3e05ad9d7fd7ecfc040be4935698bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f9b8ca2978e77df67845112bb9a8bf930eb09a88f17c6eb15bdc507b8b9dfd1
MD5 e47df664f2cf63b5ce6f2cd723d1a58e
BLAKE2b-256 94941e99f7e7ee883563b17b4fcc5fcd4d6beaa300426267d5bccd1611a8864f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc2f916ac3598545a403a40b88e216e3f9559942f26e57f65d82dc9bd9a4079c
MD5 a46780ab37d8ca94cee85d623012e59a
BLAKE2b-256 0f126ee8fba6a6fae457020eeba7d9764275858644bfed92cc365b16eec0f83d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.2.15-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b0171a75cc83edf38321511d29ada5ccc6bab5ea708891d80771e5f3ba219370
MD5 76d5d0e8f4b73f6375571578db0795d5
BLAKE2b-256 271da6196d2c638ab86717a2ac2e23c740150e0af403448c34dc4205da13eb6b

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