Browse Source

some updates

asobolev 1 year ago
parent
commit
edfcf641b6
4 changed files with 565592 additions and 12778 deletions
  1. 40 30
      analysis/CCR.ipynb
  2. 28 141
      analysis/timeline.ipynb
  3. 169 9
      postprocessing/manual.ipynb
  4. 565355 12598
      sorting/ss-neurosuite.ipynb

File diff suppressed because it is too large
+ 40 - 30
analysis/CCR.ipynb


File diff suppressed because it is too large
+ 28 - 141
analysis/timeline.ipynb


+ 169 - 9
postprocessing/manual.ipynb

@@ -22,14 +22,6 @@
     "from session.utils import get_sessions_list, get_sampling_rate, cleaned_epochs"
    ]
   },
-  {
-   "cell_type": "markdown",
-   "id": "1a84fad3",
-   "metadata": {},
-   "source": [
-    "## Manually patching JSON files"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": 2,
@@ -41,6 +33,14 @@
     "animal = '009265'"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "1a84fad3",
+   "metadata": {},
+   "source": [
+    "## Manually patching JSON files"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": 23,
@@ -63,6 +63,144 @@
     "        json.dump(cfg, f, ensure_ascii=False, indent=4)"
    ]
   },
+  {
+   "cell_type": "markdown",
+   "id": "432ced32",
+   "metadata": {},
+   "source": [
+    "## Clean up"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 29,
+   "id": "d450f34a",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Removed 467 files\n"
+     ]
+    }
+   ],
+   "source": [
+    "to_clean = ['fil', 'lfp', 'clu', 'fet', 'klg', 'res', 'spk', 'nrs', 'xml']\n",
+    "\n",
+    "count = 0\n",
+    "sessions = [x for x in os.listdir(os.path.join(source, animal)) if os.path.isdir(os.path.join(source, animal, x))]\n",
+    "for session_name in sessions:\n",
+    "    for file_name in os.listdir(os.path.join(source, animal, session_name)):\n",
+    "        for key in to_clean:\n",
+    "            if file_name.find('.' + key) > 0:\n",
+    "                os.remove(os.path.join(source, animal, session_name, file_name))\n",
+    "                count += 1\n",
+    "                \n",
+    "print('Removed %s files' % count)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "id": "33c577a8",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'foo'"
+      ]
+     },
+     "execution_count": 30,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "def is_wrong(file_name):\n",
+    "    keys = ['clu', 'fet', 'klg', 'res', 'spk', 'nrs', 'xml']\n",
+    "    for key in keys:\n",
+    "        if file_name.find('.' + key) > 0:\n",
+    "            return True\n",
+    "    return False\n",
+    "\n",
+    "from functools import reduce\n",
+    "sessions = [x for x in os.listdir(os.path.join(source, animal)) if os.path.isdir(os.path.join(source, animal, x))]\n",
+    "files_all = reduce(lambda x, y: x + y, [os.listdir(os.path.join(source, animal, session)) for session in sessions])\n",
+    "'foo'"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "99c7733e",
+   "metadata": {},
+   "source": [
+    "## Put correct .XML"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "id": "4389e7dd",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import shutil\n",
+    "\n",
+    "sessions = [x for x in os.listdir(os.path.join(source, animal)) if os.path.isdir(os.path.join(source, animal, x))]\n",
+    "\n",
+    "for session_name in sessions:\n",
+    "    for file_name in os.listdir(os.path.join(source, animal, session_name)):\n",
+    "        if file_name.find('.dat') > 0:\n",
+    "            src = os.path.join(source, animal, 'default.xml')\n",
+    "            dst = os.path.join(source, animal, session_name, session_name + '.xml')\n",
+    "            shutil.copyfile(src, dst)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "id": "46229f4d",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['009265_hippoSIT_2023-02-24_09-53-26',\n",
+       " '009265_hippoSIT_2023-02-24_09-42-44',\n",
+       " '009265_hippoSIT_2023-02-23_15-24-36',\n",
+       " '009265_hippoSIT_2023-02-23_09-08-17',\n",
+       " '009265_hippoSIT_2023-02-22_15-22-30',\n",
+       " '009265_hippoSIT_2023-02-22_08-50-47',\n",
+       " '009265_hippoSIT_2023-02-21_20-44-17',\n",
+       " '009265_hippoSIT_2023-02-24_17-22-46',\n",
+       " '009265_hippoSIT_2023-02-27_10-18-32',\n",
+       " '009265_hippoSIT_2023-02-27_15-33-46',\n",
+       " '009265_hippoSIT_2023-02-28_09-16-50',\n",
+       " '009265_hippoSIT_2023-02-28_13-16-10',\n",
+       " '009265_hippoSIT_2023-02-28_20-45-04',\n",
+       " '009265_hippoSIT_2023-03-01_10-46-12',\n",
+       " '009265_hippoSIT_2023-03-02_09-32-54',\n",
+       " '009265_hippoSIT_2023-03-02_16-27-42',\n",
+       " '009265_hippoSIT_2023-03-02_20-11-35',\n",
+       " '009265_hippoSIT_2023-03-03_09-37-07',\n",
+       " '009265_hippoSIT_2023-03-03_16-00-47',\n",
+       " '009265_hippoSIT_2023-03-04_11-12-04',\n",
+       " '009265_hippoSIT_2023-03-05_11-52-17',\n",
+       " '009265_hippoSIT_2023-03-05_18-31-32',\n",
+       " '009265_hippoSIT_2023-03-08_18-10-07']"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "sessions"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "2c4b9cf9",
@@ -96,9 +234,31 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 7,
    "id": "e83d0e83",
    "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "36"
+      ]
+     },
+     "execution_count": 7,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "a1 = '009265_hippoSIT_2023-03-05_18-31-32.xml'\n",
+    "a1.find('xml')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "a4a6c341",
+   "metadata": {},
    "outputs": [],
    "source": []
   }

File diff suppressed because it is too large
+ 565355 - 12598
sorting/ss-neurosuite.ipynb