Skip to content

Instantly share code, notes, and snippets.

View alexbw's full-sized avatar

Alex Wiltschko alexbw

  • Google
  • Boston, MA
View GitHub Profile
# A = model.trans_distn.A.copy()
labels_norep, _ = pymouse.get_norep(np.hstack(model.stateseqs))
A = build_frequentist_statemap(labels_norep)
import spectral_clustering.spclust as sp
labels_norep, _ = pymouse.get_norep(np.hstack(model.stateseqs))
used_labels = np.argwhere(np.bincount(labels_norep).astype('float32')/len(labels_norep) > 0.001).ravel()
A = A[np.ix_(used_labels,used_labels)]
@alexbw
alexbw / syllable_movies.py
Last active August 29, 2015 14:03
making movies
_,roi = get_behavior(store_name, experiments=list(train_experiments), array_names=["rect_ROI"])
roi = roi['rect_ROI']
height,width = roi[train_experiments[0]]
Parallel(n_jobs=24)(delayed(pymouse.show_syllable)(labels,
images, df,
height=height,
width=width,
which_syllable=which_syllable,
num_instances_to_grab=45,
desired_length=120) for which_syllable in np.unique(labels));
{
"metadata": {
"name": "",
"signature": "sha256:dcb810a9650e942e8d68b058fe09b2314ef7520b461f67c444bcfcab490b6cb0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-9d64abf5b3b8> in <module>()
11 kappa=kappa,
12 train_experiments=train_experiments,
---> 13 test_experiments=test_experiments)
/home/dattalab/Code/pymouse/scripts/train_model_generalAR.py in hmm(out_file, params, store_name, train_experiments, test_experiments, datadimension, n_cpu, n_iter, max_frames_per_mouse, pca, use_ard, windowsize, featurefn, random_seed, model_dtype, **kwargs)
182 samples = []
183 for itr in progprint_xrange(n_iter):
@alexbw
alexbw / gist:9d4a9996de9277804ec1
Last active August 29, 2015 14:07
FTIR detection
{
"metadata": {
"name": "",
"signature": "sha256:afc374763139d59e6a602e272315fc2d86d189f993a55217eb7e9e6adf02a464"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@alexbw
alexbw / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
https://plus.google.com/hangouts/_/guoxccx7jaijdnbofw453tim2ia
function [tsOffsets, instantRate] = calcCrossCorrelogram(ts1, ts2, window)
% INPUT:
% ts1 - timestamp array, center of cross-correlogram
% ts2 - timestamp array
% window - the window of the timestamps to compute, e.g. [-0.1 0.1] for
% 0.1 seconds around each spike in ts1.
%
% OUTPUT:
% tsOffsets - the offsets from each spike in ts1 that has spikes nearby
% instantRate - 1/ISI of each spike in ts1 that has spikes nearby
// Setting up the Audio Session...
// Initialize and configure the audio session, and add an interuption listener
AudioSessionInitialize(NULL, NULL, sessionInterruptionListener, self);
UInt32 audioCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(audioCategory), &audioCategory);
// Allow iPod audio to continue to play while the app is active.
UInt32 flag = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(flag), &flag);