Skip to content

Instantly share code, notes, and snippets.

View npyoung's full-sized avatar

Noah Young npyoung

  • IndustrialNext
  • San Francisco
View GitHub Profile
@npyoung
npyoung / amzn_ami_py_conf.sh
Last active August 29, 2015 14:16
Scientific python2.7 install for Amazon Linux AMI
# update install packages
yum update -y
# install build tools
yum install make automake gcc gcc-c++ kernel-devel git-core -y
# install python 2.7 and change default python symlink
yum install python27-devel -y
rm /usr/bin/python
ln -s /usr/bin/python2.7 /usr/bin/python
@npyoung
npyoung / ratio_alternating.ijm
Last active August 29, 2015 14:21
ImageJ macros for processing ratiometric imaging movies with a static marker channel
Dialog.create("Process interleaved ratiometric movie");
Dialog.addString("Experiment name:", "expt");
Dialog.addNumber("Background", 1600)
Dialog.show()
expt_name = Dialog.getString();
background = Dialog.getNumber();
expt_dir = getDirectory("Choose a save directory");
id = getImageID();
@npyoung
npyoung / tiffstack2movie.py
Last active August 29, 2015 14:23
Compile a TIFF stack into a H.264 movie
#!/usr/bin/env python
import argparse, os
from libtiff import TIFF
import moviepy.editor as mpy
import numpy as np
from skimage.color import gray2rgb
if __name__ == '__main__':
ap = argparse.ArgumentParser()
ap.add_argument('input_stack', help="Path to a tiff stack file")
@npyoung
npyoung / pymba_demo.py
Last active August 25, 2022 11:06
Fast acquisition from a Vimba camera in Python
"""
This demonstration assumes you have already installed Pymba and followed the installation instructions there:
https://github.com/morefigs/pymba
MoviePy is used to save the frames to a video file for later viewing, while the frame's mean intensity is
printed in real time. MoviePy can be installed from pip nicely.
"""
import pymba
from moviepy.video.io.ffmpeg_writer import FFMPEG_VideoWriter as VidWriter
from skimage.color import gray2rgb
@npyoung
npyoung / dg4.py
Last active August 29, 2015 14:24
Control a DG-4 filter wheel over a serial port
from serial import Serial
from time import sleep
class DG4(object):
"""Control a Sutter Lambda DG-4 over serial interface"""
SWITCH_TO_SERIAL = 238 # switch the DG4 to serial mode, DG4 hangs until it receives the next serial command
FREEZE_DISPLAY = 218
TURN_DISPLAY_ON = 219
OPEN_SHUTTER = 170
ND_ADJ_MARKER = 171 # DATANUM = 171 MARKER BETWEEN 235 OR 236 IN N.D. ADJUST
def timeshuffle_bootstrap(dview, statistic, data, axis=-1, n_boot=1000):
"""Perform bootstrap resampling to assess the significance of a statistic by reshuffling in time.
Args:
dview: IPython client (i.e. dview = IPython.parallel.Client()[:]) for parallelization.
statistic: Function that takes the dataset and computes some statistic (or array of statistics).
data: Data from which the statistic is computed.
axis: Axis in the data the shuffle along (usually time).
"""
T = data.shape[axis]
@npyoung
npyoung / tdt2h5.py
Last active October 11, 2015 07:30
Convert a Tucker-Davis Technologies (TDT) to Neo's HDF5 format
from os.path import join as pjoin
from os.path import isdir
from os import listdir
from argparse import ArgumentParser
from neo.io import TdtIO, NeoHdf5IO
from progressbar import ProgressBar
if __name__ == '__main__':
parser = ArgumentParser(description="Convert a Tucker-Davis Technologies (TDT) to Neo's HDF5 format.")
@npyoung
npyoung / setup.sh
Last active June 9, 2016 03:12
Shell script for setting up a standard productivity environment for labwork on Ubuntu 14.04
sudo -i
apt-get update
apt-get upgrade -y
apt-get install htop git
apt-get install python-dev pkg-config build-essential libfreetype6-dev libpng-dev libatlas-base-dev
wget "https://bootstrap.pypa.io/get-pip.py" | python
rm "get-pip.py"
pip install numpy scipy matplotlib seaborn scikit-image jupyter ipyparallel ipywidgets libtiff s4cmd
@npyoung
npyoung / .gitattributes
Last active April 12, 2023 08:57
Files for making git repos handle IPython/Jupyter notebooks well
*.ipynb filter=stripoutput
@npyoung
npyoung / git-obliterate
Created July 20, 2016 19:32
The git-filter method of removing a file completely from git history. Remember to `git push --force` if the repo has a remote!
#!/usr/bin/env bash
FILEPATH=$@
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch $FILEPATH" --prune-empty --tag-name-filter cat -- --all