{ "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', ']: Invalid element <{http://www.w3.org/1999/xsl/transform}stylesheet> inside 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 (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 }