This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % output a variable's size using >> sz | |
| w = whos; | |
| findvar = clipboard('paste'); | |
| ii = strcmp({w.name},findvar); | |
| if any(ii) | |
| w(ii).size | |
| else | |
| disp(sprintf("\nNo variable '%s'\n",findvar)); | |
| end | |
| clearvars('-except',w(:).name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function workon(openArr) | |
| % (list) >> workon | |
| % (open) >> workon(1) | |
| % (open) >> workon([2,3,6,14]) | |
| % (open) >> workon(1:7) | |
| limitTo = 15; % # of files | |
| listing = dir('**/*.m'); | |
| [~,idx] = sort([listing.datenum],'descend'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| testVals = 0:1000000:100000000; % 0 to 100 million, step 1 million | |
| nTests = numel(testVals); | |
| runTest = true; | |
| if runTest | |
| tVals_uninit = []; | |
| for iTest = 1:nTests | |
| disp(iTest); | |
| a = []; | |
| tic; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filename = 'ExampleData.csv'; | |
| data = csvread(filename,1); | |
| t = data(:,1); | |
| velocityThresh = 10; % eye-balled this | |
| minpeakdist = 100; % in samples | |
| extractRange = -20:100; % padding not handled | |
| t_compiled = t(1:numel(extractRange)); | |
| eyeHorizontal = rad2deg(data(:,2)); | |
| eyeVelocity = filterVelocity(diff(eyeHorizontal)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function [lfp,t] = groundTruthLFP(timePeriod,Fs,oscillationFreq,oscillationOnOff,oscillationAmp) | |
| % timePeriod: LFP length in seconds | |
| % Fs: sampling rate in Hz | |
| % oscillationFreq: n x 1 | |
| % oscillationOnset: n x 2 | |
| % oscillationAmp: n x 1 | |
| % check for errors in inputs | |
| if any(oscillationFreq > Fs / 2) | |
| error('Insufficient resolution for high frequency oscillations'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| timePeriod = 10; | |
| Fs = 1000; | |
| oscillationFreq = [4;10;30;75]; | |
| oscillationOnOff = [0,10;1,2;0,5;6,9]; | |
| oscillationAmp = [1;1;3;2]; | |
| [lfp,t] = groundTruthLFP(timePeriod,Fs,oscillationFreq,oscillationOnOff,oscillationAmp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| timePeriod = 3; | |
| Fs = 1000; | |
| oscillationFreq = [4;6;8]; | |
| oscillationOnOff = [0 2;1 3;1.5 2.5]; | |
| [lfp,t] = groundTruthLFP(timePeriod,Fs,oscillationFreq,oscillationOnOff); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function dataDespiked = despike(data,Fs,spikeTs,spikeWidth) | |
| % data: raw neural recording data | |
| % Fs: sampling frequency | |
| % spikeTs: spike timestamps in seconds | |
| % spikeWith: width of average spike in ms to replace | |
| % display a plot of the replaced spikes at the end | |
| doDebug = true; | |
| % convert spikeTs (in s) to samples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| csvPath = "/Users/matt/Documents/MATLAB/Misc/Complete_Pero_Master_1.29.20_dateFMT.csv"; | |
| T = readtable(csvPath); | |
| % augment table | |
| firstCaught = cell(size(T,1),1); | |
| lastCaught = firstCaught; | |
| % new table | |
| new_firstCaught = {}; | |
| new_lastCaught = {}; | |
| new_mouseID = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mypal = paletteMaker(paletteImPath) | |
| % input: image path for your palette | |
| % output: color palette as a colormap | |
| im = imresize(imread(paletteImPath),0.5); | |
| figure; | |
| imshow(im); | |
| [xs,ys,mypal] = impixel(); | |
| for iColor = 1:size(mypal,1) |