In [1]:
import pandas as pd

Repository and Data Access

  1. Fork my github repository

  2. Clone the forked repository to a local directory

  3. Install miniconda (or anaconda) if it isn't already installed. Type into bash:

    wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    bash miniconda.sh -b -p $HOME/miniconda
    export PATH="$HOME/miniconda/bin:$PATH"
    hash -r
    
  4. Switch to the development branch. Type into bash:

    git checkout develop
    
  5. Go to the local repository (.../Jadhav-2016-Data-Analysis) and install the anaconda environment for the repository. Type into bash:

    conda update -q conda
    conda info -a
    conda env create -f environment.yml
    source activate Jadhav-2016-Data-Analysis
    python setup.py develop
    
  6. Make sure the environment is set up correctly by running the tests. Type into bash:

    pytest
    
  7. Copy the data folders HPa_direct, HPb_direct, HPc_direct from the dropbox folder EastWestSideHippos Team Folder/HCPFCdata to Jadhav-2016-Data-Analysis/Raw-Data

Accessing the Data via Python

Parameters Module

The src.parameters module has some convenient constants for accessing the data. Most important are the ANIMALS dictionary, the N_DAYS, and the SAMPLING_FREQUENCY.

The ANIMALS dictionary maps the animal name to the data directory containing the animal's data.


In [2]:
from src.parameters import ANIMALS

ANIMALS


Out[2]:
{'HPa': Animal(short_name='HPa', directory='HPa_direct'),
 'HPb': Animal(short_name='HPb', directory='HPb_direct'),
 'HPc': Animal(short_name='HPc', directory='HPc_direct')}

N_DAYS corresponds to the number of days of recording and SAMPLING_FREQUENCY corresponds to the sampling rate of the tetrodes recording neural activity


In [3]:
from src.parameters import N_DAYS, SAMPLING_FREQUENCY

print('Days: {0}'.format(N_DAYS))
print('Sampling Frequency: {0}'.format(SAMPLING_FREQUENCY))


Days: 8
Sampling Frequency: 1500

Data Processing Module

The src.data_processing module has convenient functions for importing the data files into Pandas dataframes. You can use these functions in conjunction with the constants from the src.parameters module. The most useful functions are:

  • make_epochs_dataframe: returns descriptive information about each epoch
  • make_tetrode_dataframe: returns descriptive information about each tetrode
  • make_neuron_dataframe: returns descriptive information about each neuron
  • get_spike_indicator_dataframe: returns the spiking data for each neuron for each time point
  • get_interpolated_position_dataframe: returns data about the position of animal for each time point

Let's take each of these functions in turn.

make_epochs_dataframe

An epoch is a single recording session. There are typically multiple recording sessions (epochs) a day. The epoch dataframe gives information about what task the animal is performing during the epoch (sleeping, running a linear track, running a w-track, resting, etc). Each row of the epoch dataframe corresponds to an epoch.


In [4]:
from src.data_processing import make_epochs_dataframe

days = range(1, N_DAYS + 1)
epoch_info = make_epochs_dataframe(ANIMALS, days)
epoch_info


Out[4]:
animal day epoch environment type
animal day epoch
HPa 1 1 HPa 1 1 presleep sleep
2 HPa 1 2 lin run
3 HPa 1 3 NaN rest
4 HPa 1 4 wtr1 run
5 HPa 1 5 NaN rest
6 HPa 1 6 wtr1 run
7 HPa 1 7 postsleep sleep
2 1 HPa 2 1 presleep sleep
2 HPa 2 2 wtr1 run
3 HPa 2 3 NaN rest
4 HPa 2 4 wtr1 run
5 HPa 2 5 postsleep sleep
3 1 HPa 3 1 presleep sleep
2 HPa 3 2 wtr1 run
3 HPa 3 3 NaN rest
4 HPa 3 4 wtr1 run
5 HPa 3 5 postsleep sleep
4 1 HPa 4 1 presleep sleep
2 HPa 4 2 wtr1 run
3 HPa 4 3 NaN rest
4 HPa 4 4 wtr1 run
5 HPa 4 5 postsleep sleep
5 1 HPa 5 1 presleep sleep
2 HPa 5 2 wtr1 run
3 HPa 5 3 NaN rest
4 HPa 5 4 wtr1 run
5 HPa 5 5 postsleep sleep
6 1 HPa 6 1 presleep sleep
2 HPa 6 2 wtr1 run
3 HPa 6 3 NaN rest
... ... ... ... ... ... ... ...
HPc 3 1 HPc 3 1 presleep sleep
2 HPc 3 2 wtr1 run
3 HPc 3 3 NaN rest
4 HPc 3 4 wtr1 run
5 HPc 3 5 postsleep sleep
4 1 HPc 4 1 presleep sleep
2 HPc 4 2 wtr1 run
3 HPc 4 3 NaN rest
4 HPc 4 4 wtr1 run
5 HPc 4 5 postsleep sleep
5 1 HPc 5 1 presleep sleep
2 HPc 5 2 wtr1 run
3 HPc 5 3 NaN rest
4 HPc 5 4 wtr1 run
5 HPc 5 5 postsleep sleep
6 1 HPc 6 1 presleep sleep
2 HPc 6 2 wtr1 run
3 HPc 6 3 NaN rest
4 HPc 6 4 wtr2 run
5 HPc 6 5 postsleep sleep
7 1 HPc 7 1 presleep sleep
2 HPc 7 2 wtr1 run
3 HPc 7 3 NaN rest
4 HPc 7 4 wtr2 run
5 HPc 7 5 postsleep sleep
8 1 HPc 8 1 presleep sleep
2 HPc 8 2 wtr1 run
3 HPc 8 3 NaN rest
4 HPc 8 4 wtr2 run
5 HPc 8 5 postsleep sleep

126 rows × 5 columns

Often we use the epoch as a key to access more information about that epoch (information about the tetrodes, neuron, etc). Epoch keys are tuples with the following format: (Animal, Day, Epoch).

The index of the epoch dataframe can be used to produce these keys.


In [5]:
epoch_info.index.tolist()


Out[5]:
[('HPa', 1, 1),
 ('HPa', 1, 2),
 ('HPa', 1, 3),
 ('HPa', 1, 4),
 ('HPa', 1, 5),
 ('HPa', 1, 6),
 ('HPa', 1, 7),
 ('HPa', 2, 1),
 ('HPa', 2, 2),
 ('HPa', 2, 3),
 ('HPa', 2, 4),
 ('HPa', 2, 5),
 ('HPa', 3, 1),
 ('HPa', 3, 2),
 ('HPa', 3, 3),
 ('HPa', 3, 4),
 ('HPa', 3, 5),
 ('HPa', 4, 1),
 ('HPa', 4, 2),
 ('HPa', 4, 3),
 ('HPa', 4, 4),
 ('HPa', 4, 5),
 ('HPa', 5, 1),
 ('HPa', 5, 2),
 ('HPa', 5, 3),
 ('HPa', 5, 4),
 ('HPa', 5, 5),
 ('HPa', 6, 1),
 ('HPa', 6, 2),
 ('HPa', 6, 3),
 ('HPa', 6, 4),
 ('HPa', 6, 5),
 ('HPa', 7, 1),
 ('HPa', 7, 2),
 ('HPa', 7, 3),
 ('HPa', 7, 4),
 ('HPa', 7, 5),
 ('HPa', 8, 1),
 ('HPa', 8, 2),
 ('HPa', 8, 3),
 ('HPa', 8, 4),
 ('HPa', 8, 5),
 ('HPb', 1, 1),
 ('HPb', 1, 2),
 ('HPb', 1, 3),
 ('HPb', 1, 4),
 ('HPb', 1, 5),
 ('HPb', 1, 6),
 ('HPb', 1, 7),
 ('HPb', 2, 1),
 ('HPb', 2, 2),
 ('HPb', 2, 3),
 ('HPb', 2, 4),
 ('HPb', 2, 5),
 ('HPb', 3, 1),
 ('HPb', 3, 2),
 ('HPb', 3, 3),
 ('HPb', 3, 4),
 ('HPb', 3, 5),
 ('HPb', 4, 1),
 ('HPb', 4, 2),
 ('HPb', 4, 3),
 ('HPb', 4, 4),
 ('HPb', 4, 5),
 ('HPb', 5, 1),
 ('HPb', 5, 2),
 ('HPb', 5, 3),
 ('HPb', 5, 4),
 ('HPb', 5, 5),
 ('HPb', 6, 1),
 ('HPb', 6, 2),
 ('HPb', 6, 3),
 ('HPb', 6, 4),
 ('HPb', 6, 5),
 ('HPb', 7, 1),
 ('HPb', 7, 2),
 ('HPb', 7, 3),
 ('HPb', 7, 4),
 ('HPb', 7, 5),
 ('HPb', 8, 1),
 ('HPb', 8, 2),
 ('HPb', 8, 3),
 ('HPb', 8, 4),
 ('HPb', 8, 5),
 ('HPc', 1, 1),
 ('HPc', 1, 2),
 ('HPc', 1, 3),
 ('HPc', 1, 4),
 ('HPc', 1, 5),
 ('HPc', 1, 6),
 ('HPc', 1, 7),
 ('HPc', 2, 1),
 ('HPc', 2, 2),
 ('HPc', 2, 3),
 ('HPc', 2, 4),
 ('HPc', 2, 5),
 ('HPc', 3, 1),
 ('HPc', 3, 2),
 ('HPc', 3, 3),
 ('HPc', 3, 4),
 ('HPc', 3, 5),
 ('HPc', 4, 1),
 ('HPc', 4, 2),
 ('HPc', 4, 3),
 ('HPc', 4, 4),
 ('HPc', 4, 5),
 ('HPc', 5, 1),
 ('HPc', 5, 2),
 ('HPc', 5, 3),
 ('HPc', 5, 4),
 ('HPc', 5, 5),
 ('HPc', 6, 1),
 ('HPc', 6, 2),
 ('HPc', 6, 3),
 ('HPc', 6, 4),
 ('HPc', 6, 5),
 ('HPc', 7, 1),
 ('HPc', 7, 2),
 ('HPc', 7, 3),
 ('HPc', 7, 4),
 ('HPc', 7, 5),
 ('HPc', 8, 1),
 ('HPc', 8, 2),
 ('HPc', 8, 3),
 ('HPc', 8, 4),
 ('HPc', 8, 5)]

This is useful if we want to filter the epoch dataframe by a particular attribute (Say we only want sessions where the animal is asleep) and use the keys to access the data for that epoch.


In [6]:
epoch_info.loc[epoch_info.type == 'run']


Out[6]:
animal day epoch environment type
animal day epoch
HPa 1 2 HPa 1 2 lin run
4 HPa 1 4 wtr1 run
6 HPa 1 6 wtr1 run
2 2 HPa 2 2 wtr1 run
4 HPa 2 4 wtr1 run
3 2 HPa 3 2 wtr1 run
4 HPa 3 4 wtr1 run
4 2 HPa 4 2 wtr1 run
4 HPa 4 4 wtr1 run
5 2 HPa 5 2 wtr1 run
4 HPa 5 4 wtr1 run
6 2 HPa 6 2 wtr1 run
4 HPa 6 4 wtr2 run
7 2 HPa 7 2 wtr1 run
4 HPa 7 4 wtr2 run
8 2 HPa 8 2 wtr1 run
4 HPa 8 4 wtr2 run
HPb 1 2 HPb 1 2 lin run
4 HPb 1 4 wtr1 run
6 HPb 1 6 wtr1 run
2 2 HPb 2 2 wtr1 run
4 HPb 2 4 wtr1 run
3 2 HPb 3 2 wtr1 run
4 HPb 3 4 wtr1 run
4 2 HPb 4 2 wtr1 run
4 HPb 4 4 wtr1 run
5 2 HPb 5 2 wtr1 run
4 HPb 5 4 wtr1 run
6 2 HPb 6 2 wtr1 run
4 HPb 6 4 wtr2 run
7 2 HPb 7 2 wtr1 run
4 HPb 7 4 wtr2 run
8 2 HPb 8 2 wtr1 run
4 HPb 8 4 wtr2 run
HPc 1 2 HPc 1 2 lin run
4 HPc 1 4 wtr1 run
6 HPc 1 6 wtr1 run
2 2 HPc 2 2 wtr1 run
4 HPc 2 4 wtr1 run
3 2 HPc 3 2 wtr1 run
4 HPc 3 4 wtr1 run
4 2 HPc 4 2 wtr1 run
4 HPc 4 4 wtr1 run
5 2 HPc 5 2 wtr1 run
4 HPc 5 4 wtr1 run
6 2 HPc 6 2 wtr1 run
4 HPc 6 4 wtr2 run
7 2 HPc 7 2 wtr1 run
4 HPc 7 4 wtr2 run
8 2 HPc 8 2 wtr1 run
4 HPc 8 4 wtr2 run

In [7]:
epoch_info.loc[epoch_info.type == 'run'].index.tolist()


Out[7]:
[('HPa', 1, 2),
 ('HPa', 1, 4),
 ('HPa', 1, 6),
 ('HPa', 2, 2),
 ('HPa', 2, 4),
 ('HPa', 3, 2),
 ('HPa', 3, 4),
 ('HPa', 4, 2),
 ('HPa', 4, 4),
 ('HPa', 5, 2),
 ('HPa', 5, 4),
 ('HPa', 6, 2),
 ('HPa', 6, 4),
 ('HPa', 7, 2),
 ('HPa', 7, 4),
 ('HPa', 8, 2),
 ('HPa', 8, 4),
 ('HPb', 1, 2),
 ('HPb', 1, 4),
 ('HPb', 1, 6),
 ('HPb', 2, 2),
 ('HPb', 2, 4),
 ('HPb', 3, 2),
 ('HPb', 3, 4),
 ('HPb', 4, 2),
 ('HPb', 4, 4),
 ('HPb', 5, 2),
 ('HPb', 5, 4),
 ('HPb', 6, 2),
 ('HPb', 6, 4),
 ('HPb', 7, 2),
 ('HPb', 7, 4),
 ('HPb', 8, 2),
 ('HPb', 8, 4),
 ('HPc', 1, 2),
 ('HPc', 1, 4),
 ('HPc', 1, 6),
 ('HPc', 2, 2),
 ('HPc', 2, 4),
 ('HPc', 3, 2),
 ('HPc', 3, 4),
 ('HPc', 4, 2),
 ('HPc', 4, 4),
 ('HPc', 5, 2),
 ('HPc', 5, 4),
 ('HPc', 6, 2),
 ('HPc', 6, 4),
 ('HPc', 7, 2),
 ('HPc', 7, 4),
 ('HPc', 8, 2),
 ('HPc', 8, 4)]

make_tetrode_dataframe

make_tetrode_dataframe is a dictionary of pandas dataframes, where the keys corresponds to an epoch and the values are pandas dataframes detailing information about the tetrodes in that epoch (brain area, number of cells recorded, etc.).

The dictionary keys for the epochs are tuples (Animal, Day, Epoch). For example, let's load the tetrode dataframe and display all the keys:


In [8]:
from src.data_processing import make_tetrode_dataframe

tetrode_info = make_tetrode_dataframe(ANIMALS)
list(tetrode_info.keys())


Out[8]:
[('HPa', 2, 1),
 ('HPa', 8, 2),
 ('HPa', 7, 5),
 ('HPb', 6, 4),
 ('HPb', 6, 2),
 ('HPa', 2, 2),
 ('HPa', 8, 3),
 ('HPa', 7, 4),
 ('HPc', 2, 4),
 ('HPb', 1, 2),
 ('HPa', 2, 3),
 ('HPb', 3, 4),
 ('HPc', 2, 5),
 ('HPa', 2, 4),
 ('HPa', 8, 1),
 ('HPa', 5, 5),
 ('HPa', 2, 5),
 ('HPb', 3, 2),
 ('HPa', 5, 4),
 ('HPc', 4, 4),
 ('HPb', 7, 2),
 ('HPb', 3, 3),
 ('HPc', 4, 5),
 ('HPa', 8, 4),
 ('HPb', 7, 5),
 ('HPa', 3, 5),
 ('HPa', 8, 5),
 ('HPb', 5, 4),
 ('HPa', 5, 1),
 ('HPa', 3, 4),
 ('HPb', 7, 4),
 ('HPa', 3, 3),
 ('HPc', 3, 1),
 ('HPb', 8, 4),
 ('HPa', 5, 3),
 ('HPc', 4, 1),
 ('HPa', 7, 2),
 ('HPb', 5, 1),
 ('HPb', 5, 3),
 ('HPa', 5, 2),
 ('HPa', 3, 1),
 ('HPb', 6, 1),
 ('HPb', 4, 2),
 ('HPc', 3, 3),
 ('HPc', 4, 3),
 ('HPc', 3, 2),
 ('HPb', 8, 3),
 ('HPc', 3, 5),
 ('HPb', 5, 5),
 ('HPb', 8, 2),
 ('HPb', 2, 5),
 ('HPc', 3, 4),
 ('HPb', 8, 1),
 ('HPb', 2, 4),
 ('HPc', 6, 4),
 ('HPc', 8, 2),
 ('HPb', 2, 2),
 ('HPc', 6, 5),
 ('HPb', 4, 5),
 ('HPa', 6, 4),
 ('HPc', 6, 2),
 ('HPb', 4, 4),
 ('HPa', 6, 5),
 ('HPc', 5, 3),
 ('HPb', 8, 5),
 ('HPc', 6, 3),
 ('HPb', 4, 3),
 ('HPc', 5, 2),
 ('HPb', 3, 5),
 ('HPb', 2, 3),
 ('HPb', 1, 4),
 ('HPc', 5, 1),
 ('HPc', 6, 1),
 ('HPb', 4, 1),
 ('HPb', 7, 1),
 ('HPa', 1, 1),
 ('HPa', 6, 1),
 ('HPa', 3, 2),
 ('HPb', 6, 3),
 ('HPb', 3, 1),
 ('HPa', 6, 2),
 ('HPb', 1, 3),
 ('HPa', 1, 3),
 ('HPa', 6, 3),
 ('HPc', 5, 5),
 ('HPa', 1, 2),
 ('HPb', 5, 2),
 ('HPc', 5, 4),
 ('HPb', 7, 3),
 ('HPa', 1, 5),
 ('HPb', 1, 5),
 ('HPa', 1, 4),
 ('HPc', 7, 5),
 ('HPa', 1, 7),
 ('HPa', 4, 4),
 ('HPc', 7, 4),
 ('HPc', 1, 7),
 ('HPa', 1, 6),
 ('HPa', 4, 5),
 ('HPb', 1, 6),
 ('HPc', 1, 6),
 ('HPa', 4, 2),
 ('HPb', 1, 7),
 ('HPc', 1, 5),
 ('HPa', 7, 3),
 ('HPa', 4, 3),
 ('HPc', 7, 1),
 ('HPc', 1, 4),
 ('HPc', 8, 1),
 ('HPc', 2, 2),
 ('HPb', 1, 1),
 ('HPc', 1, 3),
 ('HPa', 7, 1),
 ('HPc', 2, 3),
 ('HPa', 4, 1),
 ('HPc', 7, 3),
 ('HPc', 1, 2),
 ('HPc', 8, 3),
 ('HPc', 4, 2),
 ('HPc', 7, 2),
 ('HPc', 1, 1),
 ('HPb', 2, 1),
 ('HPc', 8, 4),
 ('HPc', 2, 1),
 ('HPc', 8, 5),
 ('HPb', 6, 5)]

If we want to access a particular epoch we can just pass the corresponding epoch tuple. In this case, we want animal HPa, day 6, epoch 2. This returns a dataframe where each row corresponds to a tetrode for that epoch.


In [9]:
epoch_key = ('HPa', 6, 2)
tetrode_info[epoch_key]


Out[9]:
area depth descrip numcells animal day epoch tetrode_number tetrode_id
animal day epoch tetrode_number
HPa 6 2 1 CA1 114 riptet 7 HPa 6 2 1 HPa621
2 CA1 121 NaN 0 HPa 6 2 2 HPa622
3 CA1 90 CA1Ref 0 HPa 6 2 3 HPa623
4 CA1 117 riptet 8 HPa 6 2 4 HPa624
5 CA1 117 riptet 5 HPa 6 2 5 HPa625
6 CA1 110 riptet 0 HPa 6 2 6 HPa626
7 CA1 114 riptet 0 HPa 6 2 7 HPa627
8 iCA1 114 riptet 1 HPa 6 2 8 HPa628
9 iCA1 101 riptet 1 HPa 6 2 9 HPa629
10 iCA1 98 NaN 1 HPa 6 2 10 HPa6210
11 iCA1 108 riptet 1 HPa 6 2 11 HPa6211
12 iCA1 116 riptet 1 HPa 6 2 12 HPa6212
13 iCA1 120 NaN 0 HPa 6 2 13 HPa6213
14 iCA1 105 riptet 1 HPa 6 2 14 HPa6214
15 PFC 120 NaN 0 HPa 6 2 15 HPa6215
16 PFC 123 NaN 0 HPa 6 2 16 HPa6216
17 PFC 123 NaN 1 HPa 6 2 17 HPa6217
18 PFC 112 NaN 1 HPa 6 2 18 HPa6218
19 PFC 130 NaN 0 HPa 6 2 19 HPa6219
20 PFC 109 NaN 0 HPa 6 2 20 HPa6220

Remember that the epoch dataframe index can be used as keys, which can be useful if we want to access a particular epoch.


In [10]:
[tetrode_info[epoch_key]
 for epoch_key in epoch_info.loc[
     (epoch_info.type == 'sleep') & (epoch_info.day == 8)].index]


Out[10]:
[                                 area  depth descrip  numcells animal  day  \
 animal day epoch tetrode_number                                              
 HPa    8   1     1                CA1    113  riptet        12    HPa    8   
                  2                CA1    121     NaN         0    HPa    8   
                  3                CA1     90  CA1Ref         0    HPa    8   
                  4                CA1    116  riptet        15    HPa    8   
                  5                CA1    116  riptet         0    HPa    8   
                  6                CA1    110  riptet         0    HPa    8   
                  7                CA1    114  riptet         0    HPa    8   
                  8               iCA1    114  riptet         0    HPa    8   
                  9               iCA1    100  riptet         0    HPa    8   
                  10              iCA1     96     NaN         0    HPa    8   
                  11              iCA1    106  riptet         0    HPa    8   
                  12              iCA1    114  riptet         3    HPa    8   
                  13              iCA1    120     NaN         0    HPa    8   
                  14              iCA1    105  riptet         6    HPa    8   
                  15               PFC     93     NaN         1    HPa    8   
                  16               PFC     90     NaN         0    HPa    8   
                  17               PFC     90     NaN         6    HPa    8   
                  18               PFC     90     NaN         0    HPa    8   
                  19               PFC    130     NaN         0    HPa    8   
                  20               PFC    109     NaN         0    HPa    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPa    8   1     1                   1               1     HPa811  
                  2                   1               2     HPa812  
                  3                   1               3     HPa813  
                  4                   1               4     HPa814  
                  5                   1               5     HPa815  
                  6                   1               6     HPa816  
                  7                   1               7     HPa817  
                  8                   1               8     HPa818  
                  9                   1               9     HPa819  
                  10                  1              10    HPa8110  
                  11                  1              11    HPa8111  
                  12                  1              12    HPa8112  
                  13                  1              13    HPa8113  
                  14                  1              14    HPa8114  
                  15                  1              15    HPa8115  
                  16                  1              16    HPa8116  
                  17                  1              17    HPa8117  
                  18                  1              18    HPa8118  
                  19                  1              19    HPa8119  
                  20                  1              20    HPa8120  ,
                                  area  depth descrip  numcells animal  day  \
 animal day epoch tetrode_number                                              
 HPa    8   5     1                CA1    113  riptet        12    HPa    8   
                  2                CA1    121     NaN         0    HPa    8   
                  3                CA1     90  CA1Ref         0    HPa    8   
                  4                CA1    116  riptet        15    HPa    8   
                  5                CA1    116  riptet         0    HPa    8   
                  6                CA1    110  riptet         0    HPa    8   
                  7                CA1    114  riptet         0    HPa    8   
                  8               iCA1    114  riptet         0    HPa    8   
                  9               iCA1    100  riptet         0    HPa    8   
                  10              iCA1     96     NaN         0    HPa    8   
                  11              iCA1    106  riptet         0    HPa    8   
                  12              iCA1    114  riptet         3    HPa    8   
                  13              iCA1    120     NaN         0    HPa    8   
                  14              iCA1    105  riptet         6    HPa    8   
                  15               PFC     93     NaN         1    HPa    8   
                  16               PFC     90     NaN         0    HPa    8   
                  17               PFC     90     NaN         6    HPa    8   
                  18               PFC     90     NaN         0    HPa    8   
                  19               PFC    130     NaN         0    HPa    8   
                  20               PFC    109     NaN         0    HPa    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPa    8   5     1                   5               1     HPa851  
                  2                   5               2     HPa852  
                  3                   5               3     HPa853  
                  4                   5               4     HPa854  
                  5                   5               5     HPa855  
                  6                   5               6     HPa856  
                  7                   5               7     HPa857  
                  8                   5               8     HPa858  
                  9                   5               9     HPa859  
                  10                  5              10    HPa8510  
                  11                  5              11    HPa8511  
                  12                  5              12    HPa8512  
                  13                  5              13    HPa8513  
                  14                  5              14    HPa8514  
                  15                  5              15    HPa8515  
                  16                  5              16    HPa8516  
                  17                  5              17    HPa8517  
                  18                  5              18    HPa8518  
                  19                  5              19    HPa8519  
                  20                  5              20    HPa8520  ,
                                  area  depth  descrip  numcells animal  day  \
 animal day epoch tetrode_number                                               
 HPb    8   1     1                CA1     85   riptet         2    HPb    8   
                  2                CA1     61      NaN         0    HPb    8   
                  3                CA1     69   riptet         2    HPb    8   
                  4                CA1     74   riptet         8    HPb    8   
                  5                CA1    102   riptet         0    HPb    8   
                  6                CA1     67   riptet         0    HPb    8   
                  7                CA1     90   CA1Ref         0    HPb    8   
                  8                PFC    131      NaN         2    HPb    8   
                  9                PFC     98      NaN         1    HPb    8   
                  10               PFC     72      NaN         7    HPb    8   
                  11               PFC     66      NaN         0    HPb    8   
                  12               PFC     84      NaN         1    HPb    8   
                  13               PFC     60   PFCRef         0    HPb    8   
                  14               PFC     99      NaN         3    HPb    8   
                  15              iCA1     96  iCA1Ref         0    HPb    8   
                  16              iCA1    113   riptet         0    HPb    8   
                  17              iCA1    121   riptet         0    HPb    8   
                  18              iCA1    113   riptet         3    HPb    8   
                  19              iCA1    123      NaN         0    HPb    8   
                  20              iCA1    133   riptet         1    HPb    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPb    8   1     1                   1               1     HPb811  
                  2                   1               2     HPb812  
                  3                   1               3     HPb813  
                  4                   1               4     HPb814  
                  5                   1               5     HPb815  
                  6                   1               6     HPb816  
                  7                   1               7     HPb817  
                  8                   1               8     HPb818  
                  9                   1               9     HPb819  
                  10                  1              10    HPb8110  
                  11                  1              11    HPb8111  
                  12                  1              12    HPb8112  
                  13                  1              13    HPb8113  
                  14                  1              14    HPb8114  
                  15                  1              15    HPb8115  
                  16                  1              16    HPb8116  
                  17                  1              17    HPb8117  
                  18                  1              18    HPb8118  
                  19                  1              19    HPb8119  
                  20                  1              20    HPb8120  ,
                                  area  depth  descrip  numcells animal  day  \
 animal day epoch tetrode_number                                               
 HPb    8   5     1                CA1     85   riptet         2    HPb    8   
                  2                CA1     61      NaN         0    HPb    8   
                  3                CA1     69   riptet         2    HPb    8   
                  4                CA1     74   riptet         8    HPb    8   
                  5                CA1    102   riptet         0    HPb    8   
                  6                CA1     67   riptet         0    HPb    8   
                  7                CA1     90   CA1Ref         0    HPb    8   
                  8                PFC    131      NaN         2    HPb    8   
                  9                PFC     98      NaN         0    HPb    8   
                  10               PFC     72      NaN         7    HPb    8   
                  11               PFC     66      NaN         0    HPb    8   
                  12               PFC     84      NaN         1    HPb    8   
                  13               PFC     60   PFCRef         0    HPb    8   
                  14               PFC     99      NaN         3    HPb    8   
                  15              iCA1     96  iCA1Ref         0    HPb    8   
                  16              iCA1    113   riptet         0    HPb    8   
                  17              iCA1    121   riptet         0    HPb    8   
                  18              iCA1    113   riptet         3    HPb    8   
                  19              iCA1    123      NaN         0    HPb    8   
                  20              iCA1    133   riptet         0    HPb    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPb    8   5     1                   5               1     HPb851  
                  2                   5               2     HPb852  
                  3                   5               3     HPb853  
                  4                   5               4     HPb854  
                  5                   5               5     HPb855  
                  6                   5               6     HPb856  
                  7                   5               7     HPb857  
                  8                   5               8     HPb858  
                  9                   5               9     HPb859  
                  10                  5              10    HPb8510  
                  11                  5              11    HPb8511  
                  12                  5              12    HPb8512  
                  13                  5              13    HPb8513  
                  14                  5              14    HPb8514  
                  15                  5              15    HPb8515  
                  16                  5              16    HPb8516  
                  17                  5              17    HPb8517  
                  18                  5              18    HPb8518  
                  19                  5              19    HPb8519  
                  20                  5              20    HPb8520  ,
                                 area  depth descrip  numcells animal  day  \
 animal day epoch tetrode_number                                             
 HPc    8   1     1               CA1    108  riptet         0    HPc    8   
                  2               CA1    100  riptet         1    HPc    8   
                  3               CA1     91  riptet         5    HPc    8   
                  4               CA1    104  riptet         0    HPc    8   
                  5               CA1     96  riptet         0    HPc    8   
                  6               CA1    106  riptet         3    HPc    8   
                  7               CA1     84  CA1Ref         0    HPc    8   
                  8               PFC     65     NaN         0    HPc    8   
                  9               PFC     60     NaN         0    HPc    8   
                  10              PFC     57     NaN         0    HPc    8   
                  11              PFC     98     NaN         0    HPc    8   
                  12              PFC    102     NaN         0    HPc    8   
                  13              PFC     45  PFCRef         0    HPc    8   
                  14              PFC     66     NaN         0    HPc    8   
                  15              PFC     71     NaN         7    HPc    8   
                  16              PFC    104     NaN         1    HPc    8   
                  17              Ctx    282  CtxRef         0    HPc    8   
                  18              Ctx    315     NaN         0    HPc    8   
                  19              Ctx    318     NaN         0    HPc    8   
                  20              Ctx    300     NaN         0    HPc    8   
                  21              Ctx    196     NaN         0    HPc    8   
                  22              Ctx      0     NaN         0    HPc    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPc    8   1     1                   1               1     HPc811  
                  2                   1               2     HPc812  
                  3                   1               3     HPc813  
                  4                   1               4     HPc814  
                  5                   1               5     HPc815  
                  6                   1               6     HPc816  
                  7                   1               7     HPc817  
                  8                   1               8     HPc818  
                  9                   1               9     HPc819  
                  10                  1              10    HPc8110  
                  11                  1              11    HPc8111  
                  12                  1              12    HPc8112  
                  13                  1              13    HPc8113  
                  14                  1              14    HPc8114  
                  15                  1              15    HPc8115  
                  16                  1              16    HPc8116  
                  17                  1              17    HPc8117  
                  18                  1              18    HPc8118  
                  19                  1              19    HPc8119  
                  20                  1              20    HPc8120  
                  21                  1              21    HPc8121  
                  22                  1              22    HPc8122  ,
                                 area  depth descrip  numcells animal  day  \
 animal day epoch tetrode_number                                             
 HPc    8   5     1               CA1    108  riptet         0    HPc    8   
                  2               CA1    100  riptet         1    HPc    8   
                  3               CA1     91  riptet         5    HPc    8   
                  4               CA1    104  riptet         0    HPc    8   
                  5               CA1     96  riptet         0    HPc    8   
                  6               CA1    106  riptet         3    HPc    8   
                  7               CA1     84  CA1Ref         0    HPc    8   
                  8               PFC     65     NaN         0    HPc    8   
                  9               PFC     60     NaN         0    HPc    8   
                  10              PFC     57     NaN         0    HPc    8   
                  11              PFC     98     NaN         0    HPc    8   
                  12              PFC    102     NaN         0    HPc    8   
                  13              PFC     45  PFCRef         0    HPc    8   
                  14              PFC     66     NaN         0    HPc    8   
                  15              PFC     71     NaN         7    HPc    8   
                  16              PFC    104     NaN         1    HPc    8   
                  17              Ctx    282  CtxRef         0    HPc    8   
                  18              Ctx    315     NaN         0    HPc    8   
                  19              Ctx    318     NaN         0    HPc    8   
                  20              Ctx    300     NaN         0    HPc    8   
                  21              Ctx    196     NaN         0    HPc    8   
                  22              Ctx      0     NaN         0    HPc    8   
 
                                  epoch  tetrode_number tetrode_id  
 animal day epoch tetrode_number                                    
 HPc    8   5     1                   5               1     HPc851  
                  2                   5               2     HPc852  
                  3                   5               3     HPc853  
                  4                   5               4     HPc854  
                  5                   5               5     HPc855  
                  6                   5               6     HPc856  
                  7                   5               7     HPc857  
                  8                   5               8     HPc858  
                  9                   5               9     HPc859  
                  10                  5              10    HPc8510  
                  11                  5              11    HPc8511  
                  12                  5              12    HPc8512  
                  13                  5              13    HPc8513  
                  14                  5              14    HPc8514  
                  15                  5              15    HPc8515  
                  16                  5              16    HPc8516  
                  17                  5              17    HPc8517  
                  18                  5              18    HPc8518  
                  19                  5              19    HPc8519  
                  20                  5              20    HPc8520  
                  21                  5              21    HPc8521  
                  22                  5              22    HPc8522  ]

make_neuron_dataframe

The neuron dataframe is set up similarly to the tetrode dataframe. It is a dictionary of pandas dataframes, where the keys are the epoch tuples (Animal, Day, Epoch) and the values are the pandas dataframes. The dataframes give descriptive information about the number of spikes, the average spiking rate, which brain area, etc.


In [11]:
from src.data_processing import make_neuron_dataframe
neuron_info = make_neuron_dataframe(ANIMALS)

list(neuron_info.keys())


Out[11]:
[('HPa', 2, 1),
 ('HPa', 8, 2),
 ('HPa', 7, 5),
 ('HPb', 6, 4),
 ('HPb', 6, 2),
 ('HPa', 2, 2),
 ('HPa', 8, 3),
 ('HPa', 7, 4),
 ('HPc', 2, 4),
 ('HPb', 1, 2),
 ('HPa', 2, 3),
 ('HPb', 3, 4),
 ('HPc', 2, 5),
 ('HPa', 2, 4),
 ('HPa', 8, 1),
 ('HPa', 5, 5),
 ('HPa', 2, 5),
 ('HPb', 3, 2),
 ('HPa', 5, 4),
 ('HPc', 4, 4),
 ('HPa', 2, 6),
 ('HPb', 3, 3),
 ('HPc', 4, 5),
 ('HPa', 2, 7),
 ('HPa', 8, 4),
 ('HPb', 7, 5),
 ('HPb', 7, 2),
 ('HPa', 3, 5),
 ('HPa', 8, 5),
 ('HPb', 5, 4),
 ('HPa', 5, 1),
 ('HPa', 3, 4),
 ('HPb', 7, 4),
 ('HPa', 3, 3),
 ('HPc', 3, 1),
 ('HPb', 8, 4),
 ('HPa', 5, 3),
 ('HPc', 4, 1),
 ('HPa', 7, 2),
 ('HPb', 5, 1),
 ('HPb', 5, 3),
 ('HPa', 5, 2),
 ('HPa', 3, 1),
 ('HPb', 6, 1),
 ('HPb', 4, 2),
 ('HPc', 3, 3),
 ('HPc', 4, 3),
 ('HPc', 3, 2),
 ('HPb', 8, 3),
 ('HPc', 3, 5),
 ('HPb', 5, 5),
 ('HPb', 8, 2),
 ('HPb', 2, 5),
 ('HPc', 3, 4),
 ('HPb', 8, 1),
 ('HPb', 2, 4),
 ('HPc', 6, 4),
 ('HPc', 8, 2),
 ('HPb', 2, 2),
 ('HPc', 6, 5),
 ('HPb', 4, 5),
 ('HPa', 6, 4),
 ('HPc', 6, 2),
 ('HPb', 4, 4),
 ('HPa', 6, 5),
 ('HPc', 5, 3),
 ('HPb', 8, 5),
 ('HPc', 6, 3),
 ('HPb', 4, 3),
 ('HPc', 5, 2),
 ('HPb', 3, 5),
 ('HPb', 2, 3),
 ('HPb', 1, 4),
 ('HPc', 5, 1),
 ('HPc', 6, 1),
 ('HPb', 4, 1),
 ('HPb', 7, 1),
 ('HPa', 1, 1),
 ('HPa', 6, 1),
 ('HPa', 3, 2),
 ('HPb', 6, 3),
 ('HPb', 3, 1),
 ('HPa', 6, 2),
 ('HPb', 1, 3),
 ('HPa', 1, 3),
 ('HPa', 6, 3),
 ('HPc', 5, 5),
 ('HPa', 1, 2),
 ('HPb', 5, 2),
 ('HPc', 5, 4),
 ('HPb', 7, 3),
 ('HPa', 1, 5),
 ('HPb', 1, 5),
 ('HPa', 1, 4),
 ('HPc', 7, 5),
 ('HPa', 1, 7),
 ('HPa', 4, 4),
 ('HPc', 7, 4),
 ('HPc', 1, 7),
 ('HPa', 1, 6),
 ('HPa', 4, 5),
 ('HPb', 1, 6),
 ('HPc', 1, 6),
 ('HPa', 4, 2),
 ('HPb', 1, 7),
 ('HPc', 1, 5),
 ('HPa', 7, 3),
 ('HPa', 4, 3),
 ('HPc', 7, 1),
 ('HPc', 1, 4),
 ('HPc', 8, 1),
 ('HPc', 2, 2),
 ('HPb', 1, 1),
 ('HPc', 1, 3),
 ('HPa', 7, 1),
 ('HPc', 2, 3),
 ('HPa', 4, 1),
 ('HPc', 7, 3),
 ('HPc', 1, 2),
 ('HPc', 8, 3),
 ('HPc', 4, 2),
 ('HPc', 7, 2),
 ('HPc', 1, 1),
 ('HPb', 2, 1),
 ('HPc', 8, 4),
 ('HPc', 2, 1),
 ('HPc', 8, 5),
 ('HPb', 6, 5)]

We can access the neuron dataframe for a particular epoch in the same way as the tetrodes


In [12]:
epoch_key = ('HPa', 6, 2)
neuron_info[epoch_key]


Out[12]:
area csi meanrate neuron_number numspikes propbursts spikewidth tetrode_number animal day epoch neuron_id
animal day epoch tetrode_number neuron_number
HPa 6 2 1 1 CA1 0.004048582995951417 0.4099585062240664 1 494 0.02834008097165992 11.638994636104313 1 HPa 6 2 HPa6211
2 CA1 0.11722488038277512 0.34688796680497924 2 418 0.4090909090909091 12.0074641798351 1 HPa 6 2 HPa6212
3 CA1 0.04294478527607362 0.4058091286307054 3 489 0.20245398773006135 9.818915554815934 1 HPa 6 2 HPa6213
4 CA1 0.10416666666666667 0.15933609958506223 4 192 0.4270833333333333 9.136247973738753 1 HPa 6 2 HPa6214
5 CA1 0.09194977843426884 2.2473029045643154 5 2708 0.33899556868537667 11.291874042349674 1 HPa 6 2 HPa6215
6 CA1 0.09351432880844646 0.5502074688796681 6 663 0.3257918552036199 9.665083455651253 1 HPa 6 2 HPa6216
4 1 CA1 0.20634920634920634 0.15684647302904564 1 189 0.6666666666666666 8.197871324149913 4 HPa 6 2 HPa6241
2 CA1 0.08823529411764706 0.11286307053941909 2 136 0.3897058823529412 9.155198352025812 4 HPa 6 2 HPa6242
3 CA1 0.023166023166023165 0.2149377593360996 3 259 0.0888030888030888 9.871494807397777 4 HPa 6 2 HPa6243
4 CA1 0.15186028853454822 1.0929460580912862 4 1317 0.4510250569476082 9.432374135235689 4 HPa 6 2 HPa6244
5 CA1 0.15492957746478872 0.23568464730290456 5 284 0.5211267605633803 9.741539046552957 4 HPa 6 2 HPa6245
6 CA1 0.04779411764705882 0.45145228215767635 6 544 0.11764705882352941 11.103046308020144 4 HPa 6 2 HPa6246
7 NaN NaN NaN 7 NaN NaN NaN 4 HPa 6 2 HPa6247
8 NaN NaN NaN 8 NaN NaN NaN 4 HPa 6 2 HPa6248
5 1 CA1 0.26758409785932724 0.5427385892116182 1 654 0.7691131498470948 8.12454996691276 5 HPa 6 2 HPa6251
2 CA1 0.09761824890976183 2.473858921161826 2 2981 0.33814156323381417 9.22819963534934 5 HPa 6 2 HPa6252
3 NaN NaN NaN 3 NaN NaN NaN 5 HPa 6 2 HPa6253
4 CA1 0.1951219512195122 0.5443983402489626 4 656 0.600609756097561 10.408533181462253 5 HPa 6 2 HPa6254
5 CA1 0.06997929606625258 2.004149377593361 5 2415 0.27701863354037265 9.628117714100009 5 HPa 6 2 HPa6255
8 1 iCA1 0.04825737265415549 0.3095435684647303 1 373 0.17158176943699732 11.028880358555128 8 HPa 6 2 HPa6281
9 1 iCA1 0.08766233766233766 0.5112033195020746 1 616 0.31655844155844154 13.288148027690363 9 HPa 6 2 HPa6291
10 1 iCA1 0.06779661016949153 0.2937759336099585 1 354 0.23728813559322035 11.26401493403312 10 HPa 6 2 HPa62101
11 1 iCA1 0.1391057487579844 1.1692946058091287 1 1409 0.47764371894960966 10.202388012245862 11 HPa 6 2 HPa62111
12 1 iCA1 0.03225806451612903 0.3087136929460581 1 372 0.12365591397849462 10.944528891560092 12 HPa 6 2 HPa62121
14 1 iCA1 0.08710801393728224 0.23817427385892115 1 287 0.26480836236933797 10.001442777092178 14 HPa 6 2 HPa62141
17 1 PFC 0.20539862821742016 56.261410788381745 1 67795 0.6073456744597684 4.94589895880427 17 HPa 6 2 HPa62171
18 1 PFC 0.006277463904582548 1.3219917012448132 1 1593 0.03327055869428751 11.816300042092637 18 HPa 6 2 HPa62181

get_spike_indicator_dataframe

The spike indicator dataframe is a dataframe where each row corresponds to the recording timestamp and is_spike is an indicator function where 1 indicates a spike has occurred at that timestamp and 0 indicates no spike has occurred at that timestamp. We can access the spike indicator dataframe for a particular neuron by using the neuron key (Animal, Day, Epoch, Tetrode, Neuron).


In [13]:
from src.data_processing import get_spike_indicator_dataframe

neuron_key = ('HPa', 6, 2, 1, 4)
get_spike_indicator_dataframe(neuron_key, ANIMALS)


Out[13]:
is_spike
time
4122.992000 0
4122.992667 0
4122.993333 0
4122.994000 0
4122.994667 0
4122.995333 0
4122.996000 0
4122.996667 0
4122.997333 0
4122.998000 0
4122.998667 0
4122.999333 0
4123.000000 0
4123.000667 0
4123.001333 0
4123.002000 0
4123.002667 0
4123.003333 0
4123.004000 0
4123.004667 0
4123.005333 0
4123.006000 0
4123.006667 0
4123.007333 0
4123.008000 0
4123.008667 0
4123.009333 0
4123.010000 0
4123.010667 0
4123.011333 0
... ...
5327.999333 0
5328.000000 0
5328.000667 0
5328.001333 0
5328.002000 0
5328.002667 0
5328.003333 0
5328.004000 0
5328.004667 0
5328.005333 0
5328.006000 0
5328.006667 0
5328.007333 0
5328.008000 0
5328.008667 0
5328.009333 0
5328.010000 0
5328.010667 0
5328.011333 0
5328.012000 0
5328.012667 0
5328.013333 0
5328.014000 0
5328.014667 0
5328.015333 0
5328.016000 0
5328.016667 0
5328.017333 0
5328.018000 0
5328.018667 0

1807541 rows × 1 columns

This information can be obtained from the neuron dataframe. The index of the neuron dataframe gives the key.


In [14]:
neuron_info[epoch_key].index.tolist()


Out[14]:
[('HPa', 6, 2, 1, 1),
 ('HPa', 6, 2, 1, 2),
 ('HPa', 6, 2, 1, 3),
 ('HPa', 6, 2, 1, 4),
 ('HPa', 6, 2, 1, 5),
 ('HPa', 6, 2, 1, 6),
 ('HPa', 6, 2, 4, 1),
 ('HPa', 6, 2, 4, 2),
 ('HPa', 6, 2, 4, 3),
 ('HPa', 6, 2, 4, 4),
 ('HPa', 6, 2, 4, 5),
 ('HPa', 6, 2, 4, 6),
 ('HPa', 6, 2, 4, 7),
 ('HPa', 6, 2, 4, 8),
 ('HPa', 6, 2, 5, 1),
 ('HPa', 6, 2, 5, 2),
 ('HPa', 6, 2, 5, 3),
 ('HPa', 6, 2, 5, 4),
 ('HPa', 6, 2, 5, 5),
 ('HPa', 6, 2, 8, 1),
 ('HPa', 6, 2, 9, 1),
 ('HPa', 6, 2, 10, 1),
 ('HPa', 6, 2, 11, 1),
 ('HPa', 6, 2, 12, 1),
 ('HPa', 6, 2, 14, 1),
 ('HPa', 6, 2, 17, 1),
 ('HPa', 6, 2, 18, 1)]

Like the epoch and tetrode dataframe, this allows us to filter for certain attributes (like if we want neurons in a certain brain area) and select only those neurons. For example, if we want only CA1 neurons:


In [15]:
neuron_info[epoch_key].query('area == "CA1"')


Out[15]:
area csi meanrate neuron_number numspikes propbursts spikewidth tetrode_number animal day epoch neuron_id
animal day epoch tetrode_number neuron_number
HPa 6 2 1 1 CA1 0.004048582995951417 0.4099585062240664 1 494 0.02834008097165992 11.638994636104313 1 HPa 6 2 HPa6211
2 CA1 0.11722488038277512 0.34688796680497924 2 418 0.4090909090909091 12.0074641798351 1 HPa 6 2 HPa6212
3 CA1 0.04294478527607362 0.4058091286307054 3 489 0.20245398773006135 9.818915554815934 1 HPa 6 2 HPa6213
4 CA1 0.10416666666666667 0.15933609958506223 4 192 0.4270833333333333 9.136247973738753 1 HPa 6 2 HPa6214
5 CA1 0.09194977843426884 2.2473029045643154 5 2708 0.33899556868537667 11.291874042349674 1 HPa 6 2 HPa6215
6 CA1 0.09351432880844646 0.5502074688796681 6 663 0.3257918552036199 9.665083455651253 1 HPa 6 2 HPa6216
4 1 CA1 0.20634920634920634 0.15684647302904564 1 189 0.6666666666666666 8.197871324149913 4 HPa 6 2 HPa6241
2 CA1 0.08823529411764706 0.11286307053941909 2 136 0.3897058823529412 9.155198352025812 4 HPa 6 2 HPa6242
3 CA1 0.023166023166023165 0.2149377593360996 3 259 0.0888030888030888 9.871494807397777 4 HPa 6 2 HPa6243
4 CA1 0.15186028853454822 1.0929460580912862 4 1317 0.4510250569476082 9.432374135235689 4 HPa 6 2 HPa6244
5 CA1 0.15492957746478872 0.23568464730290456 5 284 0.5211267605633803 9.741539046552957 4 HPa 6 2 HPa6245
6 CA1 0.04779411764705882 0.45145228215767635 6 544 0.11764705882352941 11.103046308020144 4 HPa 6 2 HPa6246
5 1 CA1 0.26758409785932724 0.5427385892116182 1 654 0.7691131498470948 8.12454996691276 5 HPa 6 2 HPa6251
2 CA1 0.09761824890976183 2.473858921161826 2 2981 0.33814156323381417 9.22819963534934 5 HPa 6 2 HPa6252
4 CA1 0.1951219512195122 0.5443983402489626 4 656 0.600609756097561 10.408533181462253 5 HPa 6 2 HPa6254
5 CA1 0.06997929606625258 2.004149377593361 5 2415 0.27701863354037265 9.628117714100009 5 HPa 6 2 HPa6255

We can get the keys for CA1 neurons only:


In [16]:
neuron_info[epoch_key].query('area == "CA1"').index.tolist()


Out[16]:
[('HPa', 6, 2, 1, 1),
 ('HPa', 6, 2, 1, 2),
 ('HPa', 6, 2, 1, 3),
 ('HPa', 6, 2, 1, 4),
 ('HPa', 6, 2, 1, 5),
 ('HPa', 6, 2, 1, 6),
 ('HPa', 6, 2, 4, 1),
 ('HPa', 6, 2, 4, 2),
 ('HPa', 6, 2, 4, 3),
 ('HPa', 6, 2, 4, 4),
 ('HPa', 6, 2, 4, 5),
 ('HPa', 6, 2, 4, 6),
 ('HPa', 6, 2, 5, 1),
 ('HPa', 6, 2, 5, 2),
 ('HPa', 6, 2, 5, 4),
 ('HPa', 6, 2, 5, 5)]

And then get the spike indicator data for those neurons:


In [17]:
pd.concat(
    [get_spike_indicator_dataframe(neuron_key, ANIMALS)
     for neuron_key in neuron_info[epoch_key].query('area == "CA1"').index], axis=1)


Out[17]:
is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike is_spike
time
4122.992000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.992667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.993333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.994000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.994667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.995333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.996000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.996667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.997333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.998000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.998667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4122.999333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.000667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.001333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.002000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.002667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.003333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.004000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.004667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.005333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.006000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.006667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.007333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.008000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.008667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.009333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.010000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.010667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4123.011333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
5327.999333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.000667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.001333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.002000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.002667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.003333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.004000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.004667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.005333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.006000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.006667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.007333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.008000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.008667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.009333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.010000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.010667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.011333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.012000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.012667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.013333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.014000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.014667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.015333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.016000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.016667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.017333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.018000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5328.018667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1807541 rows × 16 columns

If we want the numpy array, use .values


In [18]:
pd.concat(
    [get_spike_indicator_dataframe(neuron_key, ANIMALS)
     for neuron_key in neuron_info[epoch_key].query('area == "CA1"').index], axis=1).values


Out[18]:
array([[0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       ..., 
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]])

get_interpolated_position_dataframe

This dataframe gives information about the animal's position during an epoch. Like the tetrode and neuron dataframes, it is a dictionary of dataframes where the keys correspond to the epoch (Animal, Day, Epoch).


In [19]:
from src.data_processing import get_interpolated_position_dataframe

epoch_key = ('HPa', 6, 2)
get_interpolated_position_dataframe(epoch_key, ANIMALS)


Out[19]:
trajectory_category_ind trajectory_direction trajectory_turn trial_number linear_distance x_position y_position head_direction speed linear_position
time
4122.992000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.992667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.993333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.994000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.994667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.995333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.996000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.996667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.997333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.998000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.998667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4122.999333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.000000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.000667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.001333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.002000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.002667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.003333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.004000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.004667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.005333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.006000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.006667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.007333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.008000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.008667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.009333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.010000 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.010667 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
4123.011333 2.0 Inbound Right 1.0 3.954611 87.594914 95.793044 -1.662769 28.374497 -4.247499
... ... ... ... ... ... ... ... ... ... ...
5327.999333 1.0 Outbound Left 412.0 187.225243 60.205982 99.478092 0.771869 8.113508 -187.161663
5328.000000 1.0 Outbound Left 412.0 187.225597 60.219687 99.473423 0.772012 8.116933 -187.161965
5328.000667 1.0 Outbound Left 412.0 187.225952 60.233464 99.468748 0.772156 8.120359 -187.162268
5328.001333 1.0 Outbound Left 412.0 187.226307 60.247314 99.464069 0.772299 8.123787 -187.162571
5328.002000 1.0 Outbound Left 412.0 187.226661 60.261236 99.459385 0.772442 8.127215 -187.162874
5328.002667 1.0 Outbound Left 412.0 187.227016 60.275231 99.454696 0.772586 8.130644 -187.163177
5328.003333 1.0 Outbound Left 412.0 187.227371 60.289298 99.450002 0.772729 8.134074 -187.163480
5328.004000 1.0 Outbound Left 412.0 187.227727 60.303438 99.445304 0.772873 8.137505 -187.163783
5328.004667 1.0 Outbound Left 412.0 187.228082 60.317652 99.440600 0.773016 8.140937 -187.164086
5328.005333 1.0 Outbound Left 412.0 187.228437 60.331938 99.435892 0.773160 8.144370 -187.164390
5328.006000 1.0 Outbound Left 412.0 187.228793 60.346297 99.431179 0.773303 8.147804 -187.164693
5328.006667 1.0 Outbound Left 412.0 187.229148 60.360729 99.426461 0.773447 8.151239 -187.164997
5328.007333 1.0 Outbound Left 412.0 187.229504 60.375235 99.421738 0.773590 8.154674 -187.165300
5328.008000 1.0 Outbound Left 412.0 187.229860 60.389814 99.417010 0.773734 8.158111 -187.165604
5328.008667 1.0 Outbound Left 412.0 187.230216 60.404466 99.412277 0.773878 8.161549 -187.165908
5328.009333 1.0 Outbound Left 412.0 187.230572 60.419193 99.407540 0.774021 8.164988 -187.166212
5328.010000 1.0 Outbound Left 412.0 187.230928 60.433992 99.402797 0.774165 8.168427 -187.166516
5328.010667 1.0 Outbound Left 412.0 187.231284 60.448866 99.398050 0.774309 8.171868 -187.166820
5328.011333 1.0 Outbound Left 412.0 187.231640 60.463813 99.393298 0.774453 8.175309 -187.167124
5328.012000 1.0 Outbound Left 412.0 187.231997 60.478835 99.388541 0.774597 8.178752 -187.167429
5328.012667 1.0 Outbound Left 412.0 187.232353 60.493930 99.383780 0.774740 8.182195 -187.167733
5328.013333 1.0 Outbound Left 412.0 187.232710 60.509100 99.379013 0.774884 8.185640 -187.168038
5328.014000 1.0 Outbound Left 412.0 187.233067 60.524344 99.374241 0.775028 8.189085 -187.168342
5328.014667 1.0 Outbound Left 412.0 187.233423 60.539662 99.369465 0.775172 8.192531 -187.168647
5328.015333 1.0 Outbound Left 412.0 187.233780 60.555055 99.364684 0.775316 8.195979 -187.168951
5328.016000 1.0 Outbound Left 412.0 187.234137 60.570522 99.359898 0.775460 8.199427 -187.169256
5328.016667 1.0 Outbound Left 412.0 187.234495 60.586064 99.355106 0.775604 8.202876 -187.169561
5328.017333 1.0 Outbound Left 412.0 187.234852 60.601681 99.350311 0.775748 8.206326 -187.169866
5328.018000 1.0 Outbound Left 412.0 187.235209 60.617373 99.345510 0.775892 8.209777 -187.170171
5328.018667 1.0 Outbound Left 412.0 187.235567 60.633139 99.340704 0.776036 8.213229 -187.170477

1807541 rows × 10 columns