Skip to content

Instantly share code, notes, and snippets.


Srinivas Gorur-Shandilya sg-s

View GitHub Profile
sg-s /
Last active Jun 11, 2021
Spike sorting Review

Spike sorting packages

Name Platform Notes
kilosort MATLAB + drift correction, GPU
  1. mountainsort
  2. wave_clus wavelets + super-paramagnetic clustering
sg-s /
Last active Jun 14, 2021
Developing packages in Julia

What you want to do:

  • Write a package in Julia and develop it with the ultimate goal of releasing it for others to use

How to do it

  1. Open Julia
  2. Install PkgTemplates using using Pkg; Pkg.add("PkgTemplates")
  3. using PkgTemplates
  4. Create a template using your git user name: t = Template(user="sg-s")
sg-s /
Last active Apr 23, 2021
Github with more than one person

You submitted a patch to someone else's repository, and now you want your fork to sync with their repo

  1. Clone your fork (if you haven't already)
  2. git remote add upstream git://
  3. git fetch upstream
  4. git pull upstream master

Someone else has opened a PR on your repo, and you want to check that their code works before merging

View Data logging in

A common problem in software development and research is the "do-something"-"save data" loop. Often we are saving structured data over and over again, and this document looks at the fastest way to do this.

Solutions I will not consider

Writing each chunk of data to its own file

I will not consider this because:

  1. how do we combine these files later? This just kicks the can down the road
sg-s /
Last active Feb 10, 2021
Extremely basic MATLAB crash course

How to make a vector

a = [1; 2; 3]
a = [1, 2, 3] % avoid
a = zeros(10,1)
a = ones(10,1)
a = NaN(10,1)
a = linspace(0,1,10)
a = logspace(-1,1,10)
sg-s /
Last active May 28, 2020
Falsehoods I beleived about real data, and the price I paid for it

The data exists

If data is split across multiple files that are sequentially numbered, then it is foolish to beleive that every file exists. Some files can go missing, or be corrupted.

Files with the same name and the same size contain the same data

I learnt the hard way that one version can be corrupted, and the other version is fine, and it's all too easy to replace to good version with the corrupted version

View DNS servers
Alternate DNS
BlockAid Public DNS (or PeerDNS)
sg-s /
Created Sep 29, 2016
A note on saving data in MATLAB

The problem

We want to save data as it is generated, and to save it as a .mat file. Since every trial can be of a different length, a simple matrix will not suffice.

We have the following two options:

cell_data.x{1} = randn(1e4,1);
cell_data.y{1} = randn(1e4,1);
sg-s /
Last active Mar 30, 2021
Automatic version numbers of your git repository using git hooks

Put this in a file called pre-commit in .git/hooks/

# To enable this hook, rename this file to "pre-commit".

git log master --pretty=oneline | wc -l > build_number
git add build_number
sg-s /
Last active Aug 29, 2015
One line frozen noise generator in MATLAB

sets the randsom stream to a particular state. (1984 because this is the most True state). Make sure you run this before every invocation of rand:

>> RandStream.setGlobalStream(RandStream('mt19937ar','Seed',1984)); 
>> rand(3)
ans =