Browse Source

gin commit from nit-ope-de04

Modified files: 4
Deleted files: 1
sprenger 2 years ago
parent
commit
604e7b9c24
5 changed files with 234 additions and 324 deletions
  1. 53 0
      hands_on_1.ipynb
  2. 167 49
      hands_on_1_solution.ipynb
  3. 3 3
      hands_on_2.ipynb
  4. 11 29
      hands_on_2_solution.ipynb
  5. 0 243
      hands_on_3.ipynb

+ 53 - 0
hands_on_1.ipynb

@@ -69,6 +69,59 @@
    "outputs": [],
    "source": []
   },
+  {
+   "cell_type": "markdown",
+   "id": "494f81cd",
+   "metadata": {},
+   "source": [
+    "### Bonus Exercise 2a: Extended overview"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "8db6f6dc",
+   "metadata": {},
+   "source": [
+    "To get an overview of all channels it helps to plot each channel with an offset to avoid overlapping signal traces. Implement this by first normalizing the signal amplitude of each channel. For this first subtract the mean of each trace and then divide this rereferenced trace by it's standard deviation. Take advantage of the inherited numpy methods `mean` and `std` of an AnalogSignal.\n",
+    "\n",
+    "Plot each normalized trace with an offset corresponding to double its channel id, i.e. a vertical offset of 20 for the trace labelled with `channel_id` 10.\n",
+    "Save the figure in the `svg` format. What is the size of the resulting file?"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "c97fe6d6",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "markdown",
+   "id": "78cec6c1",
+   "metadata": {},
+   "source": [
+    "### Bonus Exercise 2b: Downsampling signals"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "f3f707c5",
+   "metadata": {},
+   "source": [
+    "The plot and svg file generated in the previous step contains information about all data points and consumes therefore more memory than needed to illustrate the traces. To improve this reduce the number of samples while preserving the shapes of the traces using the `downsample` method. Generate another overview plot with the downsampled signal and compare their svg file sizes.\n",
+    "\n",
+    "Note: Use only moderate downsampling factors (<=8) to avoid instabilities in the downsampling procedure. For higher downsampling factors downsample multiple times with lower downsampling factors."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "d8b05654",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
   {
    "cell_type": "markdown",
    "id": "766cb710",

File diff suppressed because it is too large
+ 167 - 49
hands_on_1_solution.ipynb


+ 3 - 3
hands_on_2.ipynb

@@ -10,7 +10,7 @@
     "These exercises build on concepts introduced in Tutorial 2\n",
     "\n",
     "## Preparation: Download public ephys dataset\n",
-    "On Linux you can download the compiled nix file via the command below. On other systems, please download the file manually from [here](https://gin.g-node.org/sprenger/multielectrode_grasp/raw/dataset_nix/datasets_nix/i140703-001_cut_74sec.nix) and save it in the same folder as this notebook. This is the same file as already used in Tutorial 2."
+    "On Linux you can download the compiled nix file via the command below. On other systems, please download the file manually from [here](https://gin.g-node.org/NeuralEnsemble/neo_elephant_teaching/raw/master/reach_to_grasp_material/i140703-001.nix) and save it in the same folder as this notebook. This is the same file as already used in Tutorial 2."
    ]
   },
   {
@@ -20,7 +20,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "!wget -O i140703-001.nix https://gin.g-node.org/sprenger/multielectrode_grasp/raw/dataset_nix/datasets_nix/i140703-001_cut_74sec.nix"
+    "!wget -O reach_to_grasp_material/i140703-001.nix https://gin.g-node.org/NeuralEnsemble/neo_elephant_teaching/raw/master/reach_to_grasp_material/i140703-001.nix"
    ]
   },
   {
@@ -42,7 +42,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "63dafe3f",
+   "id": "99906dba",
    "metadata": {},
    "outputs": [],
    "source": []

File diff suppressed because it is too large
+ 11 - 29
hands_on_2_solution.ipynb


+ 0 - 243
hands_on_3.ipynb

@@ -1,243 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "id": "503cb687",
-   "metadata": {},
-   "source": [
-    "# Hands-on session 3: Elephant (Solution)\n",
-    "\n",
-    "These exercises build on concepts introduced in Tutorial 3\n",
-    "\n",
-    "In this exercise, we will use the SPADE method of Elephant to find recurring patterns in the spike data of trial 1.\n",
-    "\n",
-    "\n",
-    "## Imports and Preparation"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "2fc1d993",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": [
-    "import quantities as pq\n",
-    "import neo.utils\n",
-    "import elephant\n",
-    "import viziphant"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "ae02a990",
-   "metadata": {},
-   "source": [
-    "### [Only required on MYBINDER] Download of the dataset"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "fb0d97b0",
-   "metadata": {
-    "pycharm": {
-     "name": "#%% md\n"
-    }
-   },
-   "source": [
-    "On Linux you can download the compiled nix file via the command below. On other systems, please download the file manually from here and save it in the same folder as this notebook."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "619675c9",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": [
-    "!wget -O reach_to_grasp_material/i140703-001.nix https://gin.g-node.org/sprenger/multielectrode_grasp/raw/dataset_nix/datasets_nix/i140703-001_cut_74sec.nix"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "id": "4d1cd9a4",
-   "metadata": {},
-   "source": [
-    "## Data preparation\n",
-    "\n",
-    "\n",
-    "1. Load the data `reach_to_grasp_material/i140703-001.nix` file using the `neo.io.NixIO` into a neo Block."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "d2e41fc5",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "id": "049f38c0",
-   "metadata": {},
-   "source": [
-    "2. In close analogy to the beginning of tutorial 3, prepare a Neo `Block`, containing one `Segment` of SGHF data of the first correct trial. Name this `Segement` by the variable `trial`, as in tutorial 3.  In contrast to the lecture, we will cut data from the trial start `TS-ON` to reward administration indicated by event `RW-ON`. To this end, first find also the `RW-ON` events similar to how we found `TS-ON` in tutorial 3. Then, in the call to `neo.utils.add_epoch()`, supply these as a second event `event2=` *instead* of giving `t_pre=0` and `t_post=2*pq.s`. This will cut from event 1 to event 2, instead of a fixed amount of 2 s around event 1 (as in tutorial 3)."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "caaf7e0d",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "id": "7564a093",
-   "metadata": {},
-   "source": [
-    "## SPADE analysis\n",
-    "\n",
-    "Note that patterns in this data are not easily to spot by eye in the rasterplot we developed in tutorial 3.\n",
-    "We use SPADE as a technique that does that for us by finding all patterns and checking for each pattern if it\n",
-    "occurs more often than expected given its complexity (number of neurons participating) and frequency.\n",
-    "Before going directly to the analysis we briefly explain SPADE's most important parameters:\n",
-    "\n",
-    "- `binsize`: temporal precision of the method. The smaller the binsize is, the more precisely we expect each single pattern to repeat. This raises an important question: which is the temporal precision that are you interested in? It depends on the scientific question! We often use 5ms, based on a number of studies on the minimal neuronal temporal precision.\n",
-    "- `winlen`: window length, or maximal length allowed to each pattern, expressed in bin units. SPADE will detect patterns with a temporal duration up to the window length. If winlen=1, then only synchronous patterns are detected. Are you interested in synchronous higher-order correlations? Are you interested in patterns with delays? Note: the higher the winlen parameter is, the more expensive (memory and time) the pattern search is!\n",
-    "- `min_spikes` and `min_neu`: minimum number of spikes and minimum number of neurons allowed in a pattern. These parameters are important, too. Do you want to look for pattern with a particular size? Are you interested in patterns with multiple spikes coming from the same neuron?\n",
-    "- `n_surr`: number of surrogates used for the statistical testing. If the number of surrogates is set to zero, then all patterns are retrieved by SPADE without further testing. If, instead, the number of surrogates is different from zero (typically we suggest to use a large number - the more the better!) then only the significant patterns are retrieved from the analysis. For simplicity, we will set this parameter to `n_surr=0` in the following.\n",
-    "\n",
-    "Next steps:\n",
-    "3. As in tutorial 3, select only good quality neurons using the annotations (i.e., SUA units, more than 10000 spikes,...)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "4d7cad57",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "id": "10d32abe",
-   "metadata": {
-    "pycharm": {
-     "name": "#%% md\n"
-    }
-   },
-   "source": [
-    "4. Run the SPADE analysis by executing the code given below:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "23f7d6b4",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "id": "1c3d05a6",
-   "metadata": {},
-   "source": [
-    "6. Let's look at the output in `patterns`. How many patterns were found? How does one pattern look as an output?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "994e3df5",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "id": "11523576",
-   "metadata": {},
-   "source": [
-    "7. Display five detected patterns in the data and their statistics by executing the Viziphant function calls given below"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "345f862e",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "cc8eedf4",
-   "metadata": {
-    "pycharm": {
-     "name": "#%%\n"
-    }
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "id": "15f335e8",
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3 (ipykernel)",
-   "language": "python",
-   "name": "python3"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 3
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython3",
-   "version": "3.9.7"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}