{ "cells": [ { "cell_type": "markdown", "id": "a20f7712", "metadata": {}, "source": [ "# Hands-on session 1: Neo basics\n", "\n", "These exercises cover the basics introduced in Tutorial 1\n", "\n", "## [Only required on MYBINDER] Preparation: Download public ephys dataset\n", "On Linux you can download the publicly available dataset via the command below. On other systems, please download the files manually from [l101210-001.ns2](https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.ns2), [l101210-001.nev](https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.nev) and [l101210-001.ns5](https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.ns5) and save them in the same folder as this notebook.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "f914945d", "metadata": {}, "outputs": [], "source": [ "!wget -O reach_to_grasp_material/l101210-001.ns2 https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.ns2\n", "!wget -O reach_to_grasp_material/l101210-001.nev https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.nev\n", "!wget -O reach_to_grasp_material/l101210-001.ns5 https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/blackrock/blackrock_2_1/l101210-001.ns5" ] }, { "cell_type": "markdown", "id": "95c26202", "metadata": {}, "source": [ "\n", "## Exercise 1: Exploring an ephys dataset\n", "\n", "1. Load the dataset you just downloaded with Neo. Which IO seems suitable for this dataset?\n", "2. How many continuous recording parts (segments) does this dataset contain?\n", "3. How many channels were recorded in this dataset and at what sampling rates?\n", "4. How many spiketrains does this dataset contain?\n", "\n", "### Your solution" ] }, { "cell_type": "code", "execution_count": null, "id": "4fa3decf", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "31ba447a", "metadata": {}, "source": [ "## Exercise 2: Extracting data for visualization\n", "1. Visualize the channels 10 to 19 of the `AnalogSignal` with the highest temporal resolution. \n", "2. Add axis labels, title and legend based on metadata provided by the `AnalogSignal`. Check the `array_annotations` to label each channel.\n", "\n", "### Your solution" ] }, { "cell_type": "code", "execution_count": null, "id": "feceba8f", "metadata": {}, "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", "metadata": {}, "source": [ "## Exercise 3: Saving the dataset using NIX\n", "- Save the complete dataset in a new file named `l101210-001.nix`\n", "- What is the size of the resulting nix file?\n", "\n", "### Your solution" ] }, { "cell_type": "code", "execution_count": null, "id": "cc5336bb", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "81aa0351", "metadata": {}, "source": [ "## Bonus Exercise\n", "Did you bring your own data? Check if your format is supported by Neo and load your data!" ] } ], "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 }