Replies: 12 comments 1 reply
-
Are you imaging dendrites or other non-somatic shapes? The I would be wary of skipping deconvolution: even if you don't care about spike counts, it can help you get better estimates of C during the source extraction step especially for lower SNR traces (this was one of the points of the original paper on CNMF: simultaneous denoising, demixing, deconvolution 😃 ): https://pubmed.ncbi.nlm.nih.gov/26774160/. Negative values can be very hard to interpret. Have you tried toggling the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. Sorry for my slow reply; I wanted to test a few things first. I am imaging non-somatic shapes, and I skip deconvolution by setting p=0 because my neurons are non-spiking. I see the above problem with method_init 'greedy_roi', and 'sparse_nmf'. If I use deconvolution by setting p=1 or p=2, and I set bas_nonneg=False, then I do not see the above problem. So thank you for that suggestion. But since my neurons are nonspiking, I do set p=0, and bas_nonneg seems to have no effect if p=0. My input movie is nonnegative, and it looks like negative values in the temporal component are introduced in line 214 of temporal.py, in function 'update_temporal_components', in this line: Can you help me understand the purpose of these lines (the first one, especially)? What is the meaning of the negative values after the first line? I don't understand why so much of the temporal component is getting clipped at the bottom. As I describe above, the clipped signal does not seem to be noise. Is it possible to make bas_nonneg=False have an effect when p=0? Or will that cause problems? Thank you! |
Beta Was this translation helpful? Give feedback.
-
It's pretty hard to say without seeing what the movie looks like, as well as what the reconstructed movie (AC) background (bf) and residuals (Y - AC - bf) look like. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. I've attached the movie output by this call to play_movie: estimates.play_movie(images_sliced, q_min=1, q_max=99.75, gain_res=2, magnification=2, I've also attached the raw movie (imgs), reconstructed movie (Y_rec), background (B), and residuals (Y_res), which I saved from within play_movie. I've also attached my input parameters (pars). Finally, I've attached the output of view_components, for one ROI (estimates.C at bottom). Like the example above, it shows clipping of low amplitude signal that correlates with an external variable roughly just as well as the parts that don't get clipped. I’ve also attached a scatterplot of that external variable vs. the same timeseries, and in red, the curve we expect to fit the scatterplot. You can see the lower amplitude part of the timeseries closely follows that curve. I’ve seen this in many ROIs of this cell type, so I don’t think it’s actually noise getting clipped. What do you think? Is a spatially and/or temporally distinct signal just being separated from a signal that better matches my input parameters? Could bas_nonneg=False fix this when p=0 (if it had an effect when p=0)? Thank you! Carl B.npy.zip |
Beta Was this translation helpful? Give feedback.
-
Hi, I honestly don't have the bandwidth to go through your files, can you post a video of the input movie, and reconstructed movie, background and residuals. You can drag and drop vids upto 10MB on GitHub |
Beta Was this translation helpful? Give feedback.
-
Hi |
Beta Was this translation helpful? Give feedback.
-
What are you imaging, this looks very different for what CNMF can do and seems to have high rank background. Have you tried CNMFE? |
Beta Was this translation helpful? Give feedback.
-
I'm 2-photon imaging GCaMP7f in axon terminals in the Drosophila brain at 5-8 Hz. The data above has been denoised with DeepCAD. But I see the same thing without denoising. Here, attached, is the same recording without the denoising. Also, I've included an example output of view_components, for one ROI in this recording without denoising, so you can see what's getting clipped in the timeseries when I don't include residuals. Finally, I've attached a screenshot of what happens when I include residuals (no clipping, on top), and do not include residuals (clipping, on bottom), for 3 ROIs from this recording without denoising. The red fit curves on top match how we expect activity in these ROIs to correlate with our external variable. The fits for the same ROIs on bottom do not match what we expect. It appears that valuable signal is lost to the residuals, with or without DeepCAD denoising. So I don't think this is an artifact of using denoising prior to source extraction. I have not used CNMF-E. Do you still recommend it, after reading this reply? Thanks! https://github.com/flatironinstitute/CaImAn/assets/20496060/5f24a820-75e7-4c7a-9269-3f6611847c2d |
Beta Was this translation helpful? Give feedback.
-
Hi. Do you still recommend CNMFE after reading my reply? Why does bas_nonneg=False have no effect when p=0? Is this an 'issue'? Should I post this to the 'issues' thread? Thanks |
Beta Was this translation helpful? Give feedback.
-
A lot of this is try and see what it looks like, I've never worked with movies like this so I cannot say for sure, you just have to try and see what happens. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Sorry I never dug that much into CNMFE, we currently don't have someone very experienced with CNMFE. What if you disable deconvolution (but I think it should be disabled with CNMFE anyways) |
Beta Was this translation helpful? Give feedback.
-
Hi
I use CNMF.fit, then CNMF.refit, to extract components from 2-photon GCaMP7f movies.
I use method_init graph_nmf. I skip deconvolution by setting p to 0. I use patches because SNR varies across the FOV.
Below is a temporal component (estimates.C) plotted with estimates.view_components.
It shows visual stimulus-evoked responses from a neuron. It is typical of my extracted traces.
The “inferred trace” (red trace), is estimates.C
The “filtered raw data” (blue trace) is estimates.C + residuals
The positive parts of the blue trace are obscured by the red trace.
A linear function of the visual stimulus predicts the “filtered raw data” very well, but not the “inferred trace”
I expect this linear function to predict this neuron’s responses, so I’ve been using this model as a positive control of my source extractions as I adjust CaImAn input parameters.
It’s clear from looking at the predictions that the model of the “filtered raw data” is better because it includes negative values.
Because of this, I don’t think these negative values are noise.
Based on my modeling, and my expectations, these negative values contain a similar amount of visually-evoked “signal” as the positive values.
But I thought that negative values in estimates.C represent noise.
Currently, in all my analysis, I use estimates.F_dff computed with use_residuals set to true. This gives me normalized traces with the negative parts preserved (i.e., it gives me something similar to a scaled version of the blue trace). And this gives me data that makes sense.
Can you help me understand these negative values, or why my “inferred trace” seems to be throwing away so much “signal” below zero?
Might my CaImAn input parameters be adjusted to make the “inferred trace” include this “signal”?
Thank you!
Carl
Beta Was this translation helpful? Give feedback.
All reactions