Browse Source

Slidified tutorial 4

Michael Denker 2 years ago
parent
commit
b323318281
2 changed files with 156 additions and 31 deletions
  1. 1 0
      create_slides.sh
  2. 155 31
      tutorial_4.ipynb

+ 1 - 0
create_slides.sh

@@ -1,3 +1,4 @@
 jupyter nbconvert tutorial_1.ipynb --to slides
 jupyter nbconvert tutorial_2.ipynb --to slides
 jupyter nbconvert tutorial_3.ipynb --to slides
+jupyter nbconvert tutorial_4.ipynb --to slides

+ 155 - 31
tutorial_4.ipynb

@@ -2,7 +2,11 @@
  "cells": [
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "# An example of Gaussian Process Factor Analysis (GPFA)\n",
     "\n",
@@ -18,7 +22,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "Gaussian-process factor analysis (GPFA) is a dimensionality reduction method\n",
     "[1] for neural trajectory visualization of parallel spike trains. GPFA applies\n",
@@ -42,14 +50,22 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "The implementation inherits from the basic class for all estimators in `scikit-learn` and thus can be used analogous to e.g. `sklearn.decomposition.PCA`. Furthermore it enable usage of the cross-validation functions of `sklearn.model_selection`."
    ]
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Imports and preparation"
    ]
@@ -90,7 +106,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Loading the data\n",
     "\n",
@@ -111,7 +131,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Pre-select the data for analysis\n",
     "\n",
@@ -142,6 +166,9 @@
     "ExecuteTime": {
      "end_time": "2020-10-20T12:32:46.296006Z",
      "start_time": "2020-10-20T12:32:46.291044Z"
+    },
+    "slideshow": {
+     "slide_type": "subslide"
     }
    },
    "outputs": [],
@@ -160,7 +187,11 @@
   {
    "cell_type": "code",
    "execution_count": 6,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [],
    "source": [
     "# Create new segments of data cut according to the analysis epochs \n",
@@ -190,7 +221,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "### Select the spiketrains for the analysis\n",
     "\n"
@@ -222,7 +257,11 @@
   {
    "cell_type": "code",
    "execution_count": 8,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "name": "stdout",
@@ -260,7 +299,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "The order of spiketrains should remain the same over trials. Check that the order of spiketrains is the same in all trials:"
    ]
@@ -278,7 +321,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Keep track of trial conditions\n",
     "\n",
@@ -299,7 +346,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Apply GPFA"
    ]
@@ -324,14 +375,22 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "The dimensionality `x_dim` is chosen in _ad hoc_ at this point. The two bonus exercises deal with this choice in a more systematic way, but are computationally more expensive and too time-consuming for the scope of this tutorial."
    ]
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "The spiketrains are internally binned with a certain `bin_size` to obtain a vector of spike counts for each time bin. We should choose it such that at least a few spikes fall into each time bin. Remember that we pre-selected spiketrains to have an average firing rate $> 5$ Hz. "
    ]
@@ -361,7 +420,11 @@
   {
    "cell_type": "code",
    "execution_count": 13,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "name": "stdout",
@@ -383,7 +446,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "### Latent Variables - Timescales\n",
     "\n",
@@ -393,7 +460,11 @@
   {
    "cell_type": "code",
    "execution_count": 14,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -426,7 +497,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "### Orthonormalized Latent Variables - Ordered by explained variance\n",
     "\n",
@@ -443,7 +518,11 @@
   {
    "cell_type": "code",
    "execution_count": 15,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -477,7 +556,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "### Visualize trajectories in 2D/3D"
    ]
@@ -485,7 +568,11 @@
   {
    "cell_type": "code",
    "execution_count": 16,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -514,7 +601,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "In 2D we already observe a splitting between the average trajectories for precision grip and side grip. Maybe in a 3D visualization this becomes clearer. To further get an idea of the time course, let us plot single-trial event markers onto the trajectories."
    ]
@@ -553,7 +644,11 @@
   {
    "cell_type": "code",
    "execution_count": 19,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -585,7 +680,11 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "### Loading Matrix - The mapping between neural and latent space"
    ]
@@ -593,7 +692,11 @@
   {
    "cell_type": "code",
    "execution_count": 20,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -635,14 +738,22 @@
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "source": [
     "Looking at these two plots next to each other, one can see that some latent variables have a large impact on the activity of a subset of neurons."
    ]
   },
   {
    "cell_type": "markdown",
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "slide"
+    }
+   },
    "source": [
     "## Estimate needed dimensionality"
    ]
@@ -650,7 +761,11 @@
   {
    "cell_type": "code",
    "execution_count": 21,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [],
    "source": [
     "bin_size = 20 * pq.ms\n",
@@ -662,7 +777,11 @@
   {
    "cell_type": "code",
    "execution_count": 22,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "name": "stdout",
@@ -684,7 +803,11 @@
   {
    "cell_type": "code",
    "execution_count": 23,
-   "metadata": {},
+   "metadata": {
+    "slideshow": {
+     "slide_type": "subslide"
+    }
+   },
    "outputs": [
     {
      "data": {
@@ -770,6 +893,7 @@
   }
  ],
  "metadata": {
+  "celltoolbar": "Slideshow",
   "kernelspec": {
    "display_name": "Python 3 (ipykernel)",
    "language": "python",
@@ -785,7 +909,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.12"
+   "version": "3.8.0"
   }
  },
  "nbformat": 4,