Ver Fonte

gin commit from Markov

Deleted files: 6
Krista Perks há 4 anos atrás
pai
commit
22569f04cf

+ 0 - 597
DataScripts/Analysis_responses.ipynb

@@ -1,597 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# -*- coding: utf-8 -*-\n",
-    "\"\"\"\n",
-    "Created on Mon Aug  6 13:16:08 2018\n",
-    "\n",
-    "@author: kperks\n",
-    "\"\"\"\n",
-    "# INITIALIZATION\n",
-    "from neo import Spike2IO\n",
-    "import os\n",
-    "import numpy as np\n",
-    "import scipy.io as sio\n",
-    "import scipy \n",
-    "import h5py\n",
-    "from scipy import stats\n",
-    "from scipy import signal\n",
-    "import matplotlib.pyplot as plt\n",
-    "import matplotlib.axes as ax\n",
-    "from pathlib import Path\n",
-    "import random\n",
-    "import sys\n",
-    "import pandas as pd\n",
-    "import seaborn as sns\n",
-    "from scipy.stats import spearmanr, ks_2samp "
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 36,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "def get_range_bounds(win_times,trigger):\n",
-    "    start = np.min(np.where(trigger>win_times[0])[0])\n",
-    "    stop= np.max(np.where(trigger<win_times[1])[0])\n",
-    "    trials = list(range(start,stop))\n",
-    "    return trials\n",
-    "    \n",
-    "def TrialEventTimes(trigger,analevent,trial,win):\n",
-    "    t1 = trigger[trial]\n",
-    "    t2 = t1+win\n",
-    "    EventTimes = analevent[np.where((analevent>t1)&(analevent<t2))]-t1\n",
-    "    return(EventTimes)\n",
-    "    \n",
-    "def get_response(trigger_times,data_func,trial_duration,tau):\n",
-    "    response = [data_func(np.linspace(t,t+trial_duration,int(trial_duration/dt))) for t in trigger_times]\n",
-    "    return np.asarray(response)\n",
-    "    \"\"\"\n",
-    "    Creates a spike density function from a spike train to do continuous analysis with (such as trial correlations)\n",
-    "    \"\"\" \n",
-    "    \n",
-    "def filtered_response(spk_times, tau):\n",
-    "    \"\"\"\n",
-    "    Creates a function with a gaussian centered at every spike time (the mean) with standard deviation tau\n",
-    "    \"\"\"\n",
-    "    spk_times = spk_times.reshape((-1, 1))\n",
-    "    norm_factor = tau * np.sqrt(2. * np.pi)\n",
-    "    return lambda t: np.sum(np.exp(-(spk_times - t.reshape((1, -1))) ** 2 / (2 * tau * tau)), 0) / norm_factor\n",
-    "    \n",
-    "def raster(trigger, data, **kwargs):\n",
-    "    ax = plt.gca();\n",
-    "    \n",
-    "    for ith, t in enumerate(trigger):\n",
-    "        inds = np.where((data>t)&(data<t+md.trial_duration[0]))[0]\n",
-    "        trialdata = data[inds]-t\n",
-    "        plt.scatter(trialdata, np.repeat(ith,len(trialdata)), **kwargs);\n",
-    "        \n",
-    "    plt.ylim(.5, len(trigger) + .5);\n",
-    "\n",
-    "###########\n",
-    "#functions to estimate optimal bandwidth for spike density:\n",
-    "def CostFunction(y_hist, N, w, dt):\n",
-    "    \"\"\"\n",
-    "    References\n",
-    "    ----------\n",
-    "    .. [1] H. Shimazaki and S. Shinomoto, \"Kernel Bandwidth Optimization in \n",
-    "           Spike Rate Estimation,\" in Journal of Computational Neuroscience \n",
-    "           29(1-2): 171–182, 2010 http://dx.doi.org/10.1007/s10827-009-0180-4\n",
-    "    \"\"\"\n",
-    "    # build normal smoothing kernel\n",
-    "    yh = fftkernel(y_hist, w / dt)\n",
-    "\n",
-    "    # formula for density\n",
-    "    C = np.sum(yh**2) * dt - 2 * np.sum(yh * y_hist) * dt + 2 \\\n",
-    "        / (2 * np.pi)**0.5 / w / N\n",
-    "    C = C * N**2\n",
-    "\n",
-    "    return C, yh\n",
-    "\n",
-    "\n",
-    "def fftkernel(x, w):\n",
-    "    \"\"\"\n",
-    "    References\n",
-    "    ----------\n",
-    "    .. [1] H. Shimazaki and S. Shinomoto, \"Kernel Bandwidth Optimization in \n",
-    "           Spike Rate Estimation,\" in Journal of Computational Neuroscience \n",
-    "           29(1-2): 171–182, 2010 http://dx.doi.org/10.1007/s10827-009-0180-4\n",
-    "    \"\"\"\n",
-    "    L = x.size\n",
-    "    Lmax = L + 3 * w\n",
-    "    n = 2 ** np.ceil(np.log2(Lmax))\n",
-    "\n",
-    "    X = np.fft.fft(x, n.astype(np.int))\n",
-    "\n",
-    "    f = np.linspace(0, n-1, n) / n\n",
-    "    f = np.concatenate((-f[0: np.int(n / 2 + 1)],\n",
-    "                        f[1: np.int(n / 2 - 1 + 1)][::-1]))\n",
-    "\n",
-    "    K = np.exp(-0.5 * (w * 2 * np.pi * f) ** 2)\n",
-    "\n",
-    "    y = np.real(np.fft.ifft(X * K, n))\n",
-    "\n",
-    "    y = y[0:L]\n",
-    "\n",
-    "    return y\n",
-    "\n",
-    "def sskernel(x, tin, W):\n",
-    "    \"\"\"\n",
-    "    Generates a kernel density estimate with globally-optimized bandwidth.\n",
-    "    The optimal bandwidth is obtained as a minimizer of the formula, sum_{i,j}\n",
-    "    \\int k(x - x_i) k(x - x_j) dx  -  2 sum_{i~=j} k(x_i - x_j), where k(x) is\n",
-    "    the kernel function.\n",
-    "    Parameters\n",
-    "    ----------\n",
-    "    x : array_like\n",
-    "        The one-dimensional samples drawn from the underlying density\n",
-    "    tin : array_like\n",
-    "        The values where the density estimate is to be evaluated in generating\n",
-    "        the output 'y'.\n",
-    "    W : array_like\n",
-    "        The kernel bandwidths to use in optimization. Should not be chosen\n",
-    "        smaller than the sampling resolution of 'x'.\n",
-    "    nbs : int, optional\n",
-    "        The number of bootstrap samples to use in estimating the [0.05, 0.95]\n",
-    "        confidence interval of the output 'y'\n",
-    "    Returns\n",
-    "    -------\n",
-    "    y : array_like\n",
-    "        The estimated density, evaluated at points t / tin.\n",
-    "    t : array_like\n",
-    "        The points where the density estimate 'y' is evaluated.\n",
-    "    optw : double\n",
-    "        The optimal global kernel bandwidth.\n",
-    "    C : array_like\n",
-    "        The cost functions associated with the bandwidths 'W'.\n",
-    "\n",
-    "    References\n",
-    "    ----------\n",
-    "    .. [1] H. Shimazaki and S. Shinomoto, \"Kernel Bandwidth Optimization in \n",
-    "           Spike Rate Estimation,\" in Journal of Computational Neuroscience \n",
-    "           29(1-2): 171–182, 2010 http://dx.doi.org/10.1007/s10827-009-0180-4\n",
-    "    \"\"\"\n",
-    "\n",
-    "    # set argument 't' if not provided\n",
-    "    #always provide xtime input so that output is aligned to trial duration\n",
-    "    T = np.max(x) - np.min(x)\n",
-    "    x_ab = x[(x >= np.min(tin)) & (x <= np.max(tin))]\n",
-    "    dx = np.sort(np.diff(np.sort(x)))\n",
-    "    dt_samp = dx[np.nonzero(dx)][0]\n",
-    "    if dt_samp > np.min(np.diff(tin)):\n",
-    "        t = np.linspace(np.min(tin), np.max(tin), np.min([int(np.ceil(T / dt_samp)), int(1e3)]))\n",
-    "    else:\n",
-    "        t = tin\n",
-    "\n",
-    "    # calculate delta t\n",
-    "    dt = min(np.diff(t))\n",
-    "\n",
-    "    # create the finest histogram\n",
-    "    thist = np.concatenate((t, (t[-1]+dt)[np.newaxis]))\n",
-    "    y_hist = np.histogram(x_ab, thist-dt/2)[0]\n",
-    "    N = sum(y_hist).astype(np.float)\n",
-    "    y_hist = y_hist / N / dt\n",
-    "\n",
-    "    # always provide W\n",
-    "    C = np.zeros((1, len(W)))[0]\n",
-    "    C_min = np.Inf\n",
-    "    ymat=[]\n",
-    "    for k, w in enumerate(W):\n",
-    "        C[k], yh = CostFunction(y_hist, N, w, dt)\n",
-    "        ymat.append(yh)\n",
-    "        if((C[k] < C_min).any()):\n",
-    "            C_min = C[k]\n",
-    "            optw = w\n",
-    "            y = yh\n",
-    "    ymat = np.asarray(ymat)       \n",
-    "    \n",
-    "    return y, t, optw, C, C_min\n",
-    "\n",
-    "def get_spikes_kde(trigger_times,data_times,trigger,trial_duration):\n",
-    "    aligned_times = []\n",
-    "    for t in trigger_times:\n",
-    "        thesetimes = data_times[\n",
-    "          np.where((data_times>(trigger[t]))&(data_times<(trigger[t]+trial_duration)))[0]\n",
-    "          ]-(trigger[t])\n",
-    "        aligned_times = np.concatenate((aligned_times,thesetimes)) \n",
-    "\n",
-    "    return np.asarray(aligned_times)\n",
-    "\n",
-    "def get_optw(these_trials,spikes,xtime,trigger,trial_duration):\n",
-    "    W=np.arange(0.006,0.2,0.002)\n",
-    "    aligned_times = get_spikes_kde(these_trials,spikes,trigger,trial_duration)\n",
-    "    y, t, optw, C, C_min = sskernel(aligned_times, xtime, W)\n",
-    "    \n",
-    "    return y, t, optw, C, C_min"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 48,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "meta = pd.read_csv('MetaData.csv')"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "What are the summary statistics for the trial duration in paired experiments? (for Methods section)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 58,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "count    33.000000\n",
-       "mean      2.757576\n",
-       "std       1.565603\n",
-       "min       1.000000\n",
-       "25%       1.500000\n",
-       "50%       2.000000\n",
-       "75%       4.000000\n",
-       "max       6.000000\n",
-       "Name: trial_duration, dtype: float64"
-      ]
-     },
-     "execution_count": 58,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "meta[((meta['trigger_type']=='paired')\n",
-    "      &(meta['phase']=='phase1')\n",
-    "      &((meta['condition']=='aen_vent') \n",
-    "        | (meta['condition']=='aen_proprio') \n",
-    "       |(meta['condition']=='aff_proprio')))].trial_duration.describe()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 47,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "0 20050727_3224_SPK.mat\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "/anaconda3/lib/python3.6/site-packages/neo-0.8.0.dev0-py3.6.egg/neo/rawio/spike2rawio.py:609: RuntimeWarning: overflow encountered in short_scalars\n",
-      "  info['time_per_adc']) * 1e-6\n",
-      "/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:61: DeprecationWarning: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.\n",
-      "/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:96: DeprecationWarning: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 20050728_3404_latency1_SPK.mat\n",
-      "2 20050728_3404_latency2_SPK.mat\n",
-      "3 20050808_3629_latency1_SPK.mat\n",
-      "4 20050808_3629_latency2_SPK.mat\n",
-      "5 20050811_3221_SPK.mat\n",
-      "6 20050818_2874_SPK.mat\n",
-      "7 20050819_2601_SPK.mat\n",
-      "8 20050820_2960_trial1_SPK.mat\n",
-      "9 20050824_2627_control_SPK.mat\n",
-      "10 20050824_2627_trial1_SPK.mat\n",
-      "11 20060626_2815_SPK.mat\n",
-      "12 20060627_2673_SPK.mat\n",
-      "13 20060708_3004_SPK.mat\n",
-      "14 20060710_2767_SPK.mat\n",
-      "15 20060710_3196_SPK.mat\n",
-      "16 20060804_2107_SPK.mat\n",
-      "17 20060812_2921_SPK.mat\n",
-      "18 20060812_3066_SPK.mat\n",
-      "19 20060812_3205_SPK.mat\n",
-      "20 20060816_3893_SPK.mat\n",
-      "21 20070718_598_coupled_SPK.mat\n",
-      "22 20070719_91_coupled_SPK.mat\n",
-      "23 20070720_3352_SPK.mat\n",
-      "24 20070723_287_SPK.mat\n",
-      "25 20070723_311_SPK.mat\n",
-      "26 20070723_339_SPK.mat\n",
-      "27 20070723_415_SPK.mat\n",
-      "28 20070727_3798_SPK.mat\n",
-      "29 20070727_3798_control_SPK.mat\n",
-      "30 20070816_3375_SPK.mat\n",
-      "31 20070816_3509_SPK.mat\n",
-      "32 20071025_3335_SPK.mat\n",
-      "33 20071025_3335_control_SPK.mat\n",
-      "using pre pairing expt to get baseline (recovery end)\n",
-      "34 20071026_3108_SPK.mat\n",
-      "35 20071026_3108_control_SPK.mat\n",
-      "using pre pairing expt to get baseline\n",
-      "36 20170810_expt5_vent_SPK.mat\n",
-      "37 20180124_expt1_swim_SPK.mat\n",
-      "38 20170815_expt8_vent_SPK.mat\n",
-      "39 20170815_expt9_vent_SPK.mat\n",
-      "40 20180124_expt2_swim_SPK.mat\n",
-      "41 20180407_freerun2_SPK.mat\n",
-      "42 20180407_freerun3_SPK.mat\n",
-      "43 20180407_freerun4_SPK.mat\n",
-      "44 20180407_freerun5_SPK.mat\n",
-      "45 20170815_expt10_swim_SPK.mat\n",
-      "46 20170810_expt4_vent_SPK.mat\n",
-      "47 20050808_3629_latency2b_SPK.mat\n",
-      "48 20050808_3629_latency1b_SPK.mat\n",
-      "49 20070801_3838_SPK.mat\n",
-      "50 20070801_3838_control_SPK.mat\n",
-      "51 20070808_3727_SPK.mat\n"
-     ]
-    }
-   ],
-   "source": [
-    "######MAIN##########\n",
-    "\n",
-    "meta = pd.read_csv('MetaData.csv')\n",
-    "\n",
-    "for iexpt,thisexpt_name in enumerate(meta.exptname):\n",
-    "    dt = 1/1000 \n",
-    "    ntrials_per_period = 75 #results did not depend on choice of 50, 75, or 100\n",
-    "\n",
-    "    print(iexpt,thisexpt_name)\n",
-    "\n",
-    "    thisexpt = meta.loc[meta['exptname'] == thisexpt_name]\n",
-    "\n",
-    "    trial_duration = thisexpt.trial_duration.values[0]\n",
-    "\n",
-    "    basename = thisexpt_name[0:-8]\n",
-    "    data_folder = Path.cwd() / basename\n",
-    "    file_to_open = data_folder / Path(basename + '.smr')\n",
-    "    bl = Spike2IO(file_to_open,try_signal_grouping=False).read_block()\n",
-    "\n",
-    "    trigger = []\n",
-    "    for sublist in np.asarray([seg.events[[s.name for \n",
-    "       s in seg.events].index(thisexpt.chan_trigger.values[0])].magnitude \n",
-    "       for seg in bl.segments]):\n",
-    "        for item in sublist:\n",
-    "            trigger.append(item)\n",
-    "    trigger = np.asarray(trigger)\n",
-    "\n",
-    "    if thisexpt.spike_times_from.values[0] == 'Spyking-Circus':\n",
-    "        spikes = np.load(data_folder / 'spikes.npy')\n",
-    "\n",
-    "    if thisexpt.spike_times_from.values[0] == 'Spike2':\n",
-    "        spikes = []\n",
-    "        for sublist in np.asarray([seg.events[[s.name for \n",
-    "           s in seg.events].index(thisexpt.chan_spikes.values[0])].magnitude \n",
-    "           for seg in bl.segments]):\n",
-    "            for item in sublist:\n",
-    "                spikes.append(item)\n",
-    "        spikes = np.asarray(spikes)\n",
-    "\n",
-    "    postpairing_range = get_range_bounds([thisexpt.post_start.values[0],\n",
-    "                                          thisexpt.post_stop.values[0]],trigger)\n",
-    "    stim_range = get_range_bounds([thisexpt.stim_start.values[0],\n",
-    "                                   thisexpt.stim_stop.values[0]],trigger)\n",
-    "    base_range = get_range_bounds([thisexpt.base_start.values[0],\n",
-    "                                   thisexpt.base_stop.values[0]],trigger)\n",
-    "\n",
-    "    if thisexpt_name == '20060812_3066_SPK.mat':\n",
-    "        #removing a few trials in which spike detection was clearly mis-triggered due to movement artifacts\n",
-    "        removeinds = np.arange(360,np.max(postpairing_range)-1,1)\n",
-    "        [postpairing_range.remove(x) for x in removeinds]\n",
-    "        removeinds = [263, 264, 265, 326, 327] \n",
-    "        [postpairing_range.remove(x) for x in removeinds]\n",
-    "\n",
-    "    xtime = np.linspace(0,trial_duration,trial_duration/dt)\n",
-    "\n",
-    "    iei = [(TrialEventTimes(trigger,trigger,trial,10))[0] if len(TrialEventTimes(trigger,trigger,trial,10))>0 else 0 for trial in list(range(0,len(trigger)-1))]\n",
-    "\n",
-    "    these_trials = base_range\n",
-    "    y, t, optw, C, C_min= get_optw(these_trials,spikes,xtime,trigger,trial_duration)\n",
-    "\n",
-    "    data_func = filtered_response(spikes, optw)\n",
-    "\n",
-    "    baseline_r = get_response(trigger[these_trials],data_func,trial_duration,optw)\n",
-    "    baseline_mean = np.mean(baseline_r,0)\n",
-    "\n",
-    "    n_trials = len(base_range)\n",
-    "    base_spkrt = [np.shape(np.where((spikes>(trigger[t]))&(spikes<(trigger[t]+trial_duration)))[0])[0]\n",
-    "                  /trial_duration for t in base_range]\n",
-    "\n",
-    "    spikemat_base = [spikes[np.where((spikes>trigger[t])&\n",
-    "                    (spikes<trigger[t]+trial_duration))[0]\n",
-    "                    ]-(trigger[t]) for t in base_range]\n",
-    "\n",
-    "    if thisexpt_name == '20071025_3335_control_SPK.mat': \n",
-    "    #not enough baseline recorded so get estimate of baseline from test cell clock trigger baseline\n",
-    "        print('using pre pairing expt to get baseline (recovery end)')\n",
-    "        suppname = '20071025_3335_SPK.mat'\n",
-    "        suppexpt = meta.loc[meta['exptname'] == suppname]\n",
-    "        basename = suppname[0:-8]\n",
-    "        data_folder = Path.cwd() / basename\n",
-    "        supptrigger = np.arange(suppexpt.post_stop.values[0]-250,suppexpt.post_stop.values[0],trial_duration)\n",
-    "        suppbase_range = np.arange(0,len(supptrigger),1)\n",
-    "        base_range = suppbase_range\n",
-    "\n",
-    "        suppspikes = np.load(data_folder / 'spikes.npy')\n",
-    "\n",
-    "        these_trials = suppbase_range\n",
-    "        y, t, optw, C, C_min= get_optw(these_trials,suppspikes,xtime,supptrigger,trial_duration)\n",
-    "\n",
-    "        data_func = filtered_response(suppspikes, optw)\n",
-    "\n",
-    "        baseline_mean = np.mean(get_response(\n",
-    "            supptrigger[these_trials],data_func,trial_duration,optw),0)\n",
-    "\n",
-    "        base_spkrt = [np.shape(np.where((suppspikes>(supptrigger[t]))&\n",
-    "                                        (suppspikes<(supptrigger[t]+trial_duration)))[0])[0]\n",
-    "                      /trial_duration for t in suppbase_range]\n",
-    "        spikemat_base = [suppspikes[np.where((suppspikes>supptrigger[t])&\n",
-    "                (suppspikes<supptrigger[t]+trial_duration))[0]\n",
-    "                ]-(supptrigger[t]) for t in suppbase_range]\n",
-    "\n",
-    "\n",
-    "    if thisexpt_name == '20071026_3108_control_SPK.mat': \n",
-    "    #not enough baseline recorded so get estimate of baseline from test cell clock trigger baseline\n",
-    "        print('using pre pairing expt to get baseline')\n",
-    "        suppname = '20071026_3108_SPK.mat'\n",
-    "        suppexpt = meta.loc[meta['exptname'] == suppname]\n",
-    "        basename = suppname[0:-8]\n",
-    "        data_folder = Path.cwd() / basename\n",
-    "        file_to_open = data_folder / Path(basename + '.smr')\n",
-    "        bl = Spike2IO(file_to_open,try_signal_grouping=False).read_block()\n",
-    "        supptrigger = np.arange(0,suppexpt.base_stop.values[0],trial_duration)\n",
-    "        suppbase_range = np.arange(0,len(supptrigger),1)\n",
-    "        base_range = suppbase_range\n",
-    "\n",
-    "        suppspikes = []\n",
-    "        for sublist in np.asarray([seg.events[[s.name for \n",
-    "           s in seg.events].index(suppexpt.chan_spikes.values[0])].magnitude \n",
-    "           for seg in bl.segments]):\n",
-    "            for item in sublist:\n",
-    "                suppspikes.append(item)\n",
-    "        suppspikes = np.asarray(suppspikes)\n",
-    "\n",
-    "        these_trials = suppbase_range\n",
-    "        y, t, optw, C, C_min= get_optw(these_trials,suppspikes,xtime,supptrigger,trial_duration)\n",
-    "\n",
-    "        data_func = filtered_response(suppspikes, optw)\n",
-    "\n",
-    "        baseline_mean = np.mean(get_response(\n",
-    "            supptrigger[these_trials],data_func,trial_duration,optw),0)\n",
-    "\n",
-    "        base_spkrt = [np.shape(np.where((suppspikes>(supptrigger[t]))&\n",
-    "                                        (suppspikes<(supptrigger[t]+trial_duration)))[0])[0]\n",
-    "                      /trial_duration for t in suppbase_range]\n",
-    "        spikemat_base = [suppspikes[np.where((suppspikes>supptrigger[t])&\n",
-    "                (suppspikes<supptrigger[t]+trial_duration))[0]\n",
-    "                ]-(supptrigger[t]) for t in suppbase_range]\n",
-    "\n",
-    "    data_func = filtered_response(spikes, optw)\n",
-    "\n",
-    "    npair = len(stim_range)\n",
-    "    ntrials = np.min([npair,ntrials_per_period*2])\n",
-    "    stiminitial_trials = stim_range[0:int(ntrials/2)]\n",
-    "    these_trials = stiminitial_trials\n",
-    "    stimi_spkrt = [np.shape(np.where((spikes>(trigger[t]))&(spikes<(trigger[t]+trial_duration)))[0])[0]\n",
-    "                   /trial_duration for t in these_trials]\n",
-    "    y, t, optw_stim, C, C_min= get_optw(these_trials,spikes,xtime,trigger,trial_duration)\n",
-    "    stiminitial_r = get_response(trigger[these_trials],data_func,trial_duration,optw)\n",
-    "    stiminitial_response = np.mean(stiminitial_r,0)\n",
-    "\n",
-    "    stimfinal_trials = stim_range[-int(ntrials/2):]\n",
-    "    these_trials = stimfinal_trials\n",
-    "    stimf_spkrt = [np.shape(np.where((spikes>(trigger[t]))&(spikes<(trigger[t]+trial_duration)))[0])[0]\n",
-    "                   /trial_duration for t in these_trials]\n",
-    "    stimfinal_r = get_response(trigger[these_trials],data_func,trial_duration,optw)\n",
-    "    stimfinal_response = np.mean(stimfinal_r,0)\n",
-    "\n",
-    "    npost = len(postpairing_range)\n",
-    "    ntrials = np.min([npost,ntrials_per_period])\n",
-    "    postpairing_trials = postpairing_range[0:ntrials]\n",
-    "    these_trials = postpairing_trials\n",
-    "    post_spkrt = [np.shape(np.where((spikes>(trigger[t]))&(spikes<(trigger[t]+trial_duration)))[0])[0]\n",
-    "                  /trial_duration for t in these_trials]\n",
-    "    postpairing_r = get_response(trigger[these_trials],data_func,trial_duration,optw)\n",
-    "    postpairing_response = np.mean(postpairing_r,0)\n",
-    "\n",
-    "    recovery_spkrt = np.nan\n",
-    "    recovery_response = np.full_like(np.empty(len(baseline_mean)),np.nan)\n",
-    "    recovery_trials = [np.nan]\n",
-    "    if npost>=(300+ntrials_per_period):\n",
-    "        recovery_trials = postpairing_range[300:300+ntrials_per_period]\n",
-    "        recovery_spkrt = [np.shape(np.where((spikes>(trigger[t]))&(spikes<(trigger[t]+trial_duration)))[0])[0]\n",
-    "                          /trial_duration for t in recovery_trials]\n",
-    "        these_trials = recovery_trials\n",
-    "        recovery_r = get_response(trigger[these_trials],data_func,trial_duration,optw)\n",
-    "        recovery_response = np.mean(recovery_r,0)\n",
-    "\n",
-    "\n",
-    "    spikemat_stim = [spikes[np.where((spikes>trigger[t])&\n",
-    "                    (spikes<trigger[t]+trial_duration))[0]\n",
-    "                    ]-(trigger[t]) for t in stim_range]\n",
-    "    spikemat_post = [spikes[np.where((spikes>trigger[t])&\n",
-    "                    (spikes<trigger[t]+trial_duration))[0]\n",
-    "                    ]-(trigger[t]) for t in postpairing_range]\n",
-    "\n",
-    "    ccpost = scipy.signal.correlate(postpairing_response,stiminitial_response,mode='same')/(np.var(postpairing_r)*np.var(stiminitial_r))/len(stiminitial_response)\n",
-    "    lags = np.linspace(-(0.5*len(postpairing_response)*dt),(0.5*len(postpairing_response)*dt),len(ccpost))\n",
-    "\n",
-    "    datamat = pd.DataFrame({'exptname' : thisexpt_name,\n",
-    "                  'ntrials_base' : [len(base_range)],\n",
-    "                  'ntrials_per_period' : [ntrials_per_period],\n",
-    "                  'ntrials_post' : [len(postpairing_trials)],\n",
-    "                  'ntrials_post_total' : [len(postpairing_range)],\n",
-    "                  'ntrials_recovery' : [len(recovery_trials)],\n",
-    "                  'ntrials_pairing' : [len(stim_range)],\n",
-    "                  'iei_median' : [np.median(iei)],\n",
-    "                  'spkrt_base' : [np.mean(base_spkrt)],\n",
-    "                  'spkrt_stimi' : [np.mean(stimi_spkrt)],\n",
-    "                  'spkrt_stimf' : [np.mean(stimf_spkrt)],\n",
-    "                  'spkrt_post' : [np.mean(post_spkrt)],\n",
-    "                  'spkrt_recovery' : [np.mean(recovery_spkrt)],\n",
-    "                  'latency_minpost' : [xtime[np.where(postpairing_response==np.min(postpairing_response))][0]],\n",
-    "                  'latency_maxstim' : [xtime[np.where(stiminitial_response==np.max(stiminitial_response))][0]],\n",
-    "                  'sp_poststim_mean' : [stats.spearmanr(postpairing_response,stiminitial_response,nan_policy='propagate')[0]],\n",
-    "                  'sp_recoverstim_mean' : [stats.spearmanr(recovery_response,stiminitial_response,nan_policy='propagate')[0]],\n",
-    "                  'sp_basestim_mean' : [stats.spearmanr(baseline_mean,stiminitial_response,nan_policy='propagate')[0]],\n",
-    "                  'ccneg' : [np.min(ccpost)],\n",
-    "                  'ccneg_lag' : [(dt*(np.argmin(ccpost)-len(postpairing_response)))],\n",
-    "                  'ccpos' : [np.max(ccpost)],\n",
-    "                  'ccpos_lag' : [(dt*(np.argmax(ccpost)-len(postpairing_response)))],\n",
-    "                  'cell' : thisexpt.cell.values[0],\n",
-    "                  'condition' : thisexpt.condition.values[0],\n",
-    "                  'trigger_type' : thisexpt.trigger_type.values[0],\n",
-    "                  'phase' : thisexpt.phase.values[0],\n",
-    "                  'optw' : optw,\n",
-    "                  'optw_stim' : optw_stim,\n",
-    "                  'control' : thisexpt.control.values[0]\n",
-    "                    })\n",
-    "\n",
-    "    path_to_file = Path.cwd()\n",
-    "    file_to_open = path_to_file / 'DataMat.csv'\n",
-    "    f = open(file_to_open)\n",
-    "    dfimport = pd.read_csv(f.name)\n",
-    "    dfimport = dfimport.loc[:, ~dfimport.columns.str.contains('^Unnamed')]\n",
-    "\n",
-    "    dfimport = dfimport.append(datamat,sort=True)\n",
-    "    dfimport = dfimport.drop_duplicates('exptname','last')\n",
-    "    dfimport.to_csv(f.name)"
-   ]
-  }
- ],
- "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.6.8"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}

+ 0 - 53
DataScripts/DataMat.csv

@@ -1,53 +0,0 @@
-,ccneg,ccneg_lag,ccpos,ccpos_lag,cell,condition,control,exptname,iei_median,latency_maxstim,latency_minpost,ntrials_base,ntrials_pairing,ntrials_per_period,ntrials_post,ntrials_post_total,ntrials_recovery,optw,optw_stim,phase,sp_basestim_mean,sp_poststim_mean,sp_recoverstim_mean,spkrt_base,spkrt_post,spkrt_recovery,spkrt_stimf,spkrt_stimi,trigger_type
-1,0.003391655992319634,-1.5,0.038359021662699805,-0.36,aen,aen_vent,no,20050727_3224_SPK.mat,2.373064999999997,0.5173448965977319,0.4262841894596398,188.0,765.0,75.0,75.0,248.0,1.0,0.07,0.05,phase1,-0.3152406983291993,-0.3049877088834262,,1.4148936170212767,0.6044444444444445,,2.871111111111111,3.991111111111112,paired
-2,2.7613069300326208e-05,-1.5,0.02536010977280709,-0.001,aen,aen_vent,no,20050728_3404_latency1_SPK.mat,3.1331599999998616,0.15310206804536358,0.4452968645763843,192.0,576.0,75.0,75.0,374.0,1.0,0.068,0.02,phase1,-0.4802410596626932,-0.5571528947346199,,1.0069444444444444,0.3733333333333333,,3.28,5.235555555555557,paired
-3,7.313509360103952e-06,-0.07400000000000001,0.004099956073127186,-1.5,aen,aen_vent,no,20050728_3404_latency2_SPK.mat,3.15175999999974,0.8355570380253503,0.8205470313542362,301.0,499.0,75.0,75.0,488.0,75.0,0.02,0.026,phase2,0.5230180813413695,-0.2208714901651068,-0.19941669307408585,0.3455149501661129,0.08,0.26666666666666666,3.831111111111111,4.728888888888889,paired
-4,0.0021106814012862834,-0.888,0.010704225288236058,-1.442,aen,aen_vent,no,20050808_3629_latency1_SPK.mat,1.5292100000000346,0.7725150100066712,0.6374249499666444,254.0,1051.0,75.0,75.0,898.0,75.0,0.038,0.012,phase2,-0.0662759405670847,-0.5772490778884791,-0.07168604074935145,1.8346456692913389,0.8888888888888892,0.8177777777777778,2.8888888888888893,3.608888888888889,paired
-5,0.0017240277078137546,-1.5,0.009754382268093985,-0.9059999999999999,aen,aen_vent,no,20050808_3629_latency2_SPK.mat,1.6795950000001767,0.2571714476317545,0.5653769179452969,328.0,807.0,75.0,75.0,641.0,75.0,0.04,0.026,phase1,0.4910281257902781,-0.008322976143544953,-0.2316782363014384,1.817073170731708,0.4533333333333333,1.3422222222222222,2.9244444444444437,3.4577777777777774,paired
-6,0.003527134080406928,-1.0,0.016910116194395416,-0.5740000000000001,aen,aen_vent,no,20050811_3221_SPK.mat,1.2808149999999614,0.4234234234234234,0.0,395.0,693.0,75.0,75.0,612.0,75.0,0.052000000000000005,0.008,phase1,0.06634443034443037,0.7720555120555121,0.528935628935629,0.8177215189873418,0.6666666666666666,2.32,4.16,3.7066666666666666,paired
-7,0.07297179890457199,-1.5,0.20220411260578608,-0.75,aen,aen_vent,no,20050818_2874_SPK.mat,3.289410000000089,0.6234156104069379,0.22114743162108075,189.0,284.0,75.0,75.0,173.0,1.0,0.098,0.012,phase1,-0.7282687218972097,-0.05053913712850538,,2.299823633156967,2.4977777777777783,,3.048888888888889,3.5733333333333324,paired
-8,0.0008093767014270291,-1.25,0.006209617094323282,-0.06,aen,aen_vent,no,20050819_2601_SPK.mat,3.357984999999985,0.3542834267413931,0.2852281825460368,283.0,280.0,75.0,75.0,428.0,75.0,0.052000000000000005,0.01,phase1,0.4398336142295131,-0.5721103939266521,-0.4865023498895039,1.1081272084805651,0.7573333333333334,0.6186666666666667,5.397333333333332,6.826666666666666,paired
-9,0.016286114571753024,-0.001,0.062002788282476136,-2.208,aen,aen_vent,no,20050820_2960_trial1_SPK.mat,3.822799999999688,1.374549819927971,1.4115646258503405,150.0,217.0,75.0,75.0,166.0,1.0,0.06,0.042,phase1,-0.4443087709934034,-0.5790621293859408,,6.24,6.389333333333332,,6.469333333333332,5.7920000000000025,paired
-10,0.018776053490699333,-0.001,0.1097886823372094,-1.5,aen,aen_vent,yes,20050824_2627_control_SPK.mat,2.999939999999924,1.7575858619539848,3.0,106.0,333.0,75.0,75.0,101.0,1.0,0.17800000000000002,0.006,phase1,0.3520886240098471,0.4399736924415214,,1.5094339622641506,2.0444444444444447,,1.9955555555555555,2.1111111111111107,freerun
-11,0.001599337281836691,-1.358,0.02072700802061786,-0.17600000000000002,aen,aen_vent,yes,20050824_2627_trial1_SPK.mat,3.998959999999897,0.2681787858572382,0.31420947298198804,207.0,142.0,75.0,75.0,584.0,75.0,0.038,0.012,phase1,0.12477562523361126,-0.4910344546819799,-0.3734344984153327,1.9001610305958128,0.96,1.8488888888888888,2.967136150234741,5.004694835680751,paired
-12,0.009908490423344444,-0.25,0.031300780792499774,-1.347,aen,aen_vent,no,20060626_2815_SPK.mat,2.7058200000001307,0.6023011505752875,0.012006003001500749,105.0,219.0,75.0,75.0,204.0,1.0,0.058,0.014,phase1,0.3937684044421012,0.3389502937375734,,0.7,0.6466666666666666,,1.1666666666666667,1.653333333333333,paired
-13,0.008322122905159936,-1.265,0.050107630528892944,-0.799,aen,aen_vent,no,20060627_2673_SPK.mat,2.266280000000052,0.9106070713809208,0.3682454969979987,132.0,261.0,75.0,75.0,374.0,1.0,0.068,0.012,phase1,0.3024078997368444,0.2518871910609738,,0.8939393939393939,0.4266666666666667,,2.4711111111111106,2.7022222222222223,paired
-14,0.0009059986208671073,-1.4469999999999998,0.006135136153767406,-0.8740000000000001,aen,aen_vent,no,20060708_3004_SPK.mat,1.883540000000039,0.1921280853902602,0.30520346897931955,101.0,478.0,75.0,75.0,469.0,75.0,0.02,0.018000000000000002,phase1,-0.3935002033334237,-0.3229019568453142,-0.2592372636610061,6.422442244224423,6.64888888888889,9.146666666666668,7.386666666666668,7.2799999999999985,paired
-15,0.0012960509847918722,-1.5,0.011683593029301062,-0.001,aen,aen_vent,no,20060710_2767_SPK.mat,2.7551300000000083,0.2731821214142762,0.6544362908605738,134.0,209.0,75.0,75.0,454.0,75.0,0.055999999999999994,0.016,phase1,0.10876490167328964,-0.14687330261035672,-0.5601267876119056,1.7611940298507462,1.3955555555555554,1.6711111111111108,2.08,3.128888888888889,paired
-16,0.0018610641319477734,-1.5,0.012217001450991728,-0.139,aen,aen_vent,no,20060710_3196_SPK.mat,2.6534100000001217,0.6444296197464977,0.4292861907938626,114.0,211.0,75.0,75.0,420.0,75.0,0.054000000000000006,0.046,phase1,0.04675670344742376,-0.7072262307672137,-0.8112028529790458,0.9883040935672516,1.2533333333333332,1.3244444444444443,1.262222222222222,1.8222222222222224,paired
-17,0.00844922273774072,-2.0,0.018759398334441936,-1.0,aen,aen_vent,no,20060804_2107_SPK.mat,1.9557000000000928,0.7743871935967983,1.6798399199599798,120.0,263.0,75.0,75.0,176.0,1.0,0.07,0.01,phase1,0.4956826974206743,0.21264801966200486,,2.3291666666666666,2.3466666666666667,,2.68,1.68,paired
-18,0.013282479235387357,-0.001,0.031133498539921443,-0.75,aen,aen_vent,no,20060812_2921_SPK.mat,4.386660000000006,0.8745830553702469,0.7334889926617746,47.0,239.0,75.0,75.0,112.0,1.0,0.064,0.024,phase1,-0.17703943512863785,-0.3543668561630472,,8.865248226950351,7.52,,13.368888888888893,12.293333333333333,paired
-19,0.0006022614730082135,-0.264,0.0016331834856953382,-1.143,aen,aen_vent,no,20060812_3066_SPK.mat,3.617535000000004,0.7174783188792528,0.6264176117411608,86.0,116.0,75.0,75.0,116.0,1.0,0.02,0.013999999999999999,phase1,-0.19730708858092827,-0.2144839246595221,,4.3023255813953485,4.613333333333333,,6.091954022988506,7.080459770114943,paired
-20,0.006188661351625132,-1.5,0.019558593891659103,-0.7020000000000001,aen,aen_vent,no,20060812_3205_SPK.mat,3.5563700000000162,0.4973315543695798,1.1427618412274851,147.0,246.0,75.0,75.0,241.0,1.0,0.07600000000000001,0.016,phase1,0.4537853252379224,-0.13367443807752805,,1.3197278911564625,0.8977777777777777,,2.435555555555556,3.262222222222221,paired
-21,0.00016693008326530996,-1.13,0.00039457190262420913,-0.34299999999999997,aen,aen_vent,no,20060816_3893_SPK.mat,1.5455150000000233,0.6724482988659106,0.8395597064709808,425.0,383.0,75.0,75.0,220.0,1.0,0.01,0.012,phase1,0.15522347165487632,0.014355153046734688,,4.520784313725491,3.84,,3.368888888888889,6.373333333333332,paired
-22,0.03966516358464478,-4.0,0.1072010506126799,-1.686,afferent,aff_proprio,no,20070718_598_coupled_SPK.mat,3.879199999999855,1.3763440860215057,3.5758939734933737,164.0,236.0,75.0,75.0,86.0,1.0,0.10400000000000001,0.038,phase1,0.3418293331768333,0.212414144400884,,2.1326219512195124,2.5033333333333334,,2.043333333333333,2.5933333333333333,paired
-23,0.04220615016274112,-4.0,0.0870950872123133,-2.0,afferent,aff_proprio,no,20070719_91_coupled_SPK.mat,3.621739999999989,3.708927231807953,0.46111527881970504,43.0,178.0,75.0,75.0,76.0,1.0,0.042,0.028,phase1,0.2343968747123046,0.2346968856060553,,33.80813953488372,25.94333333333333,,25.236666666666668,28.77666666666667,paired
-24,0.0007386009928324457,-0.001,0.004103853721367368,-2.61,aen,aen_proprio,no,20070720_3352_SPK.mat,4.190759999999956,3.072722993645564,3.1297364085667216,145.0,212.0,75.0,75.0,151.0,1.0,0.04,0.042,phase1,-0.5318117149726819,0.003997964752991331,,2.486004056795132,1.5905882352941174,,2.8329411764705883,2.99921568627451,paired
-25,0.2934928793669929,-0.001,0.6127375001214355,-3.0,afferent,aff_proprio,no,20070723_287_SPK.mat,5.985859999999999,3.689614935822637,0.18903150525087514,12.0,95.0,75.0,29.0,29.0,1.0,0.198,0.032,phase1,-0.4412904172025116,0.4457788554938572,,14.972222222222221,12.419540229885053,,14.24822695035461,14.333333333333332,paired
-26,0.041899623880059834,-6.0,0.09799167575936532,-3.0,afferent,aff_proprio,no,20070723_311_SPK.mat,5.984829999999987,1.2222037006167694,0.8891481913652276,32.0,91.0,75.0,24.0,24.0,1.0,0.06,0.018000000000000002,phase1,0.14484185569005156,-0.09699437786095494,,13.65625,14.215277777777779,,14.129629629629633,14.170370370370367,paired
-27,0.0016292583095410232,-5.769,0.00995177638029184,-3.009,afferent,aff_proprio,no,20070723_339_SPK.mat,5.984109999999987,1.2572095349224872,4.063677279546591,32.0,91.0,75.0,33.0,33.0,1.0,0.032,0.006,phase1,0.18420591489460875,0.17610163916948995,,6.65625,7.9848484848484835,,9.074074074074074,7.851851851851853,paired
-28,0.0052981307723133685,-5.0,0.012239274929066915,-2.454,afferent,aff_proprio,no,20070723_415_SPK.mat,5.9836199999999735,0.8761752350470094,0.7731546309261852,43.0,108.0,75.0,34.0,34.0,1.0,0.034,0.006,phase1,0.044780352831214114,0.046776766991070674,,7.362790697674419,9.182352941176466,,12.522222222222226,12.366666666666665,paired
-29,0.0018964847174822558,-4.0,0.012334479948679408,-1.125,aen,aen_proprio,yes,20070727_3798_SPK.mat,4.433950000000053,1.3473368342085523,1.1602900725181295,86.0,406.0,75.0,75.0,203.0,1.0,0.07400000000000001,0.028,phase1,0.14529427920589244,-0.1674846916552932,,1.1104651162790695,0.91,,1.2566666666666666,1.66,paired
-30,0.002328475888974052,-3.0,0.0056243119093825,-2.27,aen,aen_proprio,yes,20070727_3798_control_SPK.mat,2.9999900000000252,1.3114371457152385,2.3217739246415467,93.0,280.0,75.0,75.0,118.0,1.0,0.044,0.027999999999999997,phase1,0.026658400295377808,-0.1712015256890584,,0.971326164874552,0.6844444444444444,,1.5288888888888892,2.3466666666666667,freerun
-31,0.00191119284417951,-4.0,0.025872699409852942,-0.634,aen,aen_proprio,yes,20070816_3375_SPK.mat,4.754419999999982,1.7694423605901477,0.8232058014503627,56.0,183.0,75.0,75.0,146.0,1.0,0.07800000000000001,0.04,phase1,0.055792510987031925,-0.4894468290279267,,2.0357142857142856,0.85,,1.99,2.56,paired
-32,0.0037628673321355188,-4.0,0.015736780971665844,-1.754,aen,aen_proprio,no,20070816_3509_SPK.mat,5.523390000000063,1.2173043260815206,0.7721930482620656,61.0,154.0,75.0,75.0,94.0,1.0,0.14,0.064,phase1,-0.16706659812916236,-0.0016326229770389359,,2.8360655737704916,4.116666666666666,,6.666666666666668,5.616666666666666,paired
-33,0.002686190781940673,-3.0,0.018963404583666764,-1.619,aen,aen_vent,yes,20071025_3335_SPK.mat,5.0512600000000125,0.20406802267422475,0.2800933644548183,82.0,199.0,75.0,75.0,257.0,1.0,0.055999999999999994,0.01,phase1,0.17648341160926795,-0.29654986583887394,,1.3943089430894309,0.7155555555555555,,2.9911111111111115,3.111111111111111,paired
-34,0.019643670394007804,-3.0,0.11249217055897827,-1.5,aen,aen_vent,yes,20071025_3335_control_SPK.mat,4.0,0.6132044014671557,0.581193731243748,84.0,147.0,75.0,75.0,151.0,1.0,0.17600000000000002,0.006,phase1,-0.4267969185329909,-0.5761682600186955,,1.2222222222222223,0.6355555555555555,,2.3652968036529685,2.5342465753424657,freerun
-35,0.013996174836992436,-0.001,0.0268408965598851,-1.08,aen,aen_vent,yes,20071026_3108_SPK.mat,4.612885000000006,1.8606202067355784,1.4974991663887964,79.0,201.0,75.0,75.0,128.0,1.0,0.102,0.01,phase1,0.18804638756070968,-0.4372857548095283,,1.5443037974683549,1.2311111111111108,,3.3644444444444437,4.217777777777776,paired
-36,0.007437621873531498,-0.001,0.02235616635633664,-1.899,aen,aen_vent,yes,20071026_3108_control_SPK.mat,3.0,1.6185395131710572,0.6532177392464155,161.0,223.0,75.0,75.0,112.0,1.0,0.15000000000000002,0.006,phase1,0.490137755180877,0.4070495532277281,,1.5714285714285714,2.4533333333333336,,2.8666666666666663,3.9555555555555553,freerun
-37,0.03055139361849798,-1.5,0.07109563912324117,-0.75,aen,aen_ventcmd,no,20170810_expt5_vent_SPK.mat,1.903794000000289,0.2501667778519013,0.23915943962641764,161.0,1417.0,75.0,75.0,513.0,75.0,0.068,0.006,phase1,0.2612069498697555,-0.2433185685860305,-0.3303163388072617,5.46583850931677,4.604444444444448,5.395555555555557,6.017777777777778,5.875555555555558,paired
-38,0.0037618882825522907,-0.001,0.022031370049075426,-0.516,aen,aen_swimcmd,no,20180124_expt1_swim_SPK.mat,1.4107500000000073,0.6075523202911739,0.1151046405823476,201.0,291.0,75.0,75.0,847.0,75.0,0.052000000000000005,0.034,phase1,0.2257895359643048,0.40119907236587504,-0.37131215059606737,0.5924920850293984,0.3272727272727273,0.3151515151515152,1.3575757575757572,1.6363636363636362,paired
-39,0.0009309597892807693,-1.4340000000000002,0.002544615637485021,-0.75,aen,aen_ventcmd,no,20170815_expt8_vent_SPK.mat,2.0922070000000303,0.1751167444963309,0.2361574382921948,237.0,1449.0,75.0,75.0,217.0,1.0,0.012,0.006,phase1,0.2423338499261556,-0.10223194232530773,,4.4781997187060485,4.675555555555556,,4.64,5.066666666666666,paired
-40,0.02807003248159512,-0.001,0.06139846217438015,-0.875,aen,aen_ventcmd,no,20170815_expt9_vent_SPK.mat,2.1093199999999683,0.13907947398513434,0.8274728416237851,135.0,436.0,75.0,75.0,135.0,1.0,0.048,0.006,phase1,0.06879294738428604,0.16548313331227674,,5.257142857142859,4.7542857142857144,,5.188571428571429,5.531428571428571,paired
-41,0.000967477579041476,-0.001,0.009318052518305218,-0.371,aen,aen_swimcmd,no,20180124_expt2_swim_SPK.mat,1.3306460000000015,0.6506506506506506,0.6536536536536537,339.0,379.0,75.0,75.0,672.0,75.0,0.03,0.028,phase1,-0.07161047961047963,0.1206836286836287,0.20896790896790896,0.5309734513274337,0.6133333333333333,0.5066666666666667,1.4933333333333334,1.7466666666666666,paired
-42,43.886738211783246,-0.001,87.74475247918856,-1.0,afferent,aff_free,no,20180407_freerun2_SPK.mat,1.6805220000000531,0.6993496748374186,1.5947973986993496,79.0,196.0,75.0,75.0,97.0,1.0,0.068,0.07200000000000001,phase1,-0.263408783852196,0.2057110174277544,,17.943037974683552,18.16,,18.08,18.213333333333328,paired
-43,1.0415689984162302,-1.5,2.0864492535187003,-0.75,afferent,aff_free,no,20180407_freerun3_SPK.mat,1.6805090000000007,0.06804536357571715,1.3529019346230822,76.0,189.0,75.0,75.0,101.0,1.0,0.06,0.057999999999999996,phase1,-0.2070557684692305,0.28713646894954176,,18.394736842105264,15.306666666666665,,15.999999999999995,17.45777777777778,paired
-44,0.2840625530829406,-2.0,0.5705113161348639,-1.0,afferent,aff_free,no,20180407_freerun4_SPK.mat,1.680516000000006,1.9369684842421209,0.1890945472736368,77.0,189.0,75.0,65.0,65.0,1.0,0.198,0.006,phase1,-0.6849000377250094,-0.9633208103302024,,0.5844155844155844,0.8076923076923077,,5.0,4.073333333333333,paired
-45,0.6661811756045574,-2.0,1.5121594550180462,-1.0,afferent,aff_free,no,20180407_freerun5_SPK.mat,1.6804970000000026,0.2051025512756378,0.9174587293646824,177.0,315.0,75.0,75.0,159.0,1.0,0.198,0.006,phase1,-0.8775394638848658,0.9476009219002304,,0.4209039548022599,0.19333333333333333,,2.1933333333333334,3.653333333333333,paired
-46,0.02504302507522841,-0.001,0.062242131550814976,-0.5,aen,aen_swimcmd,no,20170815_expt10_swim_SPK.mat,1.1866800000000242,0.25125125125125125,0.6986986986986987,229.0,510.0,75.0,75.0,303.0,1.0,0.052000000000000005,0.006,phase1,0.6141173061173062,0.4867411387411388,,4.283842794759826,5.253333333333333,,5.88,6.12,paired
-47,0.007839085914220266,-2.0,0.022072639560811118,-0.633,aen,aen_ventcmd,no,20170810_expt4_vent_SPK.mat,1.93626600000016,0.23911955977988994,0.22211105552776386,260.0,1032.0,75.0,75.0,912.0,75.0,0.04,0.006,phase1,0.042452568113142033,-0.2411739167934792,-0.14673562268390564,5.655769230769232,4.92,5.433333333333334,5.386666666666668,4.886666666666667,paired
-48,0.0014418794886306555,-1.5,0.009329957655524268,-0.181,aen,aen_vent,no,20050808_3629_latency2b_SPK.mat,1.6795950000001767,0.3942628418945964,0.43929286190793865,328.0,807.0,75.0,75.0,641.0,75.0,0.048,0.052000000000000005,phase1,0.43942165663184746,-0.7118476514878451,-0.6092594778931013,1.5142276422764227,1.3955555555555552,2.1244444444444444,2.0088888888888894,1.9555555555555557,paired
-49,0.006857034691318903,-0.001,0.02548160555679874,-1.2009999999999998,aen,aen_vent,no,20050808_3629_latency1b_SPK.mat,1.5292100000000346,0.917611741160774,0.9786524349566378,254.0,1051.0,75.0,75.0,898.0,75.0,0.1,0.016,phase2,0.7658834017259563,-0.5331527774012345,-0.5595593918041742,1.6482939632545932,1.8844444444444448,1.9733333333333327,1.7866666666666666,2.3466666666666667,paired
-50,0.0009379182621860118,-0.001,0.01316521085850712,-3.732,aen,aen_proprio,yes,20070801_3838_SPK.mat,5.834470000000124,2.4456114028507128,2.5276319079769944,53.0,138.0,75.0,75.0,203.0,1.0,0.07400000000000001,0.044,phase1,0.06773300092081255,-0.34993560780847544,,1.4103773584905661,1.09,,3.467391304347826,3.431159420289855,paired
-51,0.0007206736538094145,-0.001,0.021845787941362032,-1.7369999999999999,aen,aen_proprio,yes,20070801_3838_control_SPK.mat,3.9999899999997983,2.4786196549137287,0.09502375593898477,64.0,226.0,75.0,65.0,65.0,1.0,0.11599999999999999,0.054000000000000006,phase1,-0.12393031787064485,0.3295872370992023,,1.09765625,0.8923076923076924,,3.3266666666666667,2.9833333333333334,freerun
-0,0.000805349537323278,-4.0,0.0035562846763880526,-2.134,aen,aen_proprio,no,20070808_3727_SPK.mat,4.738679999999931,1.202300575143786,2.6356589147286824,204.0,196.0,75.0,75.0,141.0,1.0,0.034,0.034,phase1,0.18327743289233955,-0.0018523639907727493,,1.6458333333333333,2.1166666666666667,,2.6233333333333335,2.4433333333333334,paired

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 5031
DataScripts/ManuscriptAnalysis.ipynb


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 1
DataScripts/MetaData.csv


+ 0 - 99
DataScripts/SpykingCircus.params

@@ -1,99 +0,0 @@
-[data]
-file_format    = raw_binary            # Can be raw_binary, openephys, hdf5, ... See >> spyking-circus help -i for more info
-data_dtype     = float32
-nb_channels    = 1
-sampling_rate  = 16666.666666666668
-stream_mode    = None                  # None by default. Can be multi-files, or anything depending to the file format
-mapping        = mon.prb  # Mapping of the electrode (see http://spyking-circus.rtfd.ord)
-suffix         = done                      # Suffix to add to generated files
-global_tmp     = True                  # should be False if local /tmp/ has enough space (better for clusters)
-overwrite      = True                  # If you want to filter or remove artefacts on site. Data are duplicated otherwise
-blosc_compress = False                 # For clusters only, to compress data shared among nodes
-
-[detection]
-radius         = auto       # Radius [in um] (if auto, read from the prb file)
-N_t            = 5          # Width of the templates [in ms]
-spike_thresh   = 5              #!! AUTOMATICALLY EDITED: DO NOT MODIFY !!
-peaks          = both    # Can be negative (default), positive or both
-matched-filter = False      # If True, we perform spike detection with matched filters
-matched_thresh = 5          # Threshold for detection if matched filter is True
-alignment      = True       # Realign the waveforms by oversampling
-isolation      = False      # Enforce individual snippets to be isolated [experimental]
-
-[filtering]
-cut_off        = 300, auto # Min and Max (auto=nyquist) cut off frequencies for the band pass butterworth filter [Hz]
-filter         = True      # If True, then a low-pass filtering is performed
-remove_median  = False     # If True, median over all channels is substracted to each channels (movement artefacts)
-
-[whitening]
-chunk_size     = 60        # Size of the data chunks [in s]
-safety_time    = 1         # Temporal zone around which templates are isolated [in ms]
-temporal       = False     # Perform temporal whitening
-spatial        = True      # Perform spatial whitening
-max_elts       = 50000     # Max number of events per electrode (should be compatible with nb_elts)
-nb_elts        = 1       # Fraction of max_elts that should be obtained per electrode [0-1]
-output_dim     = 5         # Can be in percent of variance explain, or num of dimensions for PCA on waveforms
-
-[clustering]
-extraction     = median-raw # Can be either median-raw (default), median-pca, mean-pca, mean-raw, or quadratic
-safety_space   = True       # If True, we exclude spikes in the vicinity of a selected spikes
-safety_time    = 1          # Temporal zone around which templates are isolated [in ms]
-max_elts       = 50000      # Max number of events per electrode (should be compatible with nb_elts)
-nb_elts        = 1         # Fraction of max_elts that should be obtained per electrode [0-1]
-nclus_min      = 0.002      # Min number of elements in a cluster (given in percentage)
-max_clusters   = 10         # Maximal number of clusters for every electrodes
-nb_repeats     = 3          # Number of passes used for the clustering
-make_plots     = png          # Generate sanity plots of the clustering
-sim_same_elec  = 3          # Distance within clusters under which they are re-merged
-cc_merge       = 1      # If CC between two templates is higher, they are merged
-dispersion     = (5, 5)     # Min and Max dispersion allowed for amplitudes [in MAD]
-smart_search   = True       # Parameter to activate the smart search mode
-smart_select   = False      # Experimental: activate the smart selection of centroids (max_clusters is ignored)
-noise_thr      = 0.8        # Minimal amplitudes are such than amp*min(templates) < noise_thr*threshold
-remove_mixture = True       # At the end of the clustering, we remove mixtures of templates
-cc_mixtures    = 0.75       # If CC between a sum of two templates and a template is higher, it is removed
-
-[fitting]
-chunk          = 1         # Size of chunks used during fitting [in second]
-gpu_only       = True      # Use GPU for computation of b's AND fitting
-amp_limits     = (0.3, 30) # Amplitudes for the templates during spike detection
-amp_auto       = True      # True if amplitudes are adjusted automatically for every templates
-max_chunk      = inf       # Fit only up to max_chunk
-collect_all    = False      # If True, one garbage template per electrode is created, to store unfitted spikes
-
-[merging]
-cc_overlap     = 0.75      # Only templates with CC higher than cc_overlap may be merged
-cc_bin         = 1         # Bin size for computing CC [in ms]
-correct_lag    = False     # If spikes are aligned when merging. May be better for phy usage
-auto_mode      = 0         # If >0, merging will be automatic (see doc, 0.1 is a good value)
-
-[converting]
-erase_all      = True      # If False, a prompt will ask you to export if export has already been done
-sparse_export  = False     # If True, data for phy are exported in a sparse format. Need recent version of phy
-export_pcs     = prompt    # Can be prompt [default] or in none, all, some
-export_all     = False     # If True, unfitted spikes will be exported as the last Ne templates
-
-[extracting]
-safety_time    = 1         # Temporal zone around which spikes are isolated [in ms]
-max_elts       = 10000     # Max number of events per templates (should be compatible with nb_elts)
-nb_elts        = 0.8       # Fraction of max_elts that should be obtained per electrode [0-1]
-output_dim     = 5         # Percentage of variance explained while performing PCA
-cc_merge       = 0.975     # If CC between two templates is higher, they are merged
-noise_thr      = 0.8       # Minimal amplitudes are such than amp*min(templates) < noise_thr*threshold
-
-[validating]
-nearest_elec   = auto      # Validation channel (e.g. electrode closest to the ground truth cell)
-max_iter       = 200       # Maximum number of iterations of the stochastic gradient descent (SGD)
-learning_rate  = 1.0e-3    # Initial learning rate which controls the step-size of the SGD
-roc_sampling   = 10        # Number of points to estimate the ROC curve of the BEER estimate
-test_size      = 0.3       # Portion of the dataset to include in the test split
-radius_factor  = 0.5       # Radius factor to modulate physical radius during validation
-juxta_dtype    = uint16    # Type of the juxtacellular data
-juxta_thresh   = 6         # Threshold for juxtacellular detection
-juxta_valley   = False     # True if juxta-cellular spikes are negative peaks
-juxta_spikes   =           # If none, spikes are automatically detected based on juxta_thresh
-filter         = True      # If the juxta channel need to be filtered or not
-make_plots     = png       # Generate sanity plots of the validation [Nothing or None if no plots]
-
-[noedits]
-filter_done    = True              #!! AUTOMATICALLY EDITED: DO NOT MODIFY !!

+ 0 - 12
DataScripts/SpykingCircus.prb

@@ -1,12 +0,0 @@
-total_nb_channels = 1
-radius            = 100
-
-channel_groups = {
-    1: {
-        'channels': list(range(1)),
-        'graph' : [],
-        'geometry': {
-            0:  [  0.0 ,   0.0],
-        }
-    }
-}