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
#! -*- coding:utf-8 -*- | |
from __future__ import division | |
""" | |
< Sample 1. Double Flash Illusion > | |
- 컴퓨터/모니터의 성능에 따라 자극 제시 시간이 변할 수 있습니다. | |
- 만든이: 한효빈, 2015/03/01, hiobeen@yonsei.ac.kr | |
- Stimuli properties are adopted from: { | |
Cecere, R., Rees, G., & Romei, V. (2015). |
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
function EEG = hiobeen_spectrogram( EEG, fft_win_size, t_resolution, freq_cut, option ) | |
%% Calculating spectrogram from EEG dataset | |
% | |
% EEG=hiobeen_spectrogram( EEG ); % optimized to eeglab default format | |
% EEG=hiobeen_spectrogram( EEG [,fft_win_size] [,t_resolution,] [freq_cut,] [option] ) | |
% | |
% .. fft_win_size (default 2^10) : Window size to sample (unit: data point | |
% .. t_resolution (default 0.1) : Time resolution of sliding (unit: sec) | |
% .. freq_cut (default: Nyquist) : Frequency upper-limit (unit: Hz) |
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
import numpy as np | |
def fft_half(x, srate=2000): | |
return np.fft.fft(x)[:int(len(x)/2)]/len(x), np.linspace(0,srate/2,len(x)/2) | |
# [1 x n] 2D time vector (t) should be in unit of seconds. Length should be | |
def get_spectrogram( data, t=EEG.times, srate=2000, | |
fft_win_size=2**10, t_resolution=0.1, freq_cut = 150): | |
# For many- and single-trials data compatibility | |
if data.ndim < 3: data= np.expand_dims(data,2) |
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
# -*- coding: utf-8 -*- | |
""" | |
@author: HioBeen Han, hiobeen.han@kaist.ac.kr | |
""" | |
from time import sleep, gmtime, strftime | |
init_t = strftime("%Y%m%d-%H%M%S", gmtime()) | |
print('Initiated at ' + init_t + ' ....') | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
import requests |
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 |
NewerOlder