|
@@ -0,0 +1,888 @@
|
|
|
+{
|
|
|
+ "cells": [
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "e60c7cd0",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "# Writing sample nix file for one session of spike sorted data for Monkey N"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "0643592d",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## Importing all the necessary libraries"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 1,
|
|
|
+ "id": "f3093b19",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "import urllib\n",
|
|
|
+ "\n",
|
|
|
+ "import numpy as np\n",
|
|
|
+ "import quantities as pq\n",
|
|
|
+ "from matplotlib import pyplot as plt\n",
|
|
|
+ "\n",
|
|
|
+ "import neo\n",
|
|
|
+ "import nixio as nix\n",
|
|
|
+ "import elephant\n",
|
|
|
+ "from utils.plotting import Plotter\n",
|
|
|
+ "from utils.notebook import print_stats, print_metadata_table\n",
|
|
|
+ "import datetime\n",
|
|
|
+ "import odml"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "dc84b92b",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## Reading and exploring the blackrock data from .nev file"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 2,
|
|
|
+ "id": "4fbd8fec",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#url_path = 'https://gin.g-node.org/INT/multielectrode_grasp/raw/master/datasets/i140703-001-03.nev'\n",
|
|
|
+ "#local_path = './i140703-001-03.nev'\n",
|
|
|
+ "#urllib.request.urlretrieve(url_path, local_path)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 3,
|
|
|
+ "id": "e54b698d",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stderr",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "BlackrockIO: i140703-001-03.nev\n",
|
|
|
+ "nb_block: 1\n",
|
|
|
+ "nb_segment: [1]\n",
|
|
|
+ "signal_channels: []\n",
|
|
|
+ "unit_channels: [ch1#0, ch1#1, ch1#2, ch2#0 ... ch95#2 ch95#3 ch96#0 ch96#1]\n",
|
|
|
+ "event_channels: [digital_input_port, serial_input_port, comments]\n",
|
|
|
+ "\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#create a reader\n",
|
|
|
+ "reader = neo.io.BlackrockIO(filename=\"i140703-001-03.nev\")\n",
|
|
|
+ "print(reader)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 4,
|
|
|
+ "id": "cbe77c63",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stderr",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "blks = reader.read(lazy=False)[0]\n",
|
|
|
+ "#Initializing an array to store all the spikestrains in each segment\n",
|
|
|
+ "train_array = []\n",
|
|
|
+ "for seg in blks.segments:\n",
|
|
|
+ " #Extracting only the magnitde of the spike train\n",
|
|
|
+ " train = [st.rescale('s').magnitude for st in seg.spiketrains]\n",
|
|
|
+ " #Stacking all the spiketrains,such that,each index would give st corresponding to each unit channel\n",
|
|
|
+ " train_array = np.hstack((train_array,train))"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 5,
|
|
|
+ "id": "a71fad6a",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "nb_block 1\n",
|
|
|
+ "nb_segment [1]\n",
|
|
|
+ "signal_channels []\n",
|
|
|
+ "unit_channels [('ch1#0', 'Unit 1000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch1#1', 'Unit 1001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch1#2', 'Unit 1002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch2#0', 'Unit 2000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch2#1', 'Unit 2001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch2#2', 'Unit 2002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch3#0', 'Unit 3000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch3#1', 'Unit 3001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch3#2', 'Unit 3002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch4#0', 'Unit 4000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch4#1', 'Unit 4001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch4#2', 'Unit 4002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch5#0', 'Unit 5000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch5#1', 'Unit 5001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch6#0', 'Unit 6000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch6#1', 'Unit 6001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch6#2', 'Unit 6002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch7#0', 'Unit 7000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch7#1', 'Unit 7001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch7#2', 'Unit 7002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch7#3', 'Unit 7003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch8#0', 'Unit 8000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch8#1', 'Unit 8001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch8#2', 'Unit 8002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch8#3', 'Unit 8003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch8#4', 'Unit 8004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch9#0', 'Unit 9000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch9#1', 'Unit 9001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch9#2', 'Unit 9002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch10#0', 'Unit 10000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch10#1', 'Unit 10001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch11#0', 'Unit 11000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch11#1', 'Unit 11001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch11#2', 'Unit 11002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch11#3', 'Unit 11003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch12#0', 'Unit 12000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch12#1', 'Unit 12001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch13#0', 'Unit 13000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch13#1', 'Unit 13001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch13#2', 'Unit 13002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch14#0', 'Unit 14000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch14#1', 'Unit 14001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch14#2', 'Unit 14002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch14#3', 'Unit 14003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch15#0', 'Unit 15000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch15#1', 'Unit 15001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch16#0', 'Unit 16000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch16#1', 'Unit 16001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch16#2', 'Unit 16002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch17#0', 'Unit 17000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch18#0', 'Unit 18000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch18#1', 'Unit 18001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch18#2', 'Unit 18002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch18#3', 'Unit 18003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch18#4', 'Unit 18004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch19#0', 'Unit 19000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch20#0', 'Unit 20000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch20#1', 'Unit 20001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch21#0', 'Unit 21000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch21#1', 'Unit 21001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch21#2', 'Unit 21002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch22#0', 'Unit 22000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch22#1', 'Unit 22001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch22#2', 'Unit 22002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch22#3', 'Unit 22003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch23#0', 'Unit 23000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch23#1', 'Unit 23001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch24#0', 'Unit 24000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch24#1', 'Unit 24001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch24#2', 'Unit 24002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch25#0', 'Unit 25000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch25#1', 'Unit 25001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch26#0', 'Unit 26000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch26#1', 'Unit 26001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch26#2', 'Unit 26002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch26#3', 'Unit 26003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch27#0', 'Unit 27000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch27#1', 'Unit 27001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch27#2', 'Unit 27002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch27#3', 'Unit 27003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch28#0', 'Unit 28000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch28#1', 'Unit 28001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch28#2', 'Unit 28002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch29#0', 'Unit 29000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch29#1', 'Unit 29001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch30#0', 'Unit 30000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch30#1', 'Unit 30001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch30#2', 'Unit 30002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch30#3', 'Unit 30003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch30#4', 'Unit 30004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch31#0', 'Unit 31000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch31#1', 'Unit 31001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch32#0', 'Unit 32000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch32#1', 'Unit 32001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch32#2', 'Unit 32002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch32#3', 'Unit 32003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch33#0', 'Unit 33000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch33#1', 'Unit 33001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch33#2', 'Unit 33002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch33#3', 'Unit 33003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch33#4', 'Unit 33004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch34#0', 'Unit 34000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch34#1', 'Unit 34001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch35#0', 'Unit 35000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch35#1', 'Unit 35001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch36#0', 'Unit 36000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch36#1', 'Unit 36001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch36#2', 'Unit 36002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch37#0', 'Unit 37000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch38#0', 'Unit 38000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch38#1', 'Unit 38001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch38#2', 'Unit 38002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch39#0', 'Unit 39000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch40#0', 'Unit 40000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch40#1', 'Unit 40001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch40#2', 'Unit 40002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch40#3', 'Unit 40003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch41#0', 'Unit 41000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch41#1', 'Unit 41001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch42#0', 'Unit 42000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch42#1', 'Unit 42001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch42#2', 'Unit 42002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch43#0', 'Unit 43000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch43#1', 'Unit 43001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch43#2', 'Unit 43002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch44#0', 'Unit 44000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch44#1', 'Unit 44001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch45#0', 'Unit 45000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch46#0', 'Unit 46000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch46#1', 'Unit 46001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch47#0', 'Unit 47000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch47#1', 'Unit 47001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch48#0', 'Unit 48000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch48#1', 'Unit 48001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch48#2', 'Unit 48002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch48#3', 'Unit 48003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch49#0', 'Unit 49000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch49#1', 'Unit 49001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch50#0', 'Unit 50000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch50#1', 'Unit 50001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch50#2', 'Unit 50002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch51#0', 'Unit 51000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch51#1', 'Unit 51001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch52#0', 'Unit 52000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch52#1', 'Unit 52001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch52#2', 'Unit 52002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch52#3', 'Unit 52003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch53#0', 'Unit 53000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch53#1', 'Unit 53001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch54#0', 'Unit 54000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch55#0', 'Unit 55000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch55#1', 'Unit 55001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch55#2', 'Unit 55002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch56#0', 'Unit 56000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch56#1', 'Unit 56001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch56#2', 'Unit 56002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch57#0', 'Unit 57000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch57#1', 'Unit 57001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch58#0', 'Unit 58000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch58#1', 'Unit 58001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch58#2', 'Unit 58002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch59#0', 'Unit 59000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch59#1', 'Unit 59001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch59#2', 'Unit 59002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch60#0', 'Unit 60000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch60#1', 'Unit 60001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch60#2', 'Unit 60002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch61#0', 'Unit 61000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch61#1', 'Unit 61001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch61#2', 'Unit 61002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch62#0', 'Unit 62000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch62#1', 'Unit 62001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch62#2', 'Unit 62002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch62#3', 'Unit 62003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch62#4', 'Unit 62004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch63#0', 'Unit 63000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch63#1', 'Unit 63001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch63#2', 'Unit 63002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch63#3', 'Unit 63003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch64#0', 'Unit 64000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch64#1', 'Unit 64001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch64#2', 'Unit 64002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch65#0', 'Unit 65000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch65#1', 'Unit 65001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch65#2', 'Unit 65002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch66#0', 'Unit 66000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch66#1', 'Unit 66001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch66#2', 'Unit 66002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch67#0', 'Unit 67000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch67#1', 'Unit 67001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch68#0', 'Unit 68000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch68#1', 'Unit 68001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch68#2', 'Unit 68002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch69#0', 'Unit 69000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch69#1', 'Unit 69001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch69#2', 'Unit 69002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch70#0', 'Unit 70000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch71#0', 'Unit 71000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch71#1', 'Unit 71001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch71#2', 'Unit 71002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch72#0', 'Unit 72000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch72#1', 'Unit 72001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch73#0', 'Unit 73000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch73#1', 'Unit 73001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch73#2', 'Unit 73002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch74#0', 'Unit 74000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch74#1', 'Unit 74001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch74#2', 'Unit 74002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch75#0', 'Unit 75000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch75#1', 'Unit 75001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch75#2', 'Unit 75002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch76#0', 'Unit 76000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch76#1', 'Unit 76001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch77#0', 'Unit 77000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch77#1', 'Unit 77001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch77#2', 'Unit 77002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch78#0', 'Unit 78000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch78#1', 'Unit 78001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch78#2', 'Unit 78002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch79#0', 'Unit 79000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch79#1', 'Unit 79001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch79#2', 'Unit 79002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch79#3', 'Unit 79003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch79#4', 'Unit 79004', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch80#0', 'Unit 80000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch80#1', 'Unit 80001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch80#2', 'Unit 80002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch81#0', 'Unit 81000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch81#1', 'Unit 81001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch81#2', 'Unit 81002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch82#0', 'Unit 82000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch82#1', 'Unit 82001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch83#0', 'Unit 83000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch83#1', 'Unit 83001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch83#2', 'Unit 83002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch84#0', 'Unit 84000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch84#1', 'Unit 84001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch85#0', 'Unit 85000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch85#1', 'Unit 85001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch85#2', 'Unit 85002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch86#0', 'Unit 86000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch86#1', 'Unit 86001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch86#2', 'Unit 86002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch86#3', 'Unit 86003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch87#0', 'Unit 87000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch87#1', 'Unit 87001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch88#0', 'Unit 88000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch88#1', 'Unit 88001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch89#0', 'Unit 89000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch89#1', 'Unit 89001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch90#0', 'Unit 90000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch90#1', 'Unit 90001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch91#0', 'Unit 91000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch91#1', 'Unit 91001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch91#2', 'Unit 91002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch91#3', 'Unit 91003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch92#0', 'Unit 92000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch92#1', 'Unit 92001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch92#2', 'Unit 92002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch93#0', 'Unit 93000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch93#1', 'Unit 93001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch93#2', 'Unit 93002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch94#0', 'Unit 94000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch94#1', 'Unit 94001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch94#2', 'Unit 94002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch95#0', 'Unit 95000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch95#1', 'Unit 95001', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch95#2', 'Unit 95002', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch95#3', 'Unit 95003', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch96#0', 'Unit 96000', 'uV', 0.25, 0., 10, 30000.)\n",
|
|
|
+ " ('ch96#1', 'Unit 96001', 'uV', 0.25, 0., 10, 30000.)]\n",
|
|
|
+ "event_channels [('digital_input_port', '', b'event') ('serial_input_port', '', b'event')\n",
|
|
|
+ " ('comments', '', b'event')]\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Printing out entire reader dictionary to understand the structure of the file\n",
|
|
|
+ "for key_var , value_var in reader.header.items():\n",
|
|
|
+ " print(key_var,value_var)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 6,
|
|
|
+ "id": "4c88a1d8",
|
|
|
+ "metadata": {
|
|
|
+ "scrolled": true
|
|
|
+ },
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "[('name', '<U64'), ('id', '<U64'), ('wf_units', '<U64'), ('wf_gain', '<f8'), ('wf_offset', '<f8'), ('wf_left_sweep', '<i8'), ('wf_sampling_rate', '<f8')]\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Extracting the values for key of unit channels and printing the data types\n",
|
|
|
+ "unit_channel_des = reader.header['unit_channels']\n",
|
|
|
+ "print(unit_channel_des.dtype)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 7,
|
|
|
+ "id": "9c169484",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Defining a function to extact fields corresponding to the field name from a ndarray\n",
|
|
|
+ "def fields_view(arr, fields):\n",
|
|
|
+ " dtype2 = np.dtype({name:arr.dtype.fields[name] for name in fields})\n",
|
|
|
+ " return np.ndarray(arr.shape, dtype2, arr, 0, arr.strides)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 8,
|
|
|
+ "id": "e0e52464",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Extracting all the fields of unit channel key using fields_view() function\n",
|
|
|
+ "channel_name = fields_view(unit_channel_des, [\"name\"])\n",
|
|
|
+ "channel_id = fields_view(unit_channel_des, [\"id\"])\n",
|
|
|
+ "channel_wf_units = fields_view(unit_channel_des, [\"wf_units\"])\n",
|
|
|
+ "channel_wf_gain = fields_view(unit_channel_des, [\"wf_gain\"])\n",
|
|
|
+ "channel_wf_offset = fields_view(unit_channel_des, [\"wf_offset\"])\n",
|
|
|
+ "channel_wf_left_sweep = fields_view(unit_channel_des, [\"wf_left_sweep\"])\n",
|
|
|
+ "channel_wf_sampling_rate = fields_view(unit_channel_des, [\"wf_sampling_rate\"])"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "7e7c6a76",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## Creating a nix file and adding some Data available"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 9,
|
|
|
+ "id": "a3c93b2d",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Opening a nix file\n",
|
|
|
+ "nixfile = nix.File.open(\"test_nix.h5\", nix.FileMode.Overwrite)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 10,
|
|
|
+ "id": "d586a6a8",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Creating blocks corresponding to each key of the reader dictionary of .nev file\n",
|
|
|
+ "block = nixfile.create_block(\"nb_block\", \"nix.block\")\n",
|
|
|
+ "block_seg = nixfile.create_block(\"nb_segment\",\"nix.segment\")\n",
|
|
|
+ "block_sig = nixfile.create_block(\"signal_channels\", \"nix.signal_channels\")\n",
|
|
|
+ "block_unit = nixfile.create_block(\"unit_channels\", \"nix.unit_channels\")\n",
|
|
|
+ "block_event = nixfile.create_block(\"event_channels\", \"nix.event_channels\")"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 11,
|
|
|
+ "id": "9997df53",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "Total number of units : 271\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Counting and printing the total number of unit channels\n",
|
|
|
+ "total_units = reader.unit_channels_count()\n",
|
|
|
+ "print(\"Total number of units :\",total_units)\n",
|
|
|
+ "\n",
|
|
|
+ "#Iterating over each channel,to populate the unit_channels block with available information\n",
|
|
|
+ "for unit_index in range(total_units):\n",
|
|
|
+ " \n",
|
|
|
+ " channel_name_str = str((channel_id[unit_index])[0])\n",
|
|
|
+ " data = block_unit.create_data_array(channel_name_str,\"session.unit_channel\",data=[])\n",
|
|
|
+ " \n",
|
|
|
+ " data.wf_units = str((channel_wf_units[unit_index])[0])\n",
|
|
|
+ " data.wf_gain = str((channel_wf_gain[unit_index])[0])\n",
|
|
|
+ " data.wf_offset = str((channel_wf_offset[unit_index])[0])\n",
|
|
|
+ " data.wf_left_sweep = str((channel_wf_left_sweep[unit_index])[0])\n",
|
|
|
+ " data.wf_sampling_rate = str((channel_wf_sampling_rate[unit_index])[0]) \n",
|
|
|
+ " \n",
|
|
|
+ " "
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 12,
|
|
|
+ "id": "090a0dea",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "\n",
|
|
|
+ "Blocks (05)\n",
|
|
|
+ "\ttype: nix.block (01)\n",
|
|
|
+ "\ttype: nix.unit_channels (01)\n",
|
|
|
+ "\ttype: nix.signal_channels (01)\n",
|
|
|
+ "\ttype: nix.segment (01)\n",
|
|
|
+ "\ttype: nix.event_channels (01)\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Printing all the blocks types and how many are there of each type\n",
|
|
|
+ "print_stats(nixfile.blocks)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 13,
|
|
|
+ "id": "e166cef6",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "\n",
|
|
|
+ "DataArrays (271)\n",
|
|
|
+ "\ttype: session.unit_channel (271)\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Printing the type and number of data array if available in each block\n",
|
|
|
+ "print_stats(block.data_arrays)\n",
|
|
|
+ "print_stats(block_seg.data_arrays)\n",
|
|
|
+ "print_stats(block_sig.data_arrays)\n",
|
|
|
+ "print_stats(block_unit.data_arrays)\n",
|
|
|
+ "print_stats(block_event.data_arrays)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 14,
|
|
|
+ "id": "cd41c8ed",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Iterating over each channel,to populate the segment block with spike train data\n",
|
|
|
+ "for unit_index in range(total_units):\n",
|
|
|
+ " channel_name_str = str((channel_id[unit_index])[0])\n",
|
|
|
+ " data = block_seg.create_data_array(channel_name_str,\"segment.spike_train\",data=train_array[unit_index])\n",
|
|
|
+ " data.label = \"Spike_Train\"\n",
|
|
|
+ " data.unit = 's'"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "markdown",
|
|
|
+ "id": "d0957d9a",
|
|
|
+ "metadata": {},
|
|
|
+ "source": [
|
|
|
+ "## Adding some metadata to the nix file"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 15,
|
|
|
+ "id": "ef411489",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/plain": [
|
|
|
+ "{'avail_file_set': ['nev'],\n",
|
|
|
+ " 'avail_nsx': [],\n",
|
|
|
+ " 'avail_nev': True,\n",
|
|
|
+ " 'rec_pauses': False,\n",
|
|
|
+ " 'file_datetime': None,\n",
|
|
|
+ " 'rec_datetime': datetime.datetime(2014, 7, 3, 10, 40, 59, 288),\n",
|
|
|
+ " 'index': None,\n",
|
|
|
+ " 'name': 'Blackrock Data Block',\n",
|
|
|
+ " 'description': 'Block of data from Blackrock file set.',\n",
|
|
|
+ " 'file_origin': 'i140703-001-03.nev'}"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "execution_count": 15,
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "execute_result"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Extracting some metadata in the form of attributes using elephant\n",
|
|
|
+ "elephant.neo_tools.extract_neo_attributes(blks)"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 16,
|
|
|
+ "id": "ae77ae2f",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Adding the metadata associated with the nb_block\n",
|
|
|
+ "attribute_data = nixfile.create_section(\"nb_block\", \"nix.block\")\n",
|
|
|
+ "attribute_data[\"Available_File_Set\"] = \".nev\"\n",
|
|
|
+ "attribute_data[\"Recording_Date_Time\"] = str(datetime.datetime(2014, 7, 3, 10, 40, 59, 288))\n",
|
|
|
+ "attribute_data[\"Name\"] = \"Blackrock Data Block\"\n",
|
|
|
+ "attribute_data[\"Description\"] = \"Block of data from Blackrock file set.\"\n",
|
|
|
+ "attribute_data[\"File_Origin\"] = \"i140703-001-03.nev\"\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 17,
|
|
|
+ "id": "65b1a1c9",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stderr",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "warning[None:17:<{http://www.w3.org/1999/xsl/transform}stylesheet>]: Invalid element <{http://www.w3.org/1999/xsl/transform}stylesheet> inside <odML> tag\n",
|
|
|
+ " (line 17)\n",
|
|
|
+ "warning[None:17:<{http://www.w3.org/1999/xsl/transform}stylesheet>]: Invalid element <{http://www.w3.org/1999/xsl/transform}stylesheet> in odML document section <odML> (line 17)\n",
|
|
|
+ "UserWarning: The loaded Document contains unresolved issues. Run the Documents 'validate' method to access them.\n",
|
|
|
+ "Validation found 0 errors and 3 warnings in 0 Sections and 3 Properties.\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Loading the associated odml file for the session\n",
|
|
|
+ "odml_load = odml.load(\"i140703-001.odml\")"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 18,
|
|
|
+ "id": "14476550",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "text/plain": [
|
|
|
+ "Document 0.1 {author = Lyuba Zehl, 8 sections}"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "execution_count": 18,
|
|
|
+ "metadata": {},
|
|
|
+ "output_type": "execute_result"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "odml_load"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 19,
|
|
|
+ "id": "0575dfa4",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [
|
|
|
+ {
|
|
|
+ "name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
+ "text": [
|
|
|
+ "[Lyuba Zehl [0.1] 2017-07-14, sections: 8, repository: None]\n",
|
|
|
+ " Setup [setup]\n",
|
|
|
+ " |- Location: ['Inst. de Neurosciences de la Timone (I ... Aix Marseille Univ., Marseille, France']\n",
|
|
|
+ " |- DAQSystem: ['Cerebus']\n",
|
|
|
+ " Apparatus [setup]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " Subject [subject]\n",
|
|
|
+ " |- Species: ['Macaca mulatta']\n",
|
|
|
+ " |- TrivialName: ['Rhesus monkey']\n",
|
|
|
+ " |- GivenName: ['monkey_N']\n",
|
|
|
+ " |- Identifier: ['i']\n",
|
|
|
+ " |- Gender: ['male']\n",
|
|
|
+ " |- Birthday: [datetime.date(2008, 5, 17)]\n",
|
|
|
+ " |- ActiveHand: ['left']\n",
|
|
|
+ " |- Disabilities: ['-']\n",
|
|
|
+ " |- Character: ['Calm, but overall not really motivated. Less attentive.']\n",
|
|
|
+ " Training [subject/preparation]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " ArrayImplant [subject/preparation]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " Project [project]\n",
|
|
|
+ " |- Name: ['reach-to-grasp']\n",
|
|
|
+ " |- Type: ['electrophysiology']\n",
|
|
|
+ " |- Subtype: ['motor behavior']\n",
|
|
|
+ " |- Collaborators: ['Inst. of Neuroscience and Medicine (INM- ... Marseille Univ.', ' Marseille', ' France']\n",
|
|
|
+ " TaskDesigns [project]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " ConditionCodes [codes]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " DigitalEventLabelCodes [codes]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " TrialSequenceEvents [codes]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " PerformanceCodes [codes]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " TrialSettings [setup/control]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " TargetObjectSettings [setup/control]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " Cerebus [setup/daq]\n",
|
|
|
+ " |- Owner: ['RIKEN-BSI, Japan']\n",
|
|
|
+ " |- Manufacturer: ['Blackrock Microsystems']\n",
|
|
|
+ " NeuralSignalProcessor [setup/daq/hardware]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " NeuralSignalAmplifier [setup/daq/hardware]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " ControlComputer [setup/daq/software]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " UtahArray [setup/daq/hardware]\n",
|
|
|
+ " |- Owner: ['RIKEN-BSI, Japan']\n",
|
|
|
+ " |- SerialNo: ['8596-001139']\n",
|
|
|
+ " |- Manufacturer: ['Blackrock Microsystems']\n",
|
|
|
+ " |- WiresMaterial: ['Pt/Au']\n",
|
|
|
+ " |- WiresDiameter: [25.0]um\n",
|
|
|
+ " |- WiresLength: [40.0]mm\n",
|
|
|
+ " Connector [setup/daq/hardware]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " Array [setup/daq/hardware]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " Headstage [setup/daq/hardware]\n",
|
|
|
+ " |- Model: ['PatientCable']\n",
|
|
|
+ " |- Type: ['analog']\n",
|
|
|
+ " |- Gain: [1]\n",
|
|
|
+ " |- InFrom: ['UtahArray']\n",
|
|
|
+ " |- OutTo: ['NeuralSignalAmplifier']\n",
|
|
|
+ " |- StimSwitch: [True]\n",
|
|
|
+ " Recording [recording]\n",
|
|
|
+ " |- RecordingDay: ['i140703']\n",
|
|
|
+ " |- Recording: ['i140703-001']\n",
|
|
|
+ " |- Date: [datetime.date(2014, 7, 3)]\n",
|
|
|
+ " |- Weekday: ['Thursday']\n",
|
|
|
+ " |- Time: [datetime.time(10, 40, 59)]\n",
|
|
|
+ " |- Duration: [1003]s\n",
|
|
|
+ " |- IsSpikeSorted: [True]\n",
|
|
|
+ " |- TaskType: ['TwoCues']\n",
|
|
|
+ " |- Noisy: [True]\n",
|
|
|
+ " |- Comment: ['-']\n",
|
|
|
+ " TaskSettings [recording/task]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " PreProcessing [preprocessing]\n",
|
|
|
+ " |- LFPBands: ['HFC', 'LFC', 'IFC']\n",
|
|
|
+ " HFC [subject/preparation]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " LFC [subject/preparation]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " IFC [subject/preparation]\n",
|
|
|
+ " [...]\n",
|
|
|
+ " OfflineSpikeSorting [subject/preparation]\n",
|
|
|
+ " [...]\n"
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "source": [
|
|
|
+ "#Printing all the the sections and properties from the odml file using pprint\n",
|
|
|
+ "odml_load.pprint()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 20,
|
|
|
+ "id": "ea0fee31",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Adding some metadata manually and associating it with the nb_segment block\n",
|
|
|
+ "Recording_metadata = nixfile.create_section(\"nb_segment\",\"nix.segment\")\n",
|
|
|
+ "Recording_metadata[\"RecordingDay\"] = \"i140703\"\n",
|
|
|
+ "Recording_metadata[\"Recording\"] = \"i140703-001\"\n",
|
|
|
+ "Recording_metadata[\"Date\"] = str(datetime.date(2014, 7, 3))\n",
|
|
|
+ "Recording_metadata[\"Weekday\"] = \"Thursday\"\n",
|
|
|
+ "Recording_metadata[\"Duration\"] = \"1003_seconds\"\n",
|
|
|
+ "Recording_metadata[\"IsSpikeSorted\"] = \"True\"\n",
|
|
|
+ "Recording_metadata[\"TaskType\"] = \"TwoCues\"\n"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 21,
|
|
|
+ "id": "36f84601",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Adding source for the data in the segment block\n",
|
|
|
+ "source = block_seg.create_source(\"monkey_N\", \"nix.experimental_subject\")"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 22,
|
|
|
+ "id": "7331b978",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "#Adding some subject metadata\n",
|
|
|
+ "subject = Recording_metadata.create_section(\"monkey_N\", \"nix.experimental_subject\")\n",
|
|
|
+ "subject[\"Species\"] = \"Macaca mulatta\"\n",
|
|
|
+ "subject[\"TrivialName\"] = \"Rhesus monkey\"\n",
|
|
|
+ "subject[\"Identifier\"] = 'i'"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": 23,
|
|
|
+ "id": "6d32cc3b",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": [
|
|
|
+ "nixfile.close()"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "cell_type": "code",
|
|
|
+ "execution_count": null,
|
|
|
+ "id": "5e5deba5",
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
+ "source": []
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "metadata": {
|
|
|
+ "kernelspec": {
|
|
|
+ "display_name": "Python 3",
|
|
|
+ "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.5"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "nbformat": 4,
|
|
|
+ "nbformat_minor": 5
|
|
|
+}
|