This file contains 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 handle = imagesc_surf( x, y, d ) | |
size_xy = size( d ); | |
if size(x,1)>size(x,2), x=x'; end | |
if size(y,1)>size(y,2), y=y'; end | |
if ~(size_xy(1)==length(x)), x = imresize(x, [1,size_xy(1)]); end | |
if ~(size_xy(2)==length(y)), y = imresize(y, [1,size_xy(2)]); end | |
handle = surf( x, y, d' ); axis xy | |
handle.LineStyle = 'none'; | |
view(gca,[-0.001 90]); | |
set(gca, 'XScale', 'log', 'YScale', 'log'); |
This file contains 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
% | |
% Jeelab Spectral Granger-causality demo script for dummies | |
% Toolbox source: http://www.sussex.ac.uk/sackler/mvgc/ | |
% | |
% written by Hio-Been Han, 2021-07-23. hiobeen.han@kaist.ac.kr | |
% https://jeelab.net | |
% | |
%% (1) Environment setting | |
clear all; |
This file contains 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 mat_interp = interp_nan2d( mat, kernel_size ) | |
% | |
% MATLAB function for interpolating 2d matrix | |
% | |
% Interpolating nan in 2D matrix | |
% Hio-Been Han, hiobeen.han@kaist.ac.kr | |
% 2021-03-09. | |
% | |
shape = size(mat); | |
if nargin < 2,kernel_size = ceil( mean(shape)/50 );end |
This file contains 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
acqDuration = 60*5; | |
fprintf('\nInitiating DAQ recording.. Max duration: [%03d minutes]\n', acqDuration); | |
samplingRate = 2000; | |
%% (1) Get DAQ | |
warning off; | |
nSmooth = 180; % for visualization | |
try; DAQs.in.session.stop; release( DAQs.in.session ); end | |
%% (2) DAQ INIT |
This file contains 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 parse_video(resizeOption, cropOption) | |
% | |
% Parsing video (*.mp4/*.avi) file(s) into image (*.jpg) files | |
% | |
% Written by Hio-Been Han, hiobeen.han@kaist.ac.kr | |
% | |
% 2020-09-30 | |
% | |
if nargin < 1, resizeOption = false; end | |
if nargin < 2, cropOption = false; end |
This file contains 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 [x_conv, window] = hb_calc_movingwindow( x, winsize, func, gaussOpt ) | |
% Calculating *func* using moving window | |
% ex) For moving average | |
% data = hb_calc_movingwindow( data, 100, @nanmean ); | |
% | |
% Written by hiobeen.han@kaist.ac.kr, 2020-07-27 | |
if nargin < 3, func = @nanmean; end | |
if nargin < 4, gaussOpt = false; end |
This file contains 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 generate_masks_manual() | |
% MATLAB function for generating binary masks | |
% Hio-Been Han, hiobeen.han@kaist.ac.kr | |
% 2020-07-13. | |
%% (1) Environment set | |
[img_directory] = uigetdir(); | |
% img_directory = [pwd '/frame_copied']; | |
file_list = dir( [img_directory '/*.png'] ); |
This file contains 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
%% (0) Set option | |
vid_save_option = false; % <- change this to true (to gen video output) | |
%% (1) Read frames from input video | |
vid_in = VideoReader( 'video_input.mp4' ); | |
frames = []; | |
nFrames = vid_in.Duration * vid_in.FrameRate; | |
for frameIdx = 1:nFrames | |
frames(:,:,:,frameIdx) = vid_in.readFrame(); | |
end |
This file contains 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 imgs = get_drifting_grating( n_frames, rec, tilt, sf, drift_speed, plot_option ) | |
%% MATLAB function for drifting grating (2D sine wave) | |
% Usage: | |
% imgs = get_drifting_grating( n_frames, rec, tilt, sf, drift_speed, plot_option ) | |
% ex) imgs = get_drifting_grating( 60, 500, 30, .01, 5, 1 ); | |
% ex) imgs = get_drifting_grating(); | |
% | |
% written by Hio-Been Han, 2020-02-22 | |
% hiobeen.han@kaist.ac.kr | |
% |
This file contains 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
songnames = [ 'Anne-Marie/2002', | |
'Aaron Sheer/Searching', | |
'The Clash/Should I Stay Or Should I Go', | |
'Jessie Reyez/Figures, a Reprise (Feat. Daniel Caesar)', | |
'Usher/Love In This Club (Feat. Young Jeezy)', | |
"Jason Mraz/I'm Yours", | |
"Jason Mraz/I Won't Give Up", | |
"Justin Bieber/Love Yourself", | |
"Anne-Marie/FRIENDS", | |
"The Chainsmokers/Closer (Feat.Halsey)", |
NewerOlder