flatironinstitute / CaImAn

Computational toolbox for large scale Calcium Imaging Analysis, including movie handling, motion correction, source extraction, spike deconvolution and result visualization.
https://caiman.readthedocs.io
GNU General Public License v2.0
640 stars 370 forks source link

Analysis inside a region designated by a Binary Mask #1162

Open ggmirandac opened 1 year ago

ggmirandac commented 1 year ago

Please fill in the following for any issues

Your setup:

  1. Operating System (Linux, MacOS, Windows): MacOS
  2. Hardware type (x86, ARM..) and RAM: M1 16 gb
  3. Python Version (e.g. 3.9): 3.10
  4. Caiman version (e.g. 1.9.12): last one
  5. Which demo exhibits the problem (if applicable): demo_seeded_CNMF.ipynb
  6. How you installed Caiman (pure conda, conda + compile, colab, ..): jupyter notebook using micromamba to install
  7. Details:

Hi

Sorry for so many questions.

I am currently working on analyzing the calcium traces on A. thaliana and CaImAn doesn't seem to work well because of the weird shape of the cells (I am using your tool because it not seems to be a better one to analyze calcium). And I'm trying to use a set of binary masks for the analysis of the specific region that I am trying to understand the behavior.

My main issues are that, on one side, the binary masks are weirdly shaped because I am analyzing the cell wall: (one example provided, I have approximately 120 more)

binary_mask_105

And CaImAn doesn't seem to work good on this, because when I run the seeded analysis based on the .ipynb file that I gives me the following output for the analysis:

Screenshot 2023-08-24 at 18 29 59

And as you can see, the region that was selected by the CNMF algorithm is different from the presented on the binary mask.

Is there a way to just extract the calcium traces on the cell wall using CaImAn as a tool for background signal extraction and deconvolution of the data extracted, but still extracting the traces on the region marked with the binary mask?

Best regards

kushalkolar commented 1 year ago

I'm not sure how deconvolution would make sense here since that is based on a biophysical model of spike rate and calcium dynamics in neural soma.

Also, I'm not sure if Caiman's way of modeling background (ring model etc., Eric knows more) can apply to cell walls.

On Thu, Aug 24, 2023, 18:33 Gabriel Miranda @.***> wrote:

Please fill in the following for any issues

Your setup:

  1. Operating System (Linux, MacOS, Windows): MacOS
  2. Hardware type (x86, ARM..) and RAM: M1 16 gb
  3. Python Version (e.g. 3.9): 3.10
  4. Caiman version (e.g. 1.9.12): last one
  5. Which demo exhibits the problem (if applicable): demo_seeded_CNMF.ipynb
  6. How you installed Caiman (pure conda, conda + compile, colab, ..): jupyter notebook using micromamba to install
  7. Details:

Hi

Sorry for so many questions.

I am currently working on analyzing the calcium traces on A. thaliana and CaImAn doesn't seem to work well because of the weird shape of the cells (I am using your tool because it not seems to be a better one to analyze calcium). And I'm trying to use a set of binary masks for the analysis of the specific region that I am trying to understand the behavior.

My main issues are that, on one side, the binary masks are weirdly shaped because I am analyzing the cell wall: (one example provided, I have approximately 120 more)

[image: binary_mask_105] https://user-images.githubusercontent.com/63483031/263118990-cceb35dd-c645-452b-b08f-e5ec5db7aa4b.png

And CaImAn doesn't seem to work good on this, because when I run the seeded analysis based on the .ipynb file that I gives me the following output for the analysis: [image: Screenshot 2023-08-24 at 18 29 59] https://user-images.githubusercontent.com/63483031/263120220-ddf64441-821a-47cc-9e60-b1ed693e07a5.png

And as you can see, the region that was selected by the CNMF algorithm is different from the presented on the binary mask.

Is there a way to just extract the calcium traces on the cell wall using CaImAn as a tool for background signal extraction and deconvolution of the data extracted, but still extracting the traces on the region marked with the binary mask?

Best regards

— Reply to this email directly, view it on GitHub https://github.com/flatironinstitute/CaImAn/issues/1162, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHXXRBIAXMMRMBWY6J7OVLXW7JELANCNFSM6AAAAAA35VRYGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

EricThomson commented 10 months ago

Coming back to issues from 2023 that I let slide.

So it seems you basically want to use a supplied mask to extract signals, but first use caiman to remove background?

This should be pretty easy to do. Since you are doing CNMF, you can save the Y-bf movie, and then and use your masks in ImageJ (I can't help you with the latter but I assume it's a common ImageJ thing 😄 ). Y is the full movie, and b*f is the background movie. (b,f are in estimates class and are background components: spatial and temporal respectively).