Calcium Imaging Analysis Tool CaImAn Setup (Python)

In this article, I will introduce a tool called CaImAn (Calcium Imaging Analysis). Official site (https://github.com/flatironinstitute/CaImAn) This software has various functions such as motion collection of calcium imaging videos, cell extraction, and signal deconvolution. It seems to be the standard of current calcium imaging analysis tools.

There are Python version and MATLAB version of CaImAn, but since the installation method of Python version is complicated and there is no Japanese document, it is summarized below. (The MATLAB version is easier to use, so it is recommended for those who have MATLAB.)

Installation of CaImAn

The installation method is as described in the linked Installation. Python 3.6 recommended, Anaconda or Miniconda required. You can install mac or linux just by running the bash command, but windows is a bit complicated. Below is the case when I tried it on windows around the end of 2018 and it worked.

First of all, you need to install "Desktop Development Tools with C ++" and "C / C ++ CLI Tools" of Visual Studio 2017. Download Visual Studio 2017 from the Microsoft home page. Community Edition is free. After that, start the installer and check the two workloads "Desktop Development Tools with C ++" and "C / C ++ CLI Tools" to install.

Next, create a virtual environment for CaImAn in Anaconda. Let's execute the command with anaconda prompt.

git clone  https://github.com/flatironinstitute/CaImAn
cd CaImAn
conda env create -f environment.yml -n caiman

You have now created a virtual environment called caiman in Anaconda. Next, let's operate the two files in the folders under C: \ Users \ (user name) \ Anaconda3 \ envs \ caiman .

  1. Open "keras_activate.bat" and change the environment variable KERAS_BACKEND from theano to tensorflow.
  2. Delete "vs2015_compiler_vars.bat".

Then install CaImAn.

conda install -n caiman vs2017_win-64
activate caiman
pip install .
copy caimanmanager.py ..
conda install numba
cd ..

Next, let's create a folder to put the execution script and analysis data.

caimanmanager.py install

You now have a folder called caiman_data in your current directory. I think the analysis should be done in this folder.

Try running the demo code

You can use demo_caiman_basic.py in \ caiman_data \ demos \ general as demo code. Let's run it and see if it works.

cd caiman_data\demos\general
demo_caiman_basic.py

When executed, the following screen will appear. 1.png This is an extract of the cell shape. It is numbered.

2.png And this shows the change in brightness of each cell, that is, the change in electrical activity. You can switch and display cells with the arrow keys.

In this demo code, we have extracted the blinking cells from the video (demoMovie.tif in the example_movies folder). Adjusting the parameters in the code will change the result.

At the end

You can now use the Python version of CaImAn. I plan to write a separate article on how to use the MATLAB version and how to deconvolution. Regarding the cell extraction algorithm, it seems that after extracting the candidate region using CNMF (conditional non-negative matrix factorization), it is judged whether it is a cell or not using CNN (convolutional neural network).

Recommended Posts

Calcium Imaging Analysis Tool CaImAn Setup (Python)
Python visualization tool for data analysis work
Pure Python version online morphological analysis tool Rakuten MA
Data analysis with python 2
Python: Time Series Analysis
PyOpenGL setup on Python 3
Data analysis using Python 0
Data analysis overview python
Voice analysis with python
Python data analysis template
Association analysis in Python
Voice analysis with python
Data analysis with Python
Regression analysis in Python
Create a simple video analysis tool with python wxpython + openCV
3. Natural language processing with Python 5-2. Emotion intensity analysis tool VADER