Skip to content

Instantly share code, notes, and snippets.

@edeno
Last active August 26, 2019 14:32
Show Gist options
  • Save edeno/46fbb6ad0e51d2418adfeceb3a3e9388 to your computer and use it in GitHub Desktop.
Save edeno/46fbb6ad0e51d2418adfeceb3a3e9388 to your computer and use it in GitHub Desktop.
Get interpolated data from loren frank data
from loren_frank_data_processing import get_trial_time, get_interpolated_position_dataframe, make_neuron_dataframe
import pandas as pd
import numpy as np
epoch_key = ('HPa', 3, 2)
# Get time of epoch from first LFP
SAMPLING_FREQUENCY = 500 # samples per second
time = get_trial_time(epoch_key, ANIMALS)
time = (pd.Series(np.ones_like(time, dtype=np.float), index=time)
.resample('2ms').mean() # resample to 2 ms aka 500 samples / second
.index)
# `get_interpolated_position_dataframe` takes a function for determining the timing
def _time_function(*args, **kwargs):
return time
# Get the position, speed, velocity, etc
position_info = (
get_interpolated_position_dataframe(
epoch_key, ANIMALS, _time_function, spacing=30)
.dropna(subset=['linear_distance', 'linear_speed']))
# Get the neurons based on the `neuron_info` dataframe
neuron_info = neuron_info.loc[
(neuron_info.numspikes > 100)]
# Get the spikes from the neuron_info dataframe keys and reindex it to the same
# time as the position info to make sure they match.
spikes = get_all_spike_indicators(
neuron_info.index, ANIMALS, _time_function).reindex(time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment