Skip to content

Commit

Permalink
Notebooks: revert 41828ff (based on mostly in-person discussion)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgunn committed Feb 9, 2024
1 parent c2f65c5 commit 1c1167c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions demos/notebooks/demo_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"# CNMF demo pipeline: Intro\n",
"This demo provides a full pipeline for the analysis of a two-photon calcium imaging dataset using the CaImAn software package. It demonstrates how to use Caiman for the following analysis steps:\n",
"\n",
"![Full CNMF Workflow](https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/full_cnmf_workflow.jpg)\n",
"![Full CNMF Workflow](../../docs/img/full_cnmf_workflow.jpg)\n",
"\n",
"1) Apply the nonrigid motion correction (NoRMCorre) algorithm for motion correction.\n",
"2) Apply the constrained nonnegative matrix factorization (CNMF) source separation algorithm to extract initial estimates of neuronal spatial footprints and calcium traces. \n",
Expand Down Expand Up @@ -465,7 +465,7 @@
"## Motion Correction\n",
"The first substantive step in our analysis pipeline is to remove motion artifacts from the original movie:\n",
"\n",
"<img src=\"https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/normcorre_workflow.jpg\" alt=\"motion correction workflow\" width=\"700\"/>\n",
"<img src=\"../../docs/img/normcorre_workflow.jpg\" alt=\"motion correction workflow\" width=\"700\"/>\n",
"\n",
"It is *very* important to get rid of motion artifacts, as the subsequent CNMF source separation algorithm assumes that each pixel represents the same region of space\n",
"\n",
Expand Down Expand Up @@ -662,7 +662,7 @@
"\n",
"Everything is now set up for running CNMF. This algorithm simultaneously extracts the *spatial footprint* and corresponding *calcium trace* for each component. \n",
"\n",
"![cnmf patch flow image](https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/cnmf_workflow.jpg)\n",
"![cnmf patch flow image](../../docs/img/cnmf_workflow.jpg)\n",
"\n",
"It also performs *deconvolution*, providing an estimate of the spike count that generated the calcium signal in the movie. "
]
Expand All @@ -673,7 +673,7 @@
"source": [
"The algorithm is parallelized as illustrated here:\n",
"\n",
"<img src=\"https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/cnmf_patches.jpg\" alt=\"cnmf patch flow\" width=\"500\"/>\n",
"<img src=\"../../docs/img/cnmf_patches.jpg\" alt=\"cnmf patch flow\" width=\"500\"/>\n",
"\n",
"1) The movie field of view is split into overlapping patches.\n",
"2) These patches are processed in parallel by the CNMF algorithm. The degree of parallelization depends on your available computing power: if you have just one CPU then the patches will be processed sequentially. \n",
Expand Down Expand Up @@ -935,7 +935,7 @@
"# Component Evaluation\n",
"As already mentioned, the initial estimates produced by CNMF contains many spurious components. Our next step is to do some some quality control, cutting out the bad estimates to arrive at our final set of estimates:\n",
"\n",
"![component evaluation image](https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/evaluation_workflow.jpg)"
"![component evaluation image](../../docs/img/evaluation_workflow.jpg)"
]
},
{
Expand All @@ -950,7 +950,7 @@
"\n",
"The first two criteria are illustrated schematically here (see also Figure 2 of <a href=\"https://elifesciences.org/articles/38173\">the Caiman paper</a>):\n",
"\n",
"![component evaluation image](https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/component_evaluation.jpg)"
"![component evaluation image](../../docs/img/component_evaluation.jpg)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions demos/notebooks/demo_pipeline_cnmfE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"# CNMF-E demo pipeline: Intro \n",
"This notebook demonstrates how to use Caiman for processing 1p microendoscopic data. It shows how to use Caiman for the following steps:\n",
"\n",
"![workflow diagram](https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/full_cnmfe_workflow.jpg)\n",
"![workflow diagram](../../docs/img/full_cnmfe_workflow.jpg)\n",
"\n",
"1. Apply the nonrigid motion correction (NoRMCorre) algorithm for motion correction to the original movie.\n",
"2. Apply the constrained nonnegative matrix factorization endoscopic (CNMF-E) source separation algorithm to extract an initial estimate of neuronal spatial footprint and calcium traces.\n",
Expand Down Expand Up @@ -475,7 +475,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/bokeh_menu.jpg\" align=\"right\" width=\"200\"></img>\n",
"<img src=\"../../docs/img/bokeh_menu.jpg\" align=\"right\" width=\"200\"></img>\n",
"Using `nb_inspect_correlation_pnr()`, you can inspect the correlation and PNR images to find threshold values for these quantities: `min_corr` and `min_pnr`. You can adjust the range of values displayed in the two subplots below by choosing the Y-box select tool (third button from the left -- highlighted in yellow in the accompanying image to the right) and selecting the desired region in the histograms on the right hand side of each image. You can also use the pan button (first button on the left) to zoom/adjust the axis limits in the histogram to make it easier to see the limits."
]
},
Expand Down Expand Up @@ -527,7 +527,7 @@
"source": [
"<div class=\"alert alert-info\">\n",
" <h2>CNMFE initialization: More on correlation and peak-to-noise-ratio</h2>\n",
" <img src=\"https://raw.githubusercontent.com/flatironinstitute/CaImAn/main/docs/img/mn_centered_gaussian.jpg\" align=\"right\" width=\"200\"></img>\n",
" <img src=\"../../docs/img/mn_centered_gaussian.jpg\" align=\"right\" width=\"200\"></img>\n",
"How are correlation and peak-to-noise ratio actually calculated? First Caiman convolves the motion corrected movie with a <i>mean-centered Gaussian</i> (example to the right). The sigma of the Gaussian is <em>gSig</em>, and mean centering is turned on by setting <em>center_psf</em> to <em>True</em>. This mean centering creates a Gaussian with a positive peak in the middle of width <i>approximately</i> <em>gSig/2</em>, surrounded by a negative trench, and a ledge of zeros around the outer edges. This crucial preprocessing filter serves to highlight neuronal peaks and smooth away low-frequency background activity.\n",
"\n",
"<p>The function <em>correlation_pnr()</em> applies this mean-centered Gaussian to each frame of the motion corrected movie and returns the correlation image of that movie, as well as the peak-to-noise-ratio (PNR). The correlation image is the correlation of each pixel with its neighbors. The PNR is the ratio of the maximum magnitude at a pixel to the noise value at that pixel (it is a fast and rough measure of signal-to-noise). As mentioned above, both of these values tend to be higher in pixels that contain neurons. The CNMFE initialization procedure is to set a threshold for both quantities, take their <i>product</i>, and use the peaks in this product map to find <b>seed pixels</b> for initialization of the CNMFE source separation algorithm.</p>\n",
Expand Down

0 comments on commit 1c1167c

Please sign in to comment.