Skip to content

Instantly share code, notes, and snippets.

View mattgaidica's full-sized avatar
💭
Spending most my time at https://github.com/Neurotech-Hub

Matt Gaidica, Ph.D. mattgaidica

💭
Spending most my time at https://github.com/Neurotech-Hub
View GitHub Profile
function p = prc(cols,rc)
% rc = desired [row,col] position of subplot
p = (rc(1) * cols) - (cols - rc(2));
rows = 3;
cols = 4;
figure;
for iRow = 1:rows
    for iCol = 1:cols
        subplot(rows,cols,prc(cols,[iRow iCol]));
        title(['Subplot ',num2str(prc(cols,[iRow iCol]))],'fontSize',14);
        text(0.5,0.5,[num2str(iRow),', ',num2str(iCol)],...
            'HorizontalAlignment','center','fontsize',14);
function colors = mycmap(filename,varargin)
% read image
A = imread(filename);
% set number of elements to return
n = size(A,2);
if ~isempty(varargin)
n = varargin{1};
end
function [idx, val] = closest(testArr,val)
tmp = abs(testArr - val);
[~, idx] = min(tmp);
val = testArr(idx);
>> ml = 1.3;
>> ap = -3.3;
>> dv = 7.5;
>> S = ratBrainAtlas(ml,ap,dv)
S =
struct with fields:
coronal: [1×1 struct]
sagittal: [1×1 struct]
horizontal: [1×1 struct]
function r = formatBytes(bytes)
s = {'B', 'KB', 'MB', 'GB', 'TB'};
e = floor(log(bytes)/log(1024));
r = sprintf(['%.2f ',s{e+1}], (bytes/(1024^floor(e))));
class Myapi < Sinatra::Application
ActiveRecord::Base.default_timezone = :utc
configure :development, :test do
set :host, 'localhost:9999'
set :force_ssl, false
end
configure :staging do
set :host, 'my-api-staging.herokuapp.com'
set :force_ssl, true
namespace :tddium do
desc "post_build_hook"
task :post_build_hook do
return unless ENV["TDDIUM_MODE"] == "ci"
return unless ENV["TDDIUM_BUILD_STATUS"] == "passed"
dir = File.expand_path("~/.heroku/")
heroku_email = ENV["HEROKU_EMAIL"]
heroku_api_key = ENV["HEROKU_API_KEY"]
current_branch = `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-`.strip
function d1new = equalVectors(d1,d2)
% d1new is the 'dimension' of d2
nd2 = numel(d2);
if isscalar(d2)
nd2 = d2;
end
d1new = interp1(1:numel(d1),d1,linspace(1,numel(d1),nd2));
@mattgaidica
mattgaidica / spikesorter.rb
Last active December 22, 2018 18:31
SpikeSorter API call in Ruby
require 'rubygems'
require 'spikesorter-sx3'
# Get your account sid and auth token from spikesorter.com
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = SpikeSorterSX3::REST::Client.new(account_sid, auth_token)
spikes = @client.spikes
.extract(