Signal fitting

The function used for fitting Ca2+ release events is shown on Figure \ref{fig:fig1}. The shape of the function is described by 4 parameters: amplitude (\(A\)), rise and decay time constants (\(\tau_{rise},\tau_{decay}\)) and plateau duration (\(d\)). An additional parameter (\(\mu\)) determines the time when the maximum is reached. For the optimizer to obtain good performance when fitting the function used for fitting should be continously differentiable. The function describing a transient is:
\[ g(A, d, \tau_{d}, \tau_{r}, \mu, t) = A\cdot\left\{ \begin{array}{l l} 1-\exp\left( -\frac{t-\mu}{\tau_r}\right)\cdot\exp\left(-2\right) & \quad \mu-2\tau_r\le t\lt\mu\\\\ 1-\exp(-2) & \quad \mu\le t\lt \mu+d\\\\ \exp\left( -\frac{t-\mu-d}{\tau_d}\right)\cdot\left(1-\exp(-2)\right)& \quad t\ge\mu+d\\\\ 0 &\quad \mathrm{otherwise} \end{array} \right. \]

The transient consists of four phases: zero level before the onset of the transient, an exponential increase with time constant \(\tau_r\) starging when \(t=\mu-2\tau_r\), a plateau phase of duration \(d\) starting at \(t=\mu\) and an exponential decay with time constant \(\tau_d\) starting at \(t=\mu+d\)

The transient function is is convolved with a gaussian \(G(\sigma)\) to yield the actual fitting function:
\[ f(A, d, \tau_{d}, \tau_{r}, \mu, t, \sigma) = g \ast G \]
For notational purposes we shall represent the fit function parameters by (\mathbf{p}=
\left[
\begin{array}{c c c c c}
A&d&\tau{d}&\tau_{r}&\mu
\end{array}
\right]
). The smoothing parameter \(\sigma\) will be fixed for all pixels. Therefore, for the i-th pixel the k-th event is represented by \(f(\mathbf{p}_{i,k},t)\).

The entire raw signal for the i-th pixel can be represented as:
\[ F_i(t) = b(\mathbf{q}_i, t) + \sum_{k=0}^{m} f(\mathbf{p}_{i,k},t) + W + R \]
, where \(b\) is a n-th order polynomial with \(\mathbf{q}_i\) being the polynomial coefficients for the i-th pixel, summation is performed over all m events in the pixel, \(W\) consists of the noise and \(R\) is remaining residual not captured in the baseline nor events. Ideally, \(R=0\), but achieving this is limited by the accuracy of the event region detection (we cannot fit what we do not detect) and whether or not our fitting function is general enough to be able to approximate various types of events.

Because it is not know which part of the signal is the event and which is the baseline the first fit also has to estimate the baseline properties.
Signal in the candidate region is fitted with an extended fit function (Figure \ref{fig:fig1}) that also depends on relaxation baseline \(B\) and baseline offset \(C\). The \(C\) parameter allows for the possibility of an elevated background before the release event.

After paramater optimization with the extended fit function the same signal is fitted with a line. For both models the corrected Akaike Information Criterion (AICc \cite{Burnham_2004}) is calculated and the region is accepted only if the AICc for the fit function is less than the AICc for the line. This ensures that the goodness of the fit obtained with the fit function justifies the use of a more complicated model.

In order to reconstruct the entire image with all the pixels it is also necessary to know the location of the pixels. The parameter vector \(\mathbf{p}_i\) is extended with the coordinates of pixel i:
\[ \mathbf{r}_i = \left[\mathbf{p}_i,x_i,y_i\right] =\left[A_i, d_i ,\tau_{d,i},\tau_{r,i},\mu_i,x_i,y_i\right] = \left[\mathbf{p}^s_{i}, \mathbf{p}^p_{i}\right] \]
, where \(\mathbf{p}^s=\left[A,d,\tau{d},\tau_{r}\right]\) is the shape paramater vector and \(\mathbf{p}^p=\left[\mu,x,y\right]\) is the position parameter vector.

All k events detected in pixel i are represented by vectors
\(\mathbf{p}^s_{i,k}\) and \(\mathbf{p}^p_{i,k}\). These vectors can be stacked to creat an event matrix for pixel i:
\[ E_i = \left( \begin{array}{l l} \mathbf{p}^s_{i,0}&\mathbf{p}^p_{i,k}\\\\ \mathbf{p}^s_{i,1}&\mathbf{p}^p_{i,k}\\\\ \ldots\\\\ \mathbf{p}^s_{i,k}&\mathbf{p}^p_{i,k} \end{array} \right) = \left( \begin{array}{l l} E_i^s & E_i^p \end{array} \right) \]
The event matrix for the entire image is obtained by stacking all pixel event matrices:
\[ E=\left( \begin{array}{l} E_0\\\\ E_1\\\\ \vdots\\\\ E_i \end{array} \right) =\left( \begin{array}{l l} E_0^s& E_0^p\\\\ E_1^s& E_1^p\\\\ \vdots&\vdots\\\\ E_i^s& E_i^p \end{array} \right) =\left( \begin{array}{l l} E^s & E^p \end{array} \right) \]
, where \(E^s\) and \(E^p\) are shape and position submatrices, respectively, containing event shape and position parameters for all events from all pixels and making up the entire image event matrix \(E\). The separation of shape and position parameters for events is necessary in the next clustering step.