Skip to content

Instantly share code, notes, and snippets.

View JimHokanson's full-sized avatar

Jim Hokanson JimHokanson

View GitHub Profile
@JimHokanson
JimHokanson / createCleanPreNormData
Last active August 29, 2015 14:12
This is an attempt to create pre data that we can then use to write our normalization procedure in python. It takes the parsing output from our example video just before it goes to the normalization process. The goal is then to create a single file which we can load in Python.
function createCleanPreNormData()
%
% NOTE: We're starting with temporary files that were created by
% running the MRC GUI on a video
%
% This function should take the awkward file structures and output:
% - contours, non-normalized, oriented from head to tail
% - ??? a single contour with indices
% - left and right contours???
% - in real units
@JimHokanson
JimHokanson / python_windows_notes
Created June 27, 2015 16:39
Python Windows Notes
Anaconda
- https://store.continuum.io/cshop/anaconda/
- version? - uninstall program - shows version 1.9.0
conda update scipy
Wheel files:
Where is Python?????
@JimHokanson
JimHokanson / load_data_test_v2.py
Created June 25, 2013 06:15
Rough version of FTP calls for retrieving tracker data. Need to add on saving code and check possible change to change directory call.
try:
import cPickle as pickle
except:
import pickle
from ftplib import FTP
import re
import time #For modification time parsing
#For later
@JimHokanson
JimHokanson / deference_hdf5
Created September 3, 2013 06:34
A simple example trying to walk through dereferencing of a Matlab structure array in Python
#ViewWormMovement
import matplotlib.pyplot as plt
import h5py
file_path = u'F:/worm_data/segworm_data/features/798 JU258 on food R_2010_11_25__16_34_17___1___9_features.mat'
h = h5py.File(file_path, 'r')
#dv - Distance Value
@JimHokanson
JimHokanson / plotWormMovement.py
Last active December 22, 2015 05:39
Simple script to plot worm movement. A move to using an animation module would probably be more appropriate.
import matplotlib.pyplot as plt
import h5py
import numpy as np
#SPEED_UP = 4
#DT = 0.05
file_path = u'F:/worm_data/segworm_data/features/798 JU258 on food R_2010_11_25__16_34_17___1___9_features.mat'
h = h5py.File(file_path, 'r')
@JimHokanson
JimHokanson / matlab_to_python.md
Last active March 1, 2016 22:41
Transititioning from Matlab to Python

Transitioning to Python from Matlab

Indexing vs Calling

In Matlab, there is not distinction between indexing and calling. Both are accomplished with parentheses.

a = 1:5
b = a(2:3) %indexing
@JimHokanson
JimHokanson / jsmn_mex.c
Created March 18, 2016 02:23
Return output of jsmn json tokenizer to Matlab via mex
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "matrix.h"
#include "mex.h"
#include "jsmn.h"
// mex jsmn_mex.c jsmn.c
@JimHokanson
JimHokanson / mexSetField.c
Last active August 1, 2016 01:37
set field name of a Matlab structure using an arbitrary field name
#include "mex.h"
/*
*
* mex setField.c
* s = struct;
* wtf = setField(s,'wtf batman',5);
*
* %Override test
* wtf = setField(wtf,'wtf batman',1);
@JimHokanson
JimHokanson / What.txt
Created October 6, 2016 01:59
Calling back to Matlab with pressed keyboard button - see what.txt
This code listens for keys that have been pressed and calls a Matlab callback telling the callback what keys have been pressed.
@JimHokanson
JimHokanson / max_v2.c
Last active November 11, 2017 04:16
horizontal max
// gcc -std=c11 -mavx2 -o max_v2 max_v2.c
#include <immintrin.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
int main() {