Browse Source

analysis of PPC neurons ongoing

asobolev 1 year ago
parent
commit
a904909266

File diff suppressed because it is too large
+ 122 - 34
analysis/active listening.ipynb


+ 31 - 0
analysis/correlation.py

@@ -0,0 +1,31 @@
+import scipy.cluster.hierarchy as sch
+import numpy as np
+
+
+def cluster_corr(corr_array, threshold=None, inplace=False):
+    """
+    Rearranges the correlation matrix, corr_array, so that groups of highly 
+    correlated variables are next to eachother 
+    
+    Parameters
+    ----------
+    corr_array : pandas.DataFrame or numpy.ndarray
+        a NxN correlation matrix 
+        
+    Returns
+    -------
+    corr_array : a NxN correlation matrix with the columns and rows rearranged
+    linkage    : linkage of distances
+    labels     : cluster labels
+    idx        : sorted incides for original labels
+    """
+    pairwise_distances = sch.distance.pdist(corr_array)
+    linkage = sch.linkage(pairwise_distances, method='complete')
+    cluster_distance_threshold = pairwise_distances.max()/2 if threshold is None else threshold
+    labels = sch.fcluster(linkage, cluster_distance_threshold, criterion='distance')
+    idx = np.argsort(labels)
+    
+    if not inplace:
+        corr_array = corr_array.copy()
+    
+    return corr_array[idx, :][:, idx], linkage, labels, idx

File diff suppressed because it is too large
+ 19 - 17
analysis/spatial - allocentric.ipynb


File diff suppressed because it is too large
+ 12 - 10
analysis/spatial - egocentric.ipynb


File diff suppressed because it is too large
+ 526 - 0
analysis/state separation.ipynb


File diff suppressed because it is too large
+ 197 - 184
analysis/timeline.ipynb


+ 10 - 8
postprocessing/execute.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": 10,
    "id": "c37dce82",
    "metadata": {
     "scrolled": true
@@ -39,7 +39,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 11,
    "id": "a8ea2991",
    "metadata": {},
    "outputs": [
@@ -75,7 +75,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 13,
    "id": "3891b792",
    "metadata": {},
    "outputs": [],
@@ -85,7 +85,7 @@
     "source = '/home/sobolev/nevermind/Andrey/data'\n",
     "\n",
     "# test session\n",
-    "filebase = '008229_hippoSIT_2022-07-01_14-07-59'\n",
+    "filebase = '008229_hippoSIT_2022-05-16_20-36-44'\n",
     "animal = filebase.split('_')[0]\n",
     "sessionpath = os.path.join(source, animal, filebase)\n",
     "h5name  = os.path.join(source, animal, filebase, filebase + '.h5')\n",
@@ -95,14 +95,15 @@
     "#sessions = [filebase]\n",
     "sessions = processed_008228 + processed_008229\n",
     "sessions = [\n",
-    "    \"008229_hippoSIT_2022-05-20_15-54-39\",\n",
+    "    \"008229_hippoSIT_2022-05-13_09-48-00\",\n",
+    "    \"008229_hippoSIT_2022-05-18_14-36-18\"\n",
     "]\n",
     "\n",
     "# FIXME move occupancy outside units\n",
     "# FIXME Move 'processed' into H5NAMES\n",
     "\n",
     "steps = {\n",
-    "    'write_trajectory': True,      # Packing to HDF5 (trajectory, trials, sound events)\n",
+    "    'write_trajectory': True,       # Packing to HDF5 (trajectory, trials, sound events)\n",
     "    'write_units': True,            # Loading units (spikes times, trajectory indices, instantaneous rate)\n",
     "    'write_spiking_metrics': True,  # Spiking metrics (mean firing rate, ISI metrics etc.)\n",
     "    'write_spatial_metrics': True,  # Spatial metrics\n",
@@ -112,7 +113,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 14,
    "id": "24cd2f6e",
    "metadata": {},
    "outputs": [
@@ -120,7 +121,8 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "session 008229_hippoSIT_2022-05-20_15-54-39 done\n"
+      "session 008229_hippoSIT_2022-05-13_09-48-00 done\n",
+      "session 008229_hippoSIT_2022-05-18_14-36-18 done\n"
      ]
     }
    ],