tttrlib
A library for time-tagged time resolved data
Loading...
Searching...
No Matches
Classes | Macros | Functions
TTTR.h File Reference
#include <cstdint>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <array>
#include <memory>
#include <stdlib.h>
#include <numeric>
#include <cinttypes>
#include <fstream>
#include <boost/bimap.hpp>
#include "Histogram.h"
#include "TTTRHeader.h"
#include "TTTRMask.h"
#include "TTTRRecordReader.h"
#include "TTTRRecordTypes.h"
#include "info.h"

Go to the source code of this file.

Classes

class  TTTR
 Time-Tagged Time-Resolved (TTTR) data class. More...
 

Macros

#define _CRT_SECURE_NO_DEPRECATE
 
#define TTTRLIB_TTTR_H
 

Functions

void selection_by_count_rate (int **output, int *n_output, unsigned long long *time, int n_time, double time_window, int n_ph_max, double macro_time_calibration=1.0, bool invert=false, bool make_mask=false)
 A count rate (cr) filter that returns an array containing a list of indices where the cr was smaller than a specified cr.
 
void ranges_by_time_window (int **output, int *n_output, unsigned long long *input, int n_input, double minimum_window_length, double maximum_window_length=-1, int minimum_number_of_photons_in_time_window=-1, int maximum_number_of_photons_in_time_window=-1, double macro_time_calibration=1.0, bool invert=false)
 Returns time windows (tw), i.e., the start and stop indices for a minimum tw size and a minimum number of photons in a tw.
 
void compute_intensity_trace (int **output, int *n_output, unsigned long long *input, int n_input, double time_window_length, double macro_time_resolution=1.0)
 Computes the intensity trace for a sequence of time events.
 
template<typename T >
void get_array (size_t n_valid_events, T *array, T **out, int *n_out)
 Extracts a subarray of valid events from the input array.
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

◆ TTTRLIB_TTTR_H

#define TTTRLIB_TTTR_H

Function Documentation

◆ compute_intensity_trace()

void compute_intensity_trace ( int ** output,
int * n_output,
unsigned long long * input,
int n_input,
double time_window_length,
double macro_time_resolution = 1.0 )

Computes the intensity trace for a sequence of time events.

The intensity trace is calculated by partitioning the time events into time windows with a minimum specified length and counting the number of photons in each window.

Parameters
outputPointer to an array storing the number of photons in each time window.
n_outputPointer to the variable storing the number of time windows.
inputArray of time points representing the time events.
n_inputNumber of time points in the input array.
time_window_lengthSize of the time window in units of the macro time resolution.
macro_time_resolutionThe resolution of the macro time clock (default is 1.0).

The function calculates the intensity trace by dividing the time events into non-overlapping time windows of the specified length. The output array holds the count of photons in each time window, and n_output is updated accordingly. The input array contains the time points of events, and n_input is the total number of events. The time_window_length parameter defines the size of the time windows, and macro_time_resolution specifies the resolution of the macro time clock (default is 1.0). The calculated intensity trace is stored in the output array, and the total number of time windows is updated in n_output.

◆ get_array()

template<typename T >
void get_array ( size_t n_valid_events,
T * array,
T ** out,
int * n_out )
inline

Extracts a subarray of valid events from the input array.

This function takes an array of type T, representing events, and extracts a subarray containing the first n_valid_events elements. The size of the output array is updated in n_out. Memory is allocated for the output array, and the caller is responsible for freeing this memory when it is no longer needed.

Template Parameters
TThe data type of the array elements.
Parameters
n_valid_eventsNumber of valid events to extract.
arrayPointer to the input array containing events of type T.
[out]outPointer to the output array holding the extracted subarray.
[out]n_outPointer to the variable storing the size of the output array.

The function allocates memory for the output array and copies the first n_valid_events elements from the input array. The size of the output array is updated in n_out. It is the responsibility of the caller to free the allocated memory using free(*out) when the output array is no longer needed.

Parameters
[in]n_valid_eventsNumber of valid events to extract.
[in]arrayPointer to the input array containing events of type T.
[out]outPointer to the output array holding the extracted subarray.
[out]n_outPointer to the variable storing the size of the output array.

◆ ranges_by_time_window()

void ranges_by_time_window ( int ** output,
int * n_output,
unsigned long long * input,
int n_input,
double minimum_window_length,
double maximum_window_length = -1,
int minimum_number_of_photons_in_time_window = -1,
int maximum_number_of_photons_in_time_window = -1,
double macro_time_calibration = 1.0,
bool invert = false )

Returns time windows (tw), i.e., the start and stop indices for a minimum tw size and a minimum number of photons in a tw.

Parameters
output[out] Array containing the interleaved start and stop indices of the time windows in the TTTR object.
n_output[out] Length of the output array.
input[in] Array containing the macro times.
n_input[in] Number of macro times.
minimum_window_length[in] Minimum length of a time window (mandatory).
maximum_window_length[in] Maximum length of a time window (optional).
minimum_number_of_photons_in_time_window[in] Minimum number of photons a selected time window must contain (optional).
maximum_number_of_photons_in_time_window[in] Maximum number of photons a selected time window can contain (optional).
macro_time_calibration[in] Calibration factor for macro times (default is 1.0).
invert[in] If set to true, the selection criteria are inverted.

◆ selection_by_count_rate()

void selection_by_count_rate ( int ** output,
int * n_output,
unsigned long long * time,
int n_time,
double time_window,
int n_ph_max,
double macro_time_calibration = 1.0,
bool invert = false,
bool make_mask = false )

A count rate (cr) filter that returns an array containing a list of indices where the cr was smaller than a specified cr.

The filter is applied to a series of consecutive time events. The time events are sliced into time windows tw) which have at least a duration as specified by time_window. The tttr indices of the time windows are written to the output parameter output. Moreover, for every tw the number of photons is determined. If in a tw the number of photons exceeds n_ph_max and invert is false (default) the tw is not written to output. If If in a tw the number of photons is less then n_ph_max and invert is true the tw is not written to output.

Parameters
outputoutput array
n_outputnumber of elements in output array
timearray of times
n_timenumber of times
time_windowlength of the time window
n_ph_maxmaximum number of photons in a time window
macro_time_calibration
invertif invert is true (default false) only indices where the number
make_maskif true (default false) returns array filled with -1 or idx of length n_time of photons exceeds n_ph_max are selected