Skip to content

Instantly share code, notes, and snippets.

View JimHokanson's full-sized avatar

Jim Hokanson JimHokanson

View GitHub Profile
@JimHokanson
JimHokanson / tdms_reading_options.m
Created December 20, 2018 15:23
Shows how to read parts of a file using TDMS_reader
%Code: https://www.mathworks.com/matlabcentral/fileexchange/30023-tdms-reader
file_path = 'D:\repos\SVN_FOLDERS\Labview\TDT_Controller\Modules\ENG Recorder\Data\Block-003_ENG.tdms';
%TDMS file and index at (download index to speed up reading)
%https://drive.google.com/drive/folders/1iiwPMvn5l5nrMOwrt5sSBYrCm7SyJAi1?usp=sharing
%This file contains:
%/'Data'/'Trigger'
%/'Data'/'Distal'
#include <immintrin.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <x86intrin.h>
@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() {
@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 / 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 / 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 / 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 / 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 / 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 / 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