phasorpy 0.6__cp313-cp313-win_amd64.whl → 0.8__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phasorpy/__init__.py +1 -1
- phasorpy/_phasorpy.cp313-win_amd64.pyd +0 -0
- phasorpy/_phasorpy.pyx +320 -10
- phasorpy/_utils.py +114 -33
- phasorpy/cli.py +19 -1
- phasorpy/cluster.py +12 -18
- phasorpy/color.py +11 -7
- phasorpy/{components.py → component.py} +263 -36
- phasorpy/{cursors.py → cursor.py} +31 -33
- phasorpy/datasets.py +118 -8
- phasorpy/experimental.py +4 -168
- phasorpy/filter.py +966 -0
- phasorpy/io/__init__.py +3 -1
- phasorpy/io/_flimlabs.py +26 -16
- phasorpy/io/_leica.py +38 -34
- phasorpy/io/_ometiff.py +10 -9
- phasorpy/io/_other.py +116 -8
- phasorpy/io/_simfcs.py +52 -24
- phasorpy/lifetime.py +2058 -0
- phasorpy/phasor.py +106 -2502
- phasorpy/plot/_functions.py +13 -7
- phasorpy/plot/_lifetime_plots.py +34 -24
- phasorpy/plot/_phasorplot.py +561 -176
- phasorpy/plot/_phasorplot_fret.py +12 -10
- phasorpy/utils.py +22 -10
- {phasorpy-0.6.dist-info → phasorpy-0.8.dist-info}/METADATA +8 -7
- phasorpy-0.8.dist-info/RECORD +36 -0
- phasorpy-0.6.dist-info/RECORD +0 -34
- {phasorpy-0.6.dist-info → phasorpy-0.8.dist-info}/WHEEL +0 -0
- {phasorpy-0.6.dist-info → phasorpy-0.8.dist-info}/entry_points.txt +0 -0
- {phasorpy-0.6.dist-info → phasorpy-0.8.dist-info}/licenses/LICENSE.txt +0 -0
- {phasorpy-0.6.dist-info → phasorpy-0.8.dist-info}/top_level.txt +0 -0
phasorpy/io/_simfcs.py
CHANGED
@@ -12,6 +12,7 @@ __all__ = [
|
|
12
12
|
'signal_from_z64',
|
13
13
|
]
|
14
14
|
|
15
|
+
import math
|
15
16
|
import os
|
16
17
|
import struct
|
17
18
|
import zlib
|
@@ -75,9 +76,11 @@ def phasor_to_simfcs_referenced(
|
|
75
76
|
Harmonics must be starting at and increasing by one.
|
76
77
|
size : int, optional
|
77
78
|
Size of X and Y dimensions of square-sized images stored in file.
|
79
|
+
Must be in range [4, 65535].
|
78
80
|
By default, ``size = min(256, max(4, sizey, sizex))``.
|
79
81
|
dims : sequence of str, optional
|
80
82
|
Character codes for `mean` dimensions used to format file names.
|
83
|
+
Only used when chunking multi-dimensional data into multiple files.
|
81
84
|
|
82
85
|
See Also
|
83
86
|
--------
|
@@ -94,7 +97,7 @@ def phasor_to_simfcs_referenced(
|
|
94
97
|
raise ValueError(f'file extension {ext} != .r64')
|
95
98
|
|
96
99
|
# TODO: delay conversions to numpy arrays to inner loop
|
97
|
-
mean = numpy.asarray(mean, numpy.float32)
|
100
|
+
mean = numpy.asarray(mean, dtype=numpy.float32)
|
98
101
|
phi, mod = phasor_to_polar(real, imag, dtype=numpy.float32)
|
99
102
|
del real
|
100
103
|
del imag
|
@@ -180,17 +183,21 @@ def phasor_from_simfcs_referenced(
|
|
180
183
|
) -> tuple[NDArray[Any], NDArray[Any], NDArray[Any], dict[str, Any]]:
|
181
184
|
"""Return phasor coordinates and metadata from SimFCS REF or R64 file.
|
182
185
|
|
183
|
-
SimFCS referenced REF and R64 files contain phasor
|
184
|
-
(encoded as phase and modulation) for two harmonics.
|
186
|
+
SimFCS referenced REF and R64 files contain square-shaped phasor
|
187
|
+
coordinate images (encoded as phase and modulation) for two harmonics.
|
185
188
|
Phasor coordinates from lifetime-resolved signals are calibrated.
|
189
|
+
Variants of referenced files (RE<n>) written by other software may
|
190
|
+
contain up to eight harmonics and may be uncalibrated.
|
186
191
|
|
187
192
|
Parameters
|
188
193
|
----------
|
189
194
|
filename : str or Path
|
190
|
-
Name of SimFCS REF or
|
191
|
-
harmonic : int
|
195
|
+
Name of SimFCS REF, R64, or RE<n> file to read.
|
196
|
+
harmonic : int, sequence of int, or 'all', optional
|
192
197
|
Harmonic(s) to include in returned phasor coordinates.
|
193
198
|
By default, only the first harmonic is returned.
|
199
|
+
If 'all', return all available harmonics.
|
200
|
+
If int or sequence, return specified harmonic(s).
|
194
201
|
|
195
202
|
Returns
|
196
203
|
-------
|
@@ -203,7 +210,7 @@ def phasor_from_simfcs_referenced(
|
|
203
210
|
Image of imaginary component of phasor coordinates.
|
204
211
|
Multiple harmonics, if any, are in the first axis.
|
205
212
|
attrs : dict
|
206
|
-
Select metadata:
|
213
|
+
Select metadata containing:
|
207
214
|
|
208
215
|
- ``'dims'`` (tuple of str):
|
209
216
|
:ref:`Axes codes <axes>` for `mean` image dimensions.
|
@@ -211,7 +218,7 @@ def phasor_from_simfcs_referenced(
|
|
211
218
|
Raises
|
212
219
|
------
|
213
220
|
lfdfiles.LfdfileError
|
214
|
-
File is not a SimFCS REF or
|
221
|
+
File is not a SimFCS REF, R64, or RE<n> file.
|
215
222
|
|
216
223
|
See Also
|
217
224
|
--------
|
@@ -219,7 +226,7 @@ def phasor_from_simfcs_referenced(
|
|
219
226
|
|
220
227
|
Notes
|
221
228
|
-----
|
222
|
-
The implementation is based on the
|
229
|
+
The implementation for reading R64 files is based on the
|
223
230
|
`lfdfiles <https://github.com/cgohlke/lfdfiles/>`__ library.
|
224
231
|
|
225
232
|
Examples
|
@@ -232,22 +239,40 @@ def phasor_from_simfcs_referenced(
|
|
232
239
|
array([[...]], dtype=float32)
|
233
240
|
|
234
241
|
"""
|
235
|
-
import lfdfiles
|
236
|
-
|
237
242
|
ext = os.path.splitext(filename)[-1].lower()
|
238
243
|
if ext == '.r64':
|
244
|
+
import lfdfiles
|
245
|
+
|
239
246
|
with lfdfiles.SimfcsR64(filename) as r64:
|
240
247
|
data = r64.asarray()
|
241
|
-
elif ext ==
|
242
|
-
|
243
|
-
|
248
|
+
elif ext.startswith('.re') and len(ext) == 4:
|
249
|
+
if ext[-1] == 'f':
|
250
|
+
num_images = 5
|
251
|
+
elif ext[-1].isdigit():
|
252
|
+
# non-SimFCS referenced files containing other number of harmonics
|
253
|
+
num_images = int(ext[-1]) * 2 + 1
|
254
|
+
else:
|
255
|
+
raise ValueError(
|
256
|
+
f'file extension must be .ref, .r64, or .re<n>, not {ext!r}'
|
257
|
+
)
|
258
|
+
size = os.path.getsize(filename)
|
259
|
+
if (
|
260
|
+
size > 4294967295
|
261
|
+
or size % (num_images * 4)
|
262
|
+
or not math.sqrt(size // (num_images * 4)).is_integer()
|
263
|
+
):
|
264
|
+
raise ValueError(f'{filename!r} is not a valid referenced file')
|
265
|
+
size = int(math.sqrt(size // (num_images * 4)))
|
266
|
+
data = numpy.fromfile(filename, dtype='<f4').reshape((-1, size, size))
|
244
267
|
else:
|
245
|
-
raise ValueError(
|
268
|
+
raise ValueError(
|
269
|
+
f'file extension must be .ref, .r64, or .re<n>, not {ext!r}'
|
270
|
+
)
|
246
271
|
|
247
272
|
harmonic, keep_harmonic_dim = parse_harmonic(harmonic, data.shape[0] // 2)
|
248
273
|
|
249
274
|
mean = data[0].copy()
|
250
|
-
real = numpy.empty((len(harmonic),) + mean.shape, numpy.float32)
|
275
|
+
real = numpy.empty((len(harmonic),) + mean.shape, dtype=numpy.float32)
|
251
276
|
imag = numpy.empty_like(real)
|
252
277
|
for i, h in enumerate(harmonic):
|
253
278
|
h = (h - 1) * 2 + 1
|
@@ -269,10 +294,11 @@ def signal_from_fbd(
|
|
269
294
|
channel: int | None = 0,
|
270
295
|
keepdims: bool = False,
|
271
296
|
laser_factor: float = -1.0,
|
297
|
+
**kwargs: Any,
|
272
298
|
) -> DataArray:
|
273
299
|
"""Return phase histogram and metadata from FLIMbox FBD file.
|
274
300
|
|
275
|
-
|
301
|
+
FBD files contain encoded cross-correlation phase histograms from
|
276
302
|
digital frequency-domain measurements using a FLIMbox device.
|
277
303
|
The encoding scheme depends on the FLIMbox device's firmware.
|
278
304
|
The FBD file format is undocumented.
|
@@ -289,7 +315,7 @@ def signal_from_fbd(
|
|
289
315
|
frame : int, optional
|
290
316
|
If None (default), return all frames.
|
291
317
|
If < 0, integrate time axis, else return specified frame.
|
292
|
-
channel : int, optional
|
318
|
+
channel : int or None, optional
|
293
319
|
Index of channel to return.
|
294
320
|
By default, return the first channel.
|
295
321
|
If None, return all channels.
|
@@ -297,6 +323,8 @@ def signal_from_fbd(
|
|
297
323
|
If true, return reduced axes as size-one dimensions.
|
298
324
|
laser_factor : float, optional
|
299
325
|
Factor to correct dwell_time/laser_frequency.
|
326
|
+
**kwargs
|
327
|
+
Optional arguments passed to :py:class:`fbdfile.FbdFile`.
|
300
328
|
|
301
329
|
Returns
|
302
330
|
-------
|
@@ -313,13 +341,13 @@ def signal_from_fbd(
|
|
313
341
|
|
314
342
|
Raises
|
315
343
|
------
|
316
|
-
|
344
|
+
ValueError
|
317
345
|
File is not a FLIMbox FBD file.
|
318
346
|
|
319
347
|
Notes
|
320
348
|
-----
|
321
349
|
The implementation is based on the
|
322
|
-
`
|
350
|
+
`fbdfile <https://github.com/cgohlke/fbdfile/>`__ library.
|
323
351
|
|
324
352
|
Examples
|
325
353
|
--------
|
@@ -340,12 +368,12 @@ def signal_from_fbd(
|
|
340
368
|
40.0
|
341
369
|
|
342
370
|
"""
|
343
|
-
import
|
371
|
+
import fbdfile
|
344
372
|
|
345
373
|
integrate_frames = 0 if frame is None or frame >= 0 else 1
|
346
374
|
|
347
|
-
with
|
348
|
-
data = fbd.asimage(
|
375
|
+
with fbdfile.FbdFile(filename, laser_factor=laser_factor, **kwargs) as fbd:
|
376
|
+
data = fbd.asimage(integrate_frames=integrate_frames)
|
349
377
|
if integrate_frames:
|
350
378
|
frame = None
|
351
379
|
copy = False
|
@@ -530,7 +558,7 @@ def signal_from_bh(
|
|
530
558
|
Returns
|
531
559
|
-------
|
532
560
|
xarray.DataArray
|
533
|
-
TCSPC histogram with ref:`axes codes <axes>` ``'HYX'``,
|
561
|
+
TCSPC histogram with :ref:`axes codes <axes>` ``'HYX'``,
|
534
562
|
shape ``(256, 256, 256)``, and type ``float32``.
|
535
563
|
|
536
564
|
Raises
|
@@ -587,7 +615,7 @@ def signal_from_bhz(
|
|
587
615
|
Returns
|
588
616
|
-------
|
589
617
|
xarray.DataArray
|
590
|
-
TCSPC histogram with ref:`axes codes <axes>` ``'HYX'``,
|
618
|
+
TCSPC histogram with :ref:`axes codes <axes>` ``'HYX'``,
|
591
619
|
shape ``(256, 256, 256)``, and type ``float32``.
|
592
620
|
|
593
621
|
Raises
|