|
@@ -1,212 +0,0 @@
|
|
|
-{
|
|
|
- "cells": [
|
|
|
- {
|
|
|
- "cell_type": "markdown",
|
|
|
- "id": "723581d7",
|
|
|
- "metadata": {},
|
|
|
- "source": [
|
|
|
- "# Conversion\n",
|
|
|
- "This Notebook converts the dataset for the unitary events tutorial from .h5 to.nix format"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 1,
|
|
|
- "id": "6c6d2774",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "import neo\n",
|
|
|
- "from neo.core import Block, Segment, Group, AnalogSignal\n",
|
|
|
- "import numpy as np\n",
|
|
|
- "import quantities as pq\n",
|
|
|
- "\n",
|
|
|
- "import random\n",
|
|
|
- "import string\n",
|
|
|
- "import matplotlib.pyplot as plt\n",
|
|
|
- "import elephant.unitary_event_analysis as ue\n",
|
|
|
- "# Fix random seed to guarantee fixed output\n",
|
|
|
- "random.seed(1224)"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "markdown",
|
|
|
- "id": "26914203",
|
|
|
- "metadata": {},
|
|
|
- "source": [
|
|
|
- "## Download data"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 2,
|
|
|
- "id": "8c798f2b",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "name": "stdout",
|
|
|
- "output_type": "stream",
|
|
|
- "text": [
|
|
|
- " % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
|
|
- " Dload Upload Total Spent Left Speed\n",
|
|
|
- "100 369 100 369 0 0 2795 0 --:--:-- --:--:-- --:--:-- 2795\n",
|
|
|
- "100 289k 0 289k 0 0 212k 0 --:--:-- 0:00:01 --:--:-- 2979k\n"
|
|
|
- ]
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "!curl https://web.gin.g-node.org/INM-6/elephant-data/raw/master/dataset-1/dataset-1.h5 --output dataset-1.h5 --location"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "markdown",
|
|
|
- "id": "903fc908",
|
|
|
- "metadata": {},
|
|
|
- "source": [
|
|
|
- "## Load Data"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 3,
|
|
|
- "id": "870b8b77",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "name": "stderr",
|
|
|
- "output_type": "stream",
|
|
|
- "text": [
|
|
|
- "/home/kern/miniconda3/envs/elephant_nixio/lib/python3.9/site-packages/neo/io/hdf5io.py:63: FutureWarning: NeoHdf5IO will be removed in the next release of Neo. If you still have data in this format, we recommend saving it using NixIO which is also based on HDF5.\n",
|
|
|
- " warn(warning_msg, FutureWarning)\n",
|
|
|
- "/home/kern/miniconda3/envs/elephant_nixio/lib/python3.9/site-packages/numpy/core/shape_base.py:121: 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",
|
|
|
- " ary = asanyarray(ary)\n"
|
|
|
- ]
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "block = neo.io.NeoHdf5IO(\"./dataset-1.h5\")\n",
|
|
|
- "sts1 = block.read_block().segments[0].spiketrains\n",
|
|
|
- "sts2 = block.read_block().segments[1].spiketrains\n",
|
|
|
- "spiketrains = np.vstack((sts1,sts2)).T"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 4,
|
|
|
- "id": "c52a2a89",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "# create empty block\n",
|
|
|
- "blk = Block()\n",
|
|
|
- "# add segments and spike trains\n",
|
|
|
- "for ind in range (len(sts1)):\n",
|
|
|
- " seg = Segment(name='segment %d' % ind, index=ind)\n",
|
|
|
- " seg.spiketrains.append(sts1[ind])\n",
|
|
|
- " seg.spiketrains.append(sts2[ind])\n",
|
|
|
- " blk.segments.append(seg)\n"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "markdown",
|
|
|
- "id": "28a2e17f",
|
|
|
- "metadata": {},
|
|
|
- "source": [
|
|
|
- "## Save as .nix"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 5,
|
|
|
- "id": "2a06477e",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "filename = 'dataset-1.nix'\n",
|
|
|
- "with neo.io.NixIO(filename, 'ow') as io:\n",
|
|
|
- " io.write_block(blk)"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 6,
|
|
|
- "id": "3502e50c-919e-49f8-b38c-629978d1d246",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "name": "stdout",
|
|
|
- "output_type": "stream",
|
|
|
- "text": [
|
|
|
- "total 2,0M\n",
|
|
|
- "-rw-rw-r-- 1 kern kern 4,6K Dez 13 17:25 conversion_hd5_to_nix.ipynb\n",
|
|
|
- "-rw-rw-r-- 1 kern kern 289K Dez 13 17:32 dataset-1.h5\n",
|
|
|
- "-rw-rw-r-- 1 kern kern 1,7M Dez 13 17:32 dataset-1.nix\n"
|
|
|
- ]
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "!ls -lh "
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 8,
|
|
|
- "id": "cda78e18-84e9-4a44-8e6f-9c0a1f26dd0c",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "name": "stdout",
|
|
|
- "output_type": "stream",
|
|
|
- "text": [
|
|
|
- "File dataset-1.nix is up to date (1.2.1)\n",
|
|
|
- "Processing dataset-1.nix done\n"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "text/plain": [
|
|
|
- "True"
|
|
|
- ]
|
|
|
- },
|
|
|
- "execution_count": 8,
|
|
|
- "metadata": {},
|
|
|
- "output_type": "execute_result"
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "filename = \"dataset-1.nix\"\n",
|
|
|
- "import nixio\n",
|
|
|
- "nixio.file_upgrade(filename, quiet=False)"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
- "id": "e297a693-1d89-4770-89c4-d49a1f9df86c",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": []
|
|
|
- }
|
|
|
- ],
|
|
|
- "metadata": {
|
|
|
- "kernelspec": {
|
|
|
- "display_name": "elephant_nixio",
|
|
|
- "language": "python",
|
|
|
- "name": "elephant_nixio"
|
|
|
- },
|
|
|
- "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
|
|
|
-}
|