55an argument vector_timeseries, which is a numpy array,
66and accept a keyword argument error_estimate, which is a boolean
77"""
8- from typing import Callable , Union , Optional , Tuple
8+ from typing import Callable , Union , Optional , Tuple , Any
99from enum import Enum
1010
1111import numpy as np
2222)
2323
2424__all__ = [
25- 'pva'
25+ 'pva' ,
26+ 'pva_flim' ,
2627]
2728
2829class PhaseErrorFunction (Enum ):
@@ -101,6 +102,7 @@ def pva(
101102 time : Optional [np .ndarray ] = None ,
102103 error_function : Optional [Union [Callable ,str ]] = 'relative_magnitude' ,
103104 filter_fcn : Optional [Union [Callable ,str ]] = None ,
105+ angle_coords : Optional [np .ndarray [Any , Any ]] = None ,
104106 ** kwargs
105107 ) -> PhaseTrace :
106108 """
@@ -136,6 +138,15 @@ def pva(
136138 filter_fcn : function
137139
138140 A function to apply to the time series before computing the PVA.
141+
142+ angle_coords : np.ndarray
143+
144+ The angular coordinates of the first dimension of the vector timeseries,
145+ i.e. the angle that each vector component corresponds to. If not provided,
146+ will assume that the angle is linearly spaced between -pi and pi. Can
147+ provide complex numbers on the unit circle or floats corresponding to an
148+ angle in radians.
149+
139150 """
140151
141152 if normalized :
@@ -144,8 +155,7 @@ def pva(
144155 max_val = sorted_vals [:,int (sorted_vals .shape [- 1 ]* (1.0 - 1.0 / 20 ))]
145156 vector_timeseries = ((vector_timeseries .T - min_val )/ (max_val - min_val )).T
146157
147- angle_coords = np .exp (np .linspace (np .pi , - np .pi , vector_timeseries .shape [0 ])* 1j ) # it goes clockwise.
148- if isinstance (vector_timeseries , FluorescenceTrace ):
158+ if isinstance (vector_timeseries , FluorescenceTrace ) and (angle_coords is None ):
149159 if (
150160 isinstance (vector_timeseries .angle , np .ndarray )
151161 and (vector_timeseries .angle .dtype == np .complex128 )
@@ -156,7 +166,12 @@ def pva(
156166 and all (x is not None for x in vector_timeseries .angle )
157167 ):
158168 angle_coords = np .exp (- 1j * vector_timeseries .angle )
169+ elif angle_coords is None :
170+ angle_coords = np .exp (np .linspace (np .pi , - np .pi , vector_timeseries .shape [0 ])* 1j ) # it goes clockwise.
159171
172+ if angle_coords .dtype != np .complex128 :
173+ angle_coords = np .exp (1j * angle_coords )
174+
160175 pva_val = np .asarray (
161176 np .matmul (
162177 angle_coords ,
0 commit comments