Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pickle
import numpy as np
import matplotlib.pyplot as plt
def plot_psth(spiketimes, bin_size, bin_range): # [spike times 1. trial, spike times 2. trial, ...]
#now lets calculate PSTH. simply put, it is calculating the average firing rate in each time bin
num_bins = int((bin_range[1]-bin_range[0])/bin_size)
spt_binned = np.zeros((num_bins, spiketimes.__len__()), np.int64)
for i in range(spiketimes.__len__()):
@hahahannes
hahahannes / example.py
Created November 23, 2018 09:53 — forked from diosmosis/example.py
Python decorator that catches exceptions and logs a traceback that includes every local variable of each frame.
import os
from log_exceptions import log_exceptions
def throw_something(a1, a2):
raise Exception('Whoops!')
@log_exceptions(log_if = os.getenv('MYAPP_DEBUG') is not None)
def my_function(arg1, arg2):
throw_something(arg1 + 24, arg2 - 24)