Skip to content

Commit

Permalink
Handle case where spike times exceed the trial time given
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Oct 24, 2018
1 parent 10298e8 commit 6b7163d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions loren_frank_data_processing/neurons.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ def get_all_spike_indicators(neuron_keys, animals,
time = time_function(neuron_keys[0][:3], animals)
spikes_dfs = [get_spikes_dataframe(neuron_key, animals)
for neuron_key in neuron_keys]
return pd.concat(
(spikes_df
.groupby(time[np.digitize(spikes_df.index.total_seconds(),
time.total_seconds())]).sum()
.reindex(index=time, fill_value=0)
for spikes_df in spikes_dfs), axis=1)
n_time = time.size
for ind, spikes_df in enumerate(spikes_dfs):
spike_time_ind = np.digitize(
spikes_df.index.total_seconds(), time.total_seconds())
spike_time_ind = spike_time_ind[spike_time_ind < n_time]
spikes_dfs[ind] = (spikes_df
.iloc[spike_time_ind < n_time]
.groupby(time[spike_time_ind]).sum()
.reindex(index=time, fill_value=0))

return pd.concat(spikes_dfs, axis=1)


def convert_neuron_epoch_to_dataframe(tetrodes_in_epoch, animal, day,
Expand Down

0 comments on commit 6b7163d

Please sign in to comment.