juliencarponcy / trialexp

MIT License
2 stars 4 forks source link

Potential issue in the calculation of dF/F #8

Closed teristam closed 1 year ago

teristam commented 1 year ago

According to the sample notebook at https://github.com/ThomasAkam/photometry_preprocessing/blob/master/Photometry%20data%20preprocessing.ipynb

In the dF/F calculation, the denominator should be the low-pass filter signal, not the photobleached correct signal. But in

https://github.com/juliencarponcy/trialexp/blob/b5765531083a9c17be9e1fcbc56a171b1826f4a9/trialexp/process/pyphotometry/utils.py#L170-L191

the filtered signal actually is the low-passed and high-passed signal. The high-passed signal will have a baseline very close to zero, which will lead to problem when calculating analog_1_baseline_fluo and subsequently dF/F

juliencarponcy commented 1 year ago

Hi Teris,

Well spotted, I knew there were something wrong with the filtering and the order I implemented stuff there. Begun to come back to it on Friday and begun to see the issue from a bit closer but I did not realised yet it was the dividing by the zero centered LP filtered that was the culprit. Well spotted. I'm still traveling right now and will be in the lab tomorrow morning.

Will fix later today.

Thanks very much.

Julien

juliencarponcy commented 1 year ago

Fixed in : https://github.com/juliencarponcy/trialexp/pull/9/commits/2bd4307af9ce2096ff1673b56cf6bacf0a2a8127#diff-90aedd18a2a5cd46987018614831622fb110ef9b08b1d3baad395bf36c0a6e1c

The parameter named high_pass was renamed to baseline_low_pass to avoid confusion:

Indeed baseline substraction involve doing a very low LOW-PASS filtering (0.001 as per Thomas Akam examples) instead of a high-pass at 0.001.

Fix implemented in current Experiment workflow (data_import.py), switched to (semi) functional method in https://github.com/juliencarponcy/trialexp/commit/e1d585a4bcc4137084603a14fa555ba6f7d830f3