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 / 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 / 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 / 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')