Skip to content

Instantly share code, notes, and snippets.

View edeno's full-sized avatar

Eric Denovellis edeno

View GitHub Profile
@edeno
edeno / get_interpolated_data.py
Last active August 26, 2019 14:32
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)
@edeno
edeno / blah.py
Last active September 24, 2018 18:15
Get position info interpolated to 1000 Hz
from loren_frank_data_processing import get_interpolated_position_dataframe, get_spike_indicator_dataframe
from src.parameters import ANIMALS
epoch_key = ('HPa', 6, 2)
def time_function(epoch_key, animals):
neuron_info = make_neuron_dataframe(ANIMALS).xs(epoch_key, drop_level=False)
neuron_key = neuron_info.index[0]
return get_spike_indicator_dataframe(neuron_key, ANIMALS).resample('1ms').index
@edeno
edeno / jspth.py
Created May 7, 2018 17:25
Joint Peristimulus Time Histogram in Python
def jspth(spikes1, spikes2):
'''Joint Peristimulus Time Histogram
Parameters
----------
spikes1, spikes2: ndarray, shape (n_time, n_trials)
Returns
-------
joint_histogram : ndarray, shape (n_time, n_time)
@edeno
edeno / occupancy_normalized_hexbin.py
Last active November 1, 2017 00:37
Occupancy normalized hexbin
def occupancy_normalized_hexbin(x, y, all_x, all_y, ax=None,
gridsize=(3, 3), **kwargs):
'''Bins (x, y) into hexagonal grid and normalizes the
count by the binned count of (all_x, all_y).
Useful when measuring the frequency of events over time
and space when the time spent in each bin is not equal.
Parameters
----------
@edeno
edeno / rate_adjustment.py
Last active October 12, 2017 17:32
Analytic spike-field and spike-spike coherence adjustment for conditions with different mean firing rates
def coherence_rate_adjustment(firing_rate_condition1,
firing_rate_condition2, spike_power_spectrum,
homogeneous_poisson_noise=0, dt=1):
'''Correction for the spike-field or spike-spike coherence when the
conditions have different firing rates.
When comparing the coherence of two conditions, a change in firing rate
results in a change in coherence without an increase in coupling.
This adjustment modifies the coherence of one of the conditions, so
that a difference in coherence between conditions indicates a change
@edeno
edeno / record_git_hash.py
Created February 8, 2017 20:14
Record the git hash of your current run for log files
from subprocess import PIPE, run
print(run(['git', 'rev-parse', 'HEAD'],
stdout=PIPE, universal_newlines=True).stdout)
@edeno
edeno / parSave.m
Last active November 16, 2018 03:21
Matlab wrapper function for save for use in parfor loops
% Wrapper function for save for use in parfor loops
% Based on http://www.mathworks.com/matlabcentral/answers/135285#answer_149537
% Handles save options such as -append
%
% Test Example 1
% a = 10;
% b = 'blah';
% c.test = 1;
% d = {'a'};
% e = [100 100];