denisecailab / minian

miniscope analysis pipeline with interactive visualizations
GNU General Public License v3.0
91 stars 36 forks source link

Finding DF/F #248

Open bahaaaldin214 opened 1 year ago

bahaaaldin214 commented 1 year ago

Hello, I am using the Minian pipeline Jupyter notebook. I was able to extract the data and save it into an .NC file for further analysis through python. I was then able to read that data with no issues. I saved the variables [A, C, S], from what I read, my understanding is those variables correspond to (correct me if im wrong)

A: 3d matrix with [height, width and unit id] C: calcium concentration array S: spike firing rate

I managed to iterate through the C and S variables with ease to graph each cell I wanted using the matplotlib library in python, but I was stuck on my next step.

My next step is to extract the calcium transients of each cell. As I have read in this article: Minian, an open-source miniscope analysis pipeline | eLife (elifesciences.org) or (https://elifesciences.org/articles/70661) They were able to use the CNMF-E toolbox to do this; however, this toolbox didn't seem to be well documented and I wasn't able to replicate the results. Here is a link to the CNMF-E toolbox that extracts the DF_F: https://github.com/zhoupc/CNMF_E/blob/master/ca_source_extraction/utilities/extract_DF_F.m

I am looking for some guidance on how I should approach this problem; if you could, you can reply to this email or reach me at my contact information below. I also Cc the researcher I am working under.

EricThomson commented 10 months ago

Caiman maintainer here -- that is some really old unsupported matlab code you referenced for extracting DFF: the more up-to-date Python code is here:

detrend_df_f()

Unfortunately we don't do an amazing job describing/documenting DF/F and this is something I'd really like to improve.

The traditional measure of dff is just dff(t) = (F(t)-F0)/F0, where F0 is baseline activity. In the early days, F0 was activity during some initial stretch of recording when the brain "wasn't doing anything" (e.g., for retinal ganglion cells, think of animal sitting in dark before the stimulus is presented). This is fine in some limited contexts, but is problematic for many systems, so is now measured using different methods. E.g., overall mean, moving average, moving percentile. The latter is the most popular now, and is (almost) what we do in Caiman, and you can do it with your own data. (We have an additional term in the denominator in Caiman based on background activity, but I think it can often usually safely be ignored).

gadsfly commented 5 months ago

checkout this: https://github.com/flatironinstitute/CaImAn/issues/1285