Skip to content

Instantly share code, notes, and snippets.

@kylerbrown
kylerbrown / firingrate.py
Created June 21, 2017 16:25
Compute average firing rate of a spike train over trials
def da_firing_rate(df, dt, duration, gaussian_std=None, center_time=True):
'''computes Dayan and Abbot average firing rate or <r>
df: pandas dataframe with a "start" column in seconds and a
"trial" column. Starts are relative to the start of a trial
dt: timestep for computing histogram
duration: length of a trial in seconds
gaussian_std: if None, no smoothing is applied. Units: seconds.
center_time: if True, the returned time vector is the same length as
the firing rate. Otherwise, the time vector is the bin edges,
which are useful for histogram style plots.
@kylerbrown
kylerbrown / warp.py
Last active November 21, 2016 20:27
Linear time warping functions for labeled acoustic data
import numpy as np
import pandas as pd
from scipy.signal import fftconvolve
def warp_path(fid, test, sampling_rate, insertgaps=True,
function=True, remove_fid_offset=True, invert=False):
"""
fid : fiducial (true) labels. A pandas dataset with fields 'start', 'stop', and 'label'.
test : like fid, labels to be warped
sampling_rate : sampling rate of returned warp path
@kylerbrown
kylerbrown / spectrogram.py
Last active January 7, 2019 08:14
Python code for creating zebra finch spectrograms
# Looking for a decent spectrogram? Check out resin.
#
# https://github.com/kylerbrown/resin
#
# Resin creates multi-taper spectrograms and spectral derivative spectrograms
#
# old code below...
import matplotlib.pyplot as plt
import matplotlib.cm as cm
@kylerbrown
kylerbrown / stim.sh
Created May 29, 2016 18:53
a script to use jstim for overnight acoustic stimulation experiments
#!/bin/bash
## stim.sh ##
# a script to use jstim for overnight stimulation experiments
# move to source directory
cd "$(dirname "$0")" || exit
d=$(date +%Y%m%d_%H%M%S)
@kylerbrown
kylerbrown / backup.sh
Created May 29, 2016 18:34
backup script for 24/7 Intan RHD recording
#!/bin/bash
## Rational ##
# A lot of data can be generated quickly with the Intan system. To keep the experimental computer
# from running out of space, the data should be regularly copied to a server and removed locally.
# This script does that safely by:
# 1) recursively copying all *.rhd files and deleting them after safe copy.
# 2) recursively copying everything else, but not deleting (saving notes and settings on the experimenal computer.
@kylerbrown
kylerbrown / complex_radar_plot.py
Last active May 2, 2024 12:07
Code for a complex radar plot
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns # improves plot aesthetics
def _invert(x, limits):
"""inverts a value x on a scale from
limits[0] to limits[1]"""
return limits[1] - (x - limits[0])
def _scale_data(data, ranges):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
# File originally created by Dan Meliza, modified by Kyler Brown
apt-get -y install make scons g++ gcc git libjack-dev jackd1 \
libboost-dev libboost-program-options-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev \
libsndfile1-dev libsamplerate0-dev libhdf5-dev hdf5-tools \
libx11-dev x11proto-core-dev libxft-dev libzmq-dev uuid-dev
# set some configuration for better RT performance
@kylerbrown
kylerbrown / ooplot.py
Last active June 20, 2020 19:12
A very rough sketch of a hdf5 acoustic data viewer.
"""an alpha version of the plotter"""
import signal
import sys
import pyqtgraph as pg
import pyqtgraph.dockarea as pgd
import h5py
import numpy as np
from PyQt4 import QtGui, QtCore
from PyQt4.phonon import Phonon
@kylerbrown
kylerbrown / raster.py
Last active October 14, 2016 04:19
Raster plot function for viewing event data, such as neural spikes.
import numpy as np
import matplotlib.pyplot as plt
def raster(event_times_list, **kwargs):
"""
Creates a raster plot
Parameters
----------