Skip to content

Running CaImAn on a Calcium Timelapse Recording

Hagai Har-Gil edited this page May 23, 2021 · 5 revisions

Running the Analysis Pipeline

As you may already know, this repository contains functions desgined to analyze calcium and vascular data taken by our lab. However, the first step of analysis is done using CaImAn, a Python package that analyzes calcium recording from one- and two-photon images. All of the scripts in the repo assume that CaImAn was run on the files you wish to analyze, and thus they'll process those results. Below we'll detail the necessary steps to take in order to analyze your data using CaImAn.

CaImAn Analysis Pipeline

Since CaImAn is a resource hog, we (almost) never run it on our own server ("Cortex", located at cortex.tau.ac.il). Instead, we'll use Cortex to look at the data, obtain a few key parameters that CaImAn needs in order to run well, and then run the actual code on the power8 server (power9login.tau.ac.il).

  1. Open a VNC session to cortex.tau.ac.il and connect to it.
  2. Move all the data you wish to analyze to a single folder.
  3. Using Fiji, open one of the recordings and write down somewhere the following parameters: a. Radius of the cell in pixels b. Average number of cells per 50x50 pixels patch c. Frame rate d. The data channel (if you recorded GCaMP in channel 1 and Texas Red in 2, then the data channel is 1)
  4. Copy the data folder to the following folder: /mnt/pblabfs/pblab/<YOUR NAME>. To access this folder, open the "Files" app on the VNC session and click the "Other locations" button. Then click on "Computer" and the folder "mnt" should be there. You can also your data to a sub-folder inside the mentioned folder. This means that if your data folder is called june12-gcamp6-mouse1 then the final data folder is /mnt/pblabfs/pblab/<YOUR NAME>/june12-gcamp6-mouse1.
  5. In the VNC session click the "Activities" button on the top left side of the screen and type in "CaImAn Analysis". Click the app that pops up.
  6. In the GUI, enter all of the required parameters. Note that the "foldername" field is the name of the folder that your data is in, without all of the prefixes. In the above example, that would be "<YOUR NAME>/june12-gcamp6-mouse1", but it can also simply be "<YOUR NAME>" - no "/mnt/pblabfs" is needed.
  7. Click the "Run CaImAn" button. The job number should appear below. After a few minutes if you look in the folder again you'll start seeing the result files popping up.
  8. If everything went well each file should now be accompanied by a few more files: a. A file containing only the data channel, its name ending with *CHANNEL_X.tif. b. A file containing the motion-corrected data, its name ending with *CHANNEL_X_els__d1_*.mmap. c. Two results files, one ending with .npz and the other with .hdf5.
  9. Issues with the run will be written to a file inside /mnt/pblabfs/pblab/caiman_scripts. To view these issues write in the terminal cat /mnt/pblabfs/pblab/caiman_scripts/XXXX.power9.tau.ac.il.ER, where XXXX is the job number. If you have no idea what was the problem please consult someone who might.
  10. Assuming everything worked out - back in the VNC session (if you left it), move these new files from their current folder back to your data folder. We don't want to cog up the /mnt/pblabfs/pblab disk.
  11. You probably want to view the results. Press the "Activies" button on the top left part of your VNC screen, and in the search bar write "caiman". An icon should appear named CaImAn GUI. Click on it, and after a few seconds you should see a dialoge screen that asks you for a results file name. Point it to the file ending with .hdf5. Then it will ask for the data - point it to the .mmap file. After it loads it up you should see a GUI that let's you inspect the components CaImAn found and even add and remove new ones.
  12. Congratulations - you're done.