HelmchenLabSoftware / Cascade

Calibrated inference of spiking from calcium ΔF/F data using deep networks
GNU General Public License v3.0
123 stars 34 forks source link

Noise Level #59

Closed Marx666 closed 6 months ago

Marx666 commented 8 months ago

Hello,

I was trying Cascade on the df/f extracted from CaImAn, and I noticed that the noise level of my data was "Noise levels (mean, std; in standard units): 0.08, 0.04" which was much lower than 1. Is this a problem?

Thank you very much.

PTRRupprecht commented 8 months ago

Hi @Marx666,

Thank you for getting in touch. And yes, I think there is a problem. If you compute noise levels from raw data, typical values should be between 1 to 10.

The very low values that you are getting are indicating that you do not use the raw dF/F trace as input for Cascade (please notice that CaImAn also outputs a denoised trace, which is a fit of the data and should not be used as input for deconvolution at all); or that something is wrong with how your version of CaImAn computes the baseline.

If you have problems figuring this out, you can share a picture of how your extracted dF/F traces look like, then it will be very easy to judge.

Hope this helps a bit. Let me know if you need further help!

Peter

Marx666 commented 8 months ago

a picture of how your extracted dF/F traces look like

example_01 example_02 I post two traces as examples. They are the dff calculated by CaImAn using _cnmf_refit.estimates.detrend_dff based on denoised trace (C).

Should I use raw trace (C+YrA) to calculate instead?

PTRRupprecht commented 8 months ago

Hi @Marx666,

Yes, you are correct. This "denoised" trace should not be used for anything (also not for visualization in publications) because the assumptions underlying this denoising process were clearly wrong (at least in this case).

I also think that (C + YrA) will recover the raw trace instead. If you have doubts, don't hesitate to ask again! I'm not an expert for CaImAn (which I'm using only from time to time) and you might have to ask at the CaImAn repository for more technical questions, but I have a basic understanding of the algorithm

Peter

Marx666 commented 8 months ago

@PTRRupprecht Okay, I will try again with raw trace. Many thanks.

Marx666 commented 8 months ago

@PTRRupprecht Hello again. I tried with df/f calculated using raw traces, the noise level is about 0.3 now. Our data is from 2p imaging on slices, with really high SNR. So do you think I can still use Cascade on these data? Thank you very much.

PTRRupprecht commented 8 months ago

Hi @Marx666, Ok, I understand. I agree, in slices the noise level might be much lower, and 0.3 sounds like a reasonable value to me.

Of course, for the interpretation of your results, it is important to keep in mind that Cascade was trained on in vivo data, mostly in cortex. So, if you are doing imaging e.g. of striatum in slices, maybe with unphysiological external calcium, one should take the results with a grain of salt. But overall, you should be able to use Cascade on these data without major problems.

Let me know if something is still unclear.

Best wishes, Peter