asobolev преди 1 година
родител
ревизия
ea50921279

Файловите разлики са ограничени, защото са твърде много
+ 202 - 0
analysis/AEPs/LFP modulation by target.ipynb


+ 160 - 0
analysis/AEPs/hilbert.ipynb

@@ -0,0 +1,160 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "463b03ff",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import numpy as np\n",
+    "import os, h5py\n",
+    "import matplotlib.pyplot as plt\n",
+    "from sklearn import decomposition\n",
+    "\n",
+    "%matplotlib inline"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "b5a09f6a",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "6095"
+      ]
+     },
+     "execution_count": 2,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "source  = '/home/sobolev/nevermind/Andrey/data'\n",
+    "\n",
+    "session = '009266_hippoSIT_2023-04-26_08-20-17'  # sample session with some PPC units\n",
+    "#session = '009266_hippoSIT_2023-04-28_09-04-09'\n",
+    "#session = '009266_hippoSIT_2023-05-04_09-11-06'  # coma session with baseline AEPs\n",
+    "animal      = session.split('_')[0]\n",
+    "sessionpath = os.path.join(source, animal, session)\n",
+    "aeps_file = os.path.join(sessionpath, 'AEPs.h5')\n",
+    "\n",
+    "with h5py.File(aeps_file, 'r') as f:\n",
+    "    aeps = np.array(f['aeps'])\n",
+    "    aeps_events = np.array(f['aeps_events'])\n",
+    "    \n",
+    "t_N1 = 20  # all in ms\n",
+    "N1_l, N1_r = 15, 25\n",
+    "P1_l, P1_r = 30, 75\n",
+    "\n",
+    "len(aeps)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "cfc39b53",
+   "metadata": {},
+   "source": [
+    "## Phase / amplitude space"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "aaf72be2",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# do bandpass 3-15 and 50 - 80 and look at waveforms"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "a07f8909",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# if all good do hilbert and try to look at the phases"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "f6d93eea",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "a56eead9",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "markdown",
+   "id": "8f5c31df",
+   "metadata": {},
+   "source": [
+    "### Active listening - unit correlations"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "id": "95396069",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# putative active listening periods\n",
+    "idxs_active = np.where(i_rate > thresh)[0]\n",
+    "\n",
+    "def get_event_tl_idx(t_event):\n",
+    "    return (np.abs(tl[:, 0] - t_event)).argmin()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "id": "bb6e6749",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# filter tgt / bgr events\n",
+    "sound_events = events[(events[:, 1] == 1) | (events[:, 1] == 2)]\n",
+    "# get active / passive aeps\n",
+    "aeps_al_idxs = np.array([i for i, event in enumerate(sound_events) if get_event_tl_idx(event[0]) in idxs_active])\n",
+    "aeps_pl_idxs = np.array([i for i, event in enumerate(sound_events) if get_event_tl_idx(event[0]) not in idxs_active])\n",
+    "aeps_al = aeps[aeps_al_idxs]\n",
+    "aeps_pl = aeps[aeps_pl_idxs]"
+   ]
+  }
+ ],
+ "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.8.10"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

Файловите разлики са ограничени, защото са твърде много
+ 41 - 54
analysis/AEPs/pre-processing.ipynb


Файловите разлики са ограничени, защото са твърде много
+ 741 - 168
analysis/AEPs/visualizing.ipynb


Файловите разлики са ограничени, защото са твърде много
+ 26 - 35
analysis/CCR.ipynb


+ 2 - 2
analysis/active listening.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 1,
    "id": "563752fa",
    "metadata": {},
    "outputs": [],
@@ -16,7 +16,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 2,
    "id": "177b447f",
    "metadata": {},
    "outputs": [

Файловите разлики са ограничени, защото са твърде много
+ 21 - 12
analysis/state separation.ipynb


+ 14 - 41
postprocessing/execute.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": 6,
    "id": "c37dce82",
    "metadata": {
     "scrolled": true
@@ -39,7 +39,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 7,
    "id": "a8ea2991",
    "metadata": {},
    "outputs": [
@@ -75,7 +75,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 8,
    "id": "3891b792",
    "metadata": {},
    "outputs": [],
@@ -88,19 +88,19 @@
     "# test session\n",
     "#filebase = '008229_hippoSIT_2022-05-16_20-36-44'\n",
     "#filebase = '64_prSIT_2023-02-27_15-06-02'\n",
-    "filebase = '009266_hippoSIT_2023-04-26_08-20-17'\n",
-    "animal = filebase.split('_')[0]\n",
+    "#filebase = '009266_hippoSIT_2023-04-24_16-56-55'\n",
+    "#animal = filebase.split('_')[0]\n",
     "#sessionpath = os.path.join(source, animal, filebase)\n",
     "#h5name  = os.path.join(source, animal, filebase, filebase + '.h5')\n",
-    "sessionpath = os.path.join(source, filebase)\n",
-    "h5name  = os.path.join(source, filebase, filebase + '.h5')\n",
+    "#sessionpath = os.path.join(source, filebase)\n",
+    "#h5name  = os.path.join(source, filebase, filebase + '.h5')\n",
     "\n",
     "#sessions = get_sessions_list(os.path.join(source, animal), animal)\n",
     "#sessions = get_sessions_list(source, animal)\n",
     "#sessions = [filebase]\n",
     "#sessions = processed_008229\n",
     "sessions = [\n",
-    "'009266_hippoSIT_2023-04-26_08-20-17',\n",
+    "    '009266_hippoSIT_2023-04-24_16-56-55',\n",
     "]\n",
     "\n",
     "# FIXME move occupancy outside units\n",
@@ -117,7 +117,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 4,
    "id": "347fcf3d",
    "metadata": {},
    "outputs": [
@@ -126,48 +126,21 @@
       "text/plain": [
        "['009266_hippoSIT_2023-02-28_19-53-56',\n",
        " '009266_hippoSIT_2023-03-01_17-53-11',\n",
-       " '009266_hippoSIT_2023-03-06_15-10-36',\n",
-       " '009266_hippoSIT_2023-03-06_20-43-19',\n",
-       " '009266_hippoSIT_2023-03-08_17-06-45',\n",
-       " '009266_hippoSIT_2023-03-09_09-37-07',\n",
-       " '009266_hippoSIT_2023-03-09_19-12-22',\n",
-       " '009266_hippoSIT_2023-04-12_15-49-49',\n",
-       " '009266_hippoSIT_2023-04-13_08-57-46',\n",
-       " '009266_hippoSIT_2023-04-14_09-17-34',\n",
-       " '009266_hippoSIT_2023-04-17_09-06-10',\n",
-       " '009266_hippoSIT_2023-04-17_17-04-17',\n",
-       " '009266_hippoSIT_2023-04-18_10-10-37',\n",
-       " '009266_hippoSIT_2023-04-18_17-03-10',\n",
-       " '009266_hippoSIT_2023-04-19_10-33-51',\n",
-       " '009266_hippoSIT_2023-04-19_11-21-37',\n",
-       " '009266_hippoSIT_2023-04-19_17-12-48',\n",
-       " '009266_hippoSIT_2023-04-20_08-57-39',\n",
-       " '009266_hippoSIT_2023-04-20_15-24-14',\n",
-       " '009266_hippoSIT_2023-04-21_08-43-00',\n",
-       " '009266_hippoSIT_2023-04-21_13-12-31',\n",
-       " '009266_hippoSIT_2023-04-24_10-08-11',\n",
-       " '009266_hippoSIT_2023-04-24_16-56-55',\n",
-       " '009266_hippoSIT_2023-04-25_09-02-56',\n",
-       " '009266_hippoSIT_2023-04-25_17-27-51',\n",
-       " '009266_hippoSIT_2023-04-26_08-20-17',\n",
-       " '009266_hippoSIT_2023-04-27_08-50-53',\n",
-       " '009266_hippoSIT_2023-04-27_21-04-41',\n",
-       " '009266_hippoSIT_2023-04-28_09-04-09',\n",
-       " '009266_hippoSIT_2023-04-28_16-40-08']"
+       " '009266_hippoSIT_2023-03-06_15-10-36']"
       ]
      },
-     "execution_count": 7,
+     "execution_count": 4,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "get_sessions_list(os.path.join(source, animal), animal)"
+    "get_sessions_list(os.path.join(source, animal), animal)[:3]"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 9,
    "id": "24cd2f6e",
    "metadata": {},
    "outputs": [
@@ -175,7 +148,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "session 009266_hippoSIT_2023-04-26_08-20-17 done\n"
+      "session 009266_hippoSIT_2023-04-24_16-56-55 done\n"
      ]
     }
    ],

+ 1 - 1
postprocessing/spiketrain.py

@@ -3,7 +3,7 @@ from scipy.interpolate import interp1d
 import numpy as np
 
 
-def instantaneous_rate(spiketrain, time_bins, bin_size=10, k_width=100):
+def instantaneous_rate(spiketrain, time_bins, bin_size=10, k_width=70):
     """
     spiketrain - an array of spike times in seconds
     time_bins  - an array of times to have instantaneous rate for