Browse Source

gin commit from nit-ope-de04

Modified files: 8
sprenger 2 years ago
parent
commit
8203e72f3c
6 changed files with 138 additions and 123 deletions
  1. 3 0
      .gitignore
  2. BIN
      reach_to_grasp_material/i140703-001.nix
  3. BIN
      reach_to_grasp_material/l101210-001.nix
  4. 33 35
      tutorial_1.ipynb
  5. 62 48
      tutorial_2.ipynb
  6. 40 40
      tutorial_3.ipynb

+ 3 - 0
.gitignore

@@ -14,3 +14,6 @@
 # project specific files
 my_first_neo_dataset.nix
 setup_file.nix
+hands_on_1-downsample.svg
+hands_on_1-overview.svg
+results.nix

BIN
reach_to_grasp_material/i140703-001.nix


BIN
reach_to_grasp_material/l101210-001.nix


+ 33 - 35
tutorial_1.ipynb

@@ -39,7 +39,9 @@
    "source": [
     "## Data modalities in electrophysiology\n",
     "\n",
-    "![Data sources](./neo_material/ephys_data_modalities.png)\n"
+    "![Data sources](./neo_material/ephys_data_modalities.png)\n",
+    "\n",
+    "...and many more file formats to capture those"
    ]
   },
   {
@@ -51,9 +53,9 @@
     }
    },
    "source": [
-    "How can these diverse data types and formats by treated in a common framework to \n",
-    "- allow combined analyses\n",
-    "- facilitate reproducibility\n",
+    "**Goal:** Treat electrophysilogy and other data types in a common framework to \n",
+    "- allow analyses across modalities\n",
+    "- facilitate reproducibility analysis\n",
     "- simplify scientific workflows"
    ]
   },
@@ -397,8 +399,10 @@
     "- `.time_slice()` to crop to a specific time range\n",
     "- `.merge()` to combine multiple objects of the same type\n",
     "- `.concatenate()` to append multiple signal objects\n",
-    "- `.downsample()` to create a new signal with a different sampling rate\n",
-    "- `.magnitude` to extract the underlying numpy array\n",
+    "- `.downsample()` to create a new signal with a lower sampling rate\n",
+    "- `.magnitude` to strip all neo features and extract the underlying numpy array\n",
+    "- `.units` to extract the physical unit of the signal\n",
+    "- `dimensionality.latex` to extract a string representation of the physical unit\n",
     "- check out the jupyter `help()` to discover more in the documentation!"
    ]
   },
@@ -440,36 +444,30 @@
    },
    "source": [
     "### Neo structure\n",
-    "\n",
     "```\n",
-    "Block 0\n",
-    "    .segments\n",
-    "        Segment 0\n",
-    "            .analogsignals\n",
-    "                AnalogSignal 0\n",
-    "                AnalogSignal 1\n",
-    "            .spiketrains\n",
-    "                SpikeTrain 0\n",
-    "                SpikeTrain 1\n",
-    "                SpikeTrain 2\n",
-    "        Segment 1\n",
-    "            .analogsignals\n",
-    "                AnalogSignal 0\n",
-    "                AnalogSignal 1\n",
-    "            .spiketrains\n",
-    "                SpikeTrain 0\n",
-    "                SpikeTrain 1\n",
-    "                SpikeTrain 2\n",
-    "    .groups\n",
-    "        Group 0\n",
-    "            .analogsignals\n",
-    "                ...\n",
-    "            .spiketrains\n",
-    "                ...\n",
-    "            .events\n",
-    "                ...\n",
-    "            .epochs\n",
-    "            ...\n",
+    "*Neo objects*                        *Object access*\n",
+    "\n",
+    "Block 0                              block\n",
+    "    Segment 0                        block.segments[0]\n",
+    "        AnalogSignal 0               block.segments[0].analogsignals[0]\n",
+    "        AnalogSignal 1               block.segments[0].analogsignals[1]\n",
+    "        SpikeTrain 0                 block.segments[0].spiketrains[0]\n",
+    "        SpikeTrain 1                 block.segments[0].spiketrains[1]\n",
+    "        SpikeTrain 2                 block.segments[0].spiketrains[2]\n",
+    " \n",
+    "    Segment 1                        block.segments[1]\n",
+    "        AnalogSignal 2               block.segments[1].analogsignals[0]\n",
+    "        AnalogSignal 3               block.segments[1].analogsignals[1]\n",
+    "        SpikeTrain 3                 block.segments[1].spiketrains[0]\n",
+    "        SpikeTrain 4                 block.segments[1].spiketrains[1]\n",
+    "        SpikeTrain 5                 block.segments[1].spiketrains[2]\n",
+    "\n",
+    "    Group 0                          block.groups[0]\n",
+    "        AnalogSignal 0               block.groups[0].analogsignals[0]\n",
+    "        AnalogSignal 2               block.groups[0].analogsignals[1]\n",
+    "        SpikeTrain 0                 block.groups[0].spiketrains[0]\n",
+    "        SpikeTrain 3                 block.groups[0].spiketrains[1]\n",
+    "        \n",
     "```"
    ]
   },

+ 62 - 48
tutorial_2.ipynb

@@ -79,37 +79,19 @@
     }
    },
    "source": [
-    "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."
+    "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."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": null,
    "id": "10d61396",
    "metadata": {
     "slideshow": {
      "slide_type": "skip"
     }
    },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "--2021-09-29 15:24:49--  https://gin.g-node.org/NeuralEnsemble/neo_elephant_teaching/raw/master/reach_to_grasp_material/i140703-001.nix\n",
-      "Resolving gin.g-node.org (gin.g-node.org)... 141.84.41.219\n",
-      "Connecting to gin.g-node.org (gin.g-node.org)|141.84.41.219|:443... connected.\n",
-      "HTTP request sent, awaiting response... 200 OK\n",
-      "Length: 0 [text/plain]\n",
-      "Saving to: 'i140703-001.nix’\n",
-      "\n",
-      "i140703-001.nix         [ <=>                ]       0  --.-KB/s    in 0s      \n",
-      "\n",
-      "2021-09-29 15:24:49 (0,00 B/s) - 'i140703-001.nix’ saved [0/0]\n",
-      "\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "!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"
    ]
@@ -129,7 +111,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 1,
    "id": "a76ae878",
    "metadata": {
     "slideshow": {
@@ -160,7 +142,7 @@
        "      time: -0.00010000000000000026 s to 74.4549 s"
       ]
      },
-     "execution_count": 2,
+     "execution_count": 1,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -200,7 +182,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 2,
    "id": "02a207fc",
    "metadata": {
     "slideshow": {
@@ -227,7 +209,7 @@
        " 'noise': True}"
       ]
      },
-     "execution_count": 3,
+     "execution_count": 2,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -248,12 +230,12 @@
    "source": [
     "\n",
     "## Dataset overview - AnalogSignals\n",
-    "To learn more about the channels of the analogsignal, we print the array_annotations of the single analogsignal object:"
+    "To learn more about the channels of the analogsignal, we print the entries of the array_annotations of the single analogsignal object:"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 3,
    "id": "d5e4a903",
    "metadata": {
     "slideshow": {
@@ -267,7 +249,7 @@
        "dict_keys(['channel_names', 'channel_ids', 'file_origin', 'connector_ID', 'connector_pinID', 'nev_dig_factor', 'nb_sorted_units', 'nev_hi_freq_order', 'nev_hi_freq_type', 'nev_lo_freq_order', 'nev_lo_freq_type', 'nsx_hi_freq_order', 'nsx_lo_freq_order', 'nsx_hi_freq_type', 'nsx_lo_freq_type', 'description', 'nsx', 'hi_pass_freq', 'lo_pass_freq', 'hi_pass_order', 'lo_pass_order', 'filter_type', 'electrode_reject_HFC', 'electrode_reject_LFC', 'electrode_reject_IFC', 'connector_aligned_ids', 'coordinates_x', 'coordinates_y'])"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -281,7 +263,7 @@
    "id": "5111b21f",
    "metadata": {
     "slideshow": {
-     "slide_type": "fragment"
+     "slide_type": "skip"
     }
    },
    "source": [
@@ -306,7 +288,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 4,
    "id": "765fde73",
    "metadata": {
     "slideshow": {
@@ -357,7 +339,7 @@
    "id": "07d3277a",
    "metadata": {
     "slideshow": {
-     "slide_type": "fragment"
+     "slide_type": "skip"
     }
    },
    "source": [
@@ -378,7 +360,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "id": "27ce9e97",
    "metadata": {
     "slideshow": {
@@ -399,14 +381,24 @@
     }
    },
    "source": [
-    "### Masking Neo objects\n",
-    "\n",
+    "### Masking Neo objects"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "40cab7af",
+   "metadata": {
+    "slideshow": {
+     "slide_type": "skip"
+    }
+   },
+   "source": [
     "First we are selecting event times that are occurring during successful trials, marked by the `performance_in_trial_str` as `correct_trial`. In addition we also only want to select trial start (`TS-ON`) events. Based on the array annotations we are creating two masks and apply both to the original event to generate a new event object via slicing."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 6,
    "id": "fe323fd4",
    "metadata": {
     "slideshow": {
@@ -431,7 +423,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "id": "6096013b",
    "metadata": {
     "slideshow": {
@@ -453,14 +445,24 @@
    },
    "source": [
     "### Utility function: Epoch creation\n",
-    "In the next step we are making use of neo utility functions to generate epochs around the time points extracted.\n",
-    "\n",
+    "In the next step we are making use of neo utility functions to generate epochs around the time points extracted."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "f046bf8a",
+   "metadata": {
+    "slideshow": {
+     "slide_type": "skip"
+    }
+   },
+   "source": [
     "Construct analysis epochs from 10ms before the TS-ON of a successful behavioral trial to 15ms after TS-ON. The name \"analysis_epochs\" is given to the resulting Neo Epoch object. The object is not attached to the Neo Segment. The parameter event2 of add_epoch() is left empty, since we are cutting around a single event, as opposed to cutting between two events."
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "id": "192dd147",
    "metadata": {
     "slideshow": {
@@ -475,7 +477,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 9,
    "id": "daabfccf",
    "metadata": {
     "slideshow": {
@@ -499,7 +501,7 @@
    "id": "84ae63ef",
    "metadata": {
     "slideshow": {
-     "slide_type": "subslide"
+     "slide_type": "skip"
     }
    },
    "source": [
@@ -508,7 +510,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 10,
    "id": "adf48780",
    "metadata": {
     "slideshow": {
@@ -532,14 +534,26 @@
   },
   {
    "cell_type": "markdown",
-   "id": "ec0a7841",
+   "id": "36bfe04d",
    "metadata": {
     "slideshow": {
      "slide_type": "subslide"
     }
    },
    "source": [
-    "### Utility function: cutting segment by epochs\n",
+    "### Utility function: cutting segment by epochs"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "ec0a7841",
+   "metadata": {
+    "slideshow": {
+     "slide_type": "skip"
+    }
+   },
+   "source": [
+    "\n",
     "Now we use the previously defined epochs to cut the segment containing the complete dataset into subsets, where each new segment corresponds to the starting epoch of a successful trial. For capturing the newly generated segments, we create a new Neo block.\n",
     "\n",
     "Create new segments of data cut according to the analysis epochs of the 'analysis_epochs' Neo Epoch object. The time axes of all segments are aligned such that each segment starts at time 0 (parameter reset_times); annotations describing the analysis epoch are carried over to the segments. A new Neo Block named \"data_cut_to_analysis_epochs\" is created to capture all cut analysis epochs.\n"
@@ -547,7 +561,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 11,
    "id": "42d33b10",
    "metadata": {
     "slideshow": {
@@ -564,7 +578,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 12,
    "id": "f58bca34",
    "metadata": {
     "slideshow": {
@@ -578,7 +592,7 @@
        "11"
       ]
      },
-     "execution_count": 13,
+     "execution_count": 12,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -601,7 +615,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 13,
    "id": "8c34c004",
    "metadata": {
     "slideshow": {

File diff suppressed because it is too large
+ 40 - 40
tutorial_3.ipynb