Open kouichi-c-nakamura opened 1 year ago
I think there are several critical issues
I agree with all three points.
I've noticed that chunks (30 s, 50% overlap) are not connected smoothly, and sometimes looks like a staircase. This was expected.
Instead of averaging the two values for the same data points in two chunks, we can mix them with linearly increasing/decreasing weights. So the contribution of a chunk is minimum (~0) at the end of the chunk but the maximum (1.0) at the center (see the illustration). Already been implemented (will make a branch and Pull Request) and this method seems better.
At the moment I cannot explain this phenomenon because both red and green channels look totally normal and we still have this problem. Note that the signal amplitude is strangely too small for 70 s in top trace (estimated motion). This is not a problem of just one chunk (30 s long), but apparently happening to 3 consecutive chunks in this particular case.
Let me know if you have any ideas. @teristam
Maybe
Another idea.
It's been confirmed that the decays of red and green channels take different time courses.
Given that red and green signals are not strictly moving together, but only "roughly", it may be worth trying linear regression on chunks after applying a low-pass filter of ~5 Hz or ~10 Hz. The blurred filtered curves may be easier to fit together. Then the slope and intercept can be applied to the signal immediately before that low-pass filtering.
At the level of waveform average, it really seems that the red signal can be subtracted from the green signal. Note that, in the average waveform, curves are smoothed by averaging itself. Smoothing may be the key to fitting.
kms058-2023-03-24-151254
Here I summarise what I've learned so far about photometry signal processing. This can include mistakes.
$$ \frac{\Delta F} {F} = \frac{F - F_0}{F_0} $$
where $F_0$ is baseline signal.
1 simplest $\frac{\Delta F} {F}$
In the simplest case, $F_0$ can be a constant value from baseline recording.
$$ \frac{\Delta F} {F} = \frac{F - F_0}{F_0} $$
is simiply normalising the signal change from baseline $F - F_0$ to the baseline $F_0$
The baseline is 0 ($\because \Delta F = 0$).
A value of 1 (100%) means that fluorescence is twice as high as the baseline.
A value of -1 (-100%) means a negative deflection with the size of the baseline (the absolute signal is 0)
2. Using isosbestic wavelength
In reality, you almost always see a decay of signal over time due to photobleaching.
People often use a different wavelength of light, called isosbestic wavelength, at which fluorescence signal doesn't change in response to the activation of the fluorescent sensor.
$F_0$ would be "fitted control", i.e. linear regression (or other fitting methods)-based estimate of signal from the channel for isosbestic wavelength.
$$ \frac{\Delta F} {F} = \frac{F - F_0}{F_0} $$
in this case, both $F$ and $F_0$ will be a vector the same length. And you can do element-wise subtraction and division.
On average, $\frac{\Delta F} {F}$ will be around 0, because $F$ should fluctuate around $F_0$.
eg. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4790813/#F5
dLight1.2's isosbestic point is 405 nm according to this paper. However, it seems that they just took someone else's data for GCaMP sensors. Robinson JE, Coughlin GM, Hori AM, Cho JR, Mackey ED, Turan Z, Patriarchi T, Tian L, Gradinaru V (2019) Optical dopamine monitoring with dLight1 reveals mesolimbic phenotypes in a mouse model of neurofibromatosis type 1. Elife 8:e48983, https://doi.org/[10.7554/eLife.48983](https://doi.org/10.7554/eLife.48983)
3. Using control fluorescent repoter
In our case, instead of using an isosbestic wavelength, we use a control fluorescent reporter, tdTomato.
Thomas Akam's justification for his method can be found here:
https://github.com/ThomasAkam/photometry_preprocessing/issues/1
The two fluorescent proteins may not bleach at the same rate.
In his implementation, and also in ours,
$$ \frac{\Delta F} {F} = \frac{F_{corrected}}{F_0} $$
$F_0$ is the exponential decay fit of bleaching.
$F{corrected}$ is motion-corrected signal: $F{corrected} = F - F_{motion \space estimate}$
Because $F_{corrected}$ should fluctuate around 0, $\frac{\Delta F} {F}$ also fluctuate around 0.
In our case,
$$ \frac{\Delta F} {F} = \frac{F - F_{motion \space estimate}}{F_0} $$
where $F_0$ is low-pass filtered slow component of $F$.
https://github.com/juliencarponcy/trialexp/blob/d42df8479ff7e4544c4e75a9d799198a61c4648a/trialexp/process/pyphotometry/utils.py#LL69C1-L72C1
https://github.com/juliencarponcy/trialexp/blob/d42df8479ff7e4544c4e75a9d799198a61c4648a/trialexp/process/pyphotometry/utils.py#L89