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.5.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.5.24

  • Fix docstring examples not correctly rendered on GitHub.

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 or C/C++ 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.5.24.tar.gz (45.8 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.5.24-cp312-cp312-win_arm64.whl (147.6 kB view details)

Uploaded CPython 3.12Windows ARM64

ptufile-2024.5.24-cp312-cp312-win_amd64.whl (177.7 kB view details)

Uploaded CPython 3.12Windows x86-64

ptufile-2024.5.24-cp312-cp312-win32.whl (147.5 kB view details)

Uploaded CPython 3.12Windows x86

ptufile-2024.5.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.5.24-cp312-cp312-macosx_11_0_arm64.whl (195.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ptufile-2024.5.24-cp312-cp312-macosx_10_9_x86_64.whl (211.3 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

ptufile-2024.5.24-cp311-cp311-win_arm64.whl (146.4 kB view details)

Uploaded CPython 3.11Windows ARM64

ptufile-2024.5.24-cp311-cp311-win_amd64.whl (174.3 kB view details)

Uploaded CPython 3.11Windows x86-64

ptufile-2024.5.24-cp311-cp311-win32.whl (144.1 kB view details)

Uploaded CPython 3.11Windows x86

ptufile-2024.5.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.5.24-cp311-cp311-macosx_11_0_arm64.whl (190.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ptufile-2024.5.24-cp311-cp311-macosx_10_9_x86_64.whl (208.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

ptufile-2024.5.24-cp310-cp310-win_amd64.whl (174.2 kB view details)

Uploaded CPython 3.10Windows x86-64

ptufile-2024.5.24-cp310-cp310-win32.whl (144.9 kB view details)

Uploaded CPython 3.10Windows x86

ptufile-2024.5.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.5.24-cp310-cp310-macosx_11_0_arm64.whl (192.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ptufile-2024.5.24-cp310-cp310-macosx_10_9_x86_64.whl (207.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

ptufile-2024.5.24-cp39-cp39-win_amd64.whl (174.7 kB view details)

Uploaded CPython 3.9Windows x86-64

ptufile-2024.5.24-cp39-cp39-win32.whl (145.5 kB view details)

Uploaded CPython 3.9Windows x86

ptufile-2024.5.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.5.24-cp39-cp39-macosx_11_0_arm64.whl (193.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

ptufile-2024.5.24-cp39-cp39-macosx_10_9_x86_64.whl (207.9 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.5.24.tar.gz
Algorithm Hash digest
SHA256 54da85869c16cfe6097629b74da8ed11fbacf35c732aa70b906dec708957ce31
MD5 48456773bc8cdffc000e762a146f232f
BLAKE2b-256 6fa159ee55ae09b2d937f7b14a0169df60646a98c06581954e458ba4ffd07922

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 b942a555f04dd0893c94094708f938bf7626687eeb7e3a6179c0ac0ba82655db
MD5 e4bdb53f809998184378ce706657b9ee
BLAKE2b-256 bf064ec0523eaa330cfdd9d88f65e7607b5c1a09c7b75f1d7f3dceb39cfffd8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e4bb6180717f5bb24dba11370d5b178c49e05c91f2bf4bcc48f70c629de826eb
MD5 bbe8ae543c50abb28b0a56038c6f7672
BLAKE2b-256 eda302401605bc6b21ab6819025a5104ab0487c67807766ae4e6bc7e4082df6f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 9968d7521c41cd409fd55177fbd91b07448aeb0ca9d02b6bc249b24d525d4506
MD5 df0e1ba43a2ffc231bccb3504aab7015
BLAKE2b-256 e8d4c24eb9859de4d43ae49d1f1bc41099eae158fc3d467247093e4345aad8dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5d45a4180aa6b7b29763ec32988a0e020e632ca78b15f68bf00a3e0dc2ac6bd
MD5 13a7c311ade065fd5b42ecb0c71af4b6
BLAKE2b-256 ea2081902c4355e1133895c200a54dd22f07df7cf70292a0742d3705ebe280a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3d80af76114383a5245f0ffe7001100b01195f70cf7a42bc2f2f2e03b4fffb3
MD5 50a4cee83c1e498f7ae8036493de57fa
BLAKE2b-256 976177b94c0b218d26d05a67f1799c29669fa01f2bd34e59d40bedcfe291b898

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dfa54b8ab6c5a76edec464f880fee4df1fcd89b139b5b745018b49470b55f30c
MD5 295660204000a0d85a6f61a13a58b6de
BLAKE2b-256 3370dfa29c552887d455870e3de76aa501b31fca91e2eb559de1d1950d838ed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 4964ead9f31d00177d6cb10f91cfa6b0e50af55d0fbc55ff8a60cf28ecf0f3b2
MD5 56755c309673a79f8eb0684fdc2f5f43
BLAKE2b-256 73b36c6af51a4b92f1814882c3da89963e39e6c0fca67888e11844579ba2fa87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5f31cc17a427c37ff6785945819b9c655c520a8165e6c9e064990b9fb3df4a3f
MD5 9d88499ee8da24448bbf6c140f26ecd9
BLAKE2b-256 b5e1f2215893a2a1af18481b5f64f53342d4bfeec9eb0108f71459e3a739a817

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.5.24-cp311-cp311-win32.whl
  • Upload date:
  • Size: 144.1 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 6ae03394a876cfb27d878928d302baad23f3c8392ee85cc4a68a7d6288ee219e
MD5 c908b1812f5828455d29e21a8c2496ab
BLAKE2b-256 d07ded6cfc9e2240419f363016c172a0bab21b7250c3f45d39042f93cbcff2fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a09b62df7a0893d18e13ab92dd6efd3adfe486328e0cc5c78dbd17180235297
MD5 89023fc3620112c3a0a73476cfdd1307
BLAKE2b-256 c292ec876d4894b67d3cd9284d48e0530761aef8357f7b220e5a007a4a0ce263

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc0016a9f1cc34720fe39c8b1716159dfed5c5567bad1d580f30a77c92a87542
MD5 866edb5788a66f592dec35c4e1a50783
BLAKE2b-256 d73ed66fae9273e43f754a5bf825a7ad4db3ed2e6e4b5a262f56045512b088fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a2244e7b3262cf8c09fddce538fe2cd073f9497f720df18b698118eba2fddffe
MD5 679a96183db13164f19a031888f35eea
BLAKE2b-256 65c877f7b13fdc6d14a9bdd78863acad2e7180f84bd897ee668c33a7aa64311a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 50ec28f3a1008f9d196244a965b1f2d2fd5832874f4416925cc1a2a1f2ed8e63
MD5 b78e0364f2b092889533623a6070354c
BLAKE2b-256 117aa129e8f2fcf9ae15dc1dc2fb790af02058cb82d797c9b5c19f8aaebc0ede

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.5.24-cp310-cp310-win32.whl
  • Upload date:
  • Size: 144.9 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for ptufile-2024.5.24-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 a80bc1036beb610c5070ad0e486aacdefe7a0f4671ee80cb5f169fb905145e83
MD5 1ff3ac0dde4cc501792e0bc21147e1c5
BLAKE2b-256 5b1b799b6db451db4bb76769baf10ca14a193b66dd4f2ef0ac9572e843efdc4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b65ce272685a6cc1e2493395cda8ca520024a41da67f866aa3ad52651ff800fc
MD5 f9dbdff2408be2a712c1be8c742aa3ad
BLAKE2b-256 a464133015df1c78a64e061909cf1d90cdb79232f7539b1753b62732c9d45491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95205a3e1c0a7707bcf1e923c23243c1e53103288a4aec5186b6ef4d4b10aca6
MD5 3992b1bc36bd76c07a1defba624862e4
BLAKE2b-256 4407278254f863fd4b7219340397fe318face255bf49d782c108c94084184a02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 30a6cd742f20d03141055eb8af5cc25b3e13f229272c3c8c945026ac54d19e25
MD5 49cd70e9980690878e9c29e8159b44fb
BLAKE2b-256 a7eea894919297b14d8bb18764ffdadda6fb6643263af83c4e7b92c915b6aaac

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ptufile-2024.5.24-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c0ab6098635cb29c03b4f7ce76c240a96f4b5f2a885192dd0dbb307d4311fce8
MD5 3790dd865605ab7726763a649c4ccdf3
BLAKE2b-256 643407c523434c148282b4f670f4cb648d95ffaf506e224a7c15a3d9369e2c0c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptufile-2024.5.24-cp39-cp39-win32.whl
  • Upload date:
  • Size: 145.5 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for ptufile-2024.5.24-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 fe99005fde16c7ab1d621d12006bbabc06cd5f3bc2dbefc1390193e06b5aa679
MD5 43c28ab65f09d30c23d3bd1bfe526954
BLAKE2b-256 73d224fcca6f4cfb5a39abdfe85f91f7cfa704b7db3a844cd4139647e5f1b8c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5065d976c8c93ca517eef0f31f4d480fba73754ef406a053035780159f3100f4
MD5 21bfc1aaa2196052fa1bbef16bbf5407
BLAKE2b-256 6d2bbb7928d8de46dbc69eb0d706119ce323e19c8b6b0b401b1c5a8ad195d927

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abe91bb64d746fcd07a35fcfed241584820dd98b38ead35f3667d5b440340a6b
MD5 2b5bf5cf74528e7f51010894a8b64220
BLAKE2b-256 7f96d0df830239621e6fbb65be5fe46bde8148f91152a5f3649b77f1d4b494da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ptufile-2024.5.24-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a49df8084c98a33630c3a21758cddb8839dbd89f4d5d8650f527eafe9b1e7a80
MD5 8b9b0b5b8d771e8600ff049377036945
BLAKE2b-256 e8fceb26365ea7a5d7abd7840bb3dcdfd330e921ef01e0ed73b4ba9571a9814c

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