77
88## Should I move some import statements to function definitions
99from siffpy .core import io , timetools
10- from siffpy .core .flim import FLIMParams , FlimUnits , default_flimparams
10+ from siffpy .core .flim import FLIMParams , FlimUnits , default_flimparams , FlimUnitsLike
1111from siffpy .core .utils .event_stamp import EventStamp
1212
1313#from siffpy.core.utils import ImParams
@@ -1464,6 +1464,7 @@ def get_frames_flim(
14641464 registration_dict : Optional [Dict ] = None ,
14651465 confidence_metric : str = 'chi_sq' ,
14661466 method : Union [str , FlimMethod ] = FlimMethod .EMPIRICAL ,
1467+ units : 'FlimUnitsLike' = 'nanoseconds' ,
14671468 ) -> FlimTrace :
14681469 """
14691470 Returns a FlimTrace object of dimensions
@@ -1498,15 +1499,17 @@ def get_frames_flim(
14981499 confidence_metric = confidence_metric
14991500 )
15001501
1501- return FlimTrace (
1502+ ft = FlimTrace (
15021503 lifetime ,
15031504 intensity = intensity ,
15041505 #confidence= np.array(flim_arrays[2]),
15051506 FLIMParams = params ,
15061507 method = method .value ,
1507- units = 'countbins' ,
15081508 )
15091509
1510+ ft .convert_units (units )
1511+ return ft
1512+
15101513 def _get_frames_flim_srm (
15111514 self ,
15121515 params : FLIMParams ,
@@ -1574,6 +1577,7 @@ def sum_mask_flim(
15741577 registration_dict : Optional [dict ] = None ,
15751578 return_framewise : bool = False ,
15761579 flim_method : Union [str , FlimMethod ] = FlimMethod .EMPIRICAL ,
1580+ units : 'FlimUnitsLike' = 'nanoseconds' ,
15771581 )-> FlimTrace :
15781582 """
15791583 Computes the empirical lifetime within an ROI over timesteps.
@@ -1621,6 +1625,9 @@ def sum_mask_flim(
16211625 * `flim_method` : Union[str, FlimMethod]
16221626 The method to use for the FLIM analysis. Default is 'empirical'.
16231627 Options are any of the `FlimMethod` enum values (`siffpy.siffmath.flim.FlimMethod`).
1628+
1629+ * `units` : FlimUnitsLike
1630+ The units to return the FLIM data in. Default is 'nanoseconds'.
16241631
16251632 # Returns
16261633
@@ -1689,7 +1696,7 @@ def sum_mask_flim(
16891696 )
16901697
16911698 if return_framewise :
1692- return FlimTrace (
1699+ ft = FlimTrace (
16931700 summed_flim_data ,
16941701 intensity = summed_intensity_data ,
16951702 FLIMParams = params ,
@@ -1698,7 +1705,10 @@ def sum_mask_flim(
16981705 units = FlimUnits .COUNTBINS ,
16991706 )
17001707
1701- return FlimTrace (
1708+ ft .convert_units (units )
1709+ return ft
1710+
1711+ ft = FlimTrace (
17021712 summed_flim_data ,
17031713 intensity = summed_intensity_data ,
17041714 FLIMParams = params ,
@@ -1708,6 +1718,9 @@ def sum_mask_flim(
17081718 ).reshape (
17091719 (- 1 , mask .shape [0 ] if mask .ndim > 2 else 1 )
17101720 ).sum (axis = 1 )
1721+
1722+ ft .convert_units (units )
1723+ return ft
17111724
17121725 def _sum_mask_flim_srm (
17131726 self ,
@@ -1816,6 +1829,7 @@ def sum_masks_flim(
18161829 registration_dict : Optional [dict ] = None ,
18171830 return_framewise : bool = False ,
18181831 flim_method : Union [str , FlimMethod ] = FlimMethod .EMPIRICAL ,
1832+ units : 'FlimUnitsLike' = 'nanoseconds' ,
18191833 )-> FlimTrace :
18201834 """
18211835 Computes the empirical lifetime within a set of ROIs over timesteps.
@@ -1852,6 +1866,9 @@ def sum_masks_flim(
18521866 * `flim_method` : Union[str, FlimMethod]
18531867 The method to use for the FLIM analysis. Default is 'empirical'.
18541868 Options are any of the `FlimMethod` enum values (`siffpy.siffmath.flim.FlimMethod`).
1869+
1870+ * `units` : FlimUnitsLike
1871+ The units to return the FLIM data in. Default is 'nanoseconds'.
18551872
18561873 # Returns
18571874
@@ -1930,7 +1947,7 @@ def sum_masks_flim(
19301947 )
19311948
19321949 if return_framewise :
1933- return FlimTrace (
1950+ ft = FlimTrace (
19341951 flim_summed ,
19351952 intensity = intensity_summed ,
19361953 FLIMParams = params ,
@@ -1939,9 +1956,12 @@ def sum_masks_flim(
19391956 units = FlimUnits .COUNTBINS ,
19401957 )
19411958
1959+ ft .convert_units (units )
1960+ return ft
1961+
19421962 # Reshape AFTER making a `FlimTrace`
19431963 # or else things won't be added correctly.
1944- return FlimTrace (
1964+ ft = FlimTrace (
19451965 flim_summed ,
19461966 intensity = intensity_summed ,
19471967 FLIMParams = params ,
@@ -1952,8 +1972,9 @@ def sum_masks_flim(
19521972 (masks .shape [0 ], - 1 , masks .shape [1 ] if masks .ndim > 3 else 1 )
19531973 ).sum (axis = 2 )
19541974
1955- raise NotImplementedError ("Not yet implemented using corrosiff backend" )
1956-
1975+ ft = ft .convert_units (units )
1976+ return ft
1977+
19571978 def _sum_masks_flim_srm (
19581979 self ,
19591980 params : FLIMParams ,
0 commit comments