Skip to content

Instantly share code, notes, and snippets.

View Hio-Been's full-sized avatar
🏠
Working from home

Hio-Been Han Hio-Been

🏠
Working from home
  • Korea Institute of Science and Technology
  • Seoul, South Korea
View GitHub Profile
@Hio-Been
Hio-Been / hb_mp3_auto_downloader.py
Created December 9, 2019 09:21
Python script for automatic mp3 download
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)",
@Hio-Been
Hio-Been / hb_mp3_auto_downloader.py
Created December 9, 2019 09:21
Python script for automatic mp3 download
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)",
@Hio-Been
Hio-Been / hb_pixabay_crawling.py
Last active April 8, 2021 21:23
Python script for Pixabay image crawling
# -*- 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
@Hio-Been
Hio-Been / data_description_gin-mouse_hdeeg_assr_hwang_et_al.ipynb
Last active November 7, 2019 03:42
Data_Description_gin-Mouse_hdEEG_ASSR_Hwang_et_al.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Hio-Been
Hio-Been / hiobeen_spectrogram.py
Last active May 25, 2021 03:51
Calculating spectrogram for EEG data in Python 3
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)
@Hio-Been
Hio-Been / hiobeen_spectrogram.m
Last active November 4, 2021 04:33
MATLAB function for calculating spectrogram from EEG dataset
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)
@Hio-Been
Hio-Been / -mouse-body-tracking-v20191008a.ipynb
Last active October 8, 2019 01:13
Mouse Body Tracking v20191008a
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Hio-Been
Hio-Been / hb_get_IFD.m
Created August 8, 2019 08:33
Matlab function for IFD calculation
function [ifd, h_x, h_y, ang_diff] = hb_get_IFD( x, y, srate )
%
% hiobeen.han@kaist.ac.kr
%
h_x = angle(hilbert(x)); h_y = angle(hilbert(y));
ang_diff = h_x - h_y;
freqF = srate/(2*pi); ifd = freqF * diff( unwrap(ang_diff));
end
@Hio-Been
Hio-Been / IFD_demo.m
Last active August 9, 2019 14:11
Matlab script for calculating IFD (instantaneous frequency difference)
%clear all;
figure(100); clf; hold on
set(gcf, 'Color', [1 1 1])
% Wave generator
srate = 300; dura = 1; % sec
freq = [10 15]; % Hz
wave1 = MakeBeep( freq(1), dura, srate ); wave1 = wave1(1:end-1);
wave2 = MakeBeep( freq(2), dura, srate ); wave2 = wave2(1:end-1);
x = [wave1, wave1, wave1];
function [comod,amptds] = hb_comodulogram(xx, yy, filters_x, filters_y, nBin, MIfactor)
%
%% MATLAB function for Comodulogram (phase-amplitude coupling)
%
% function comod = hb_comodulogram(xx, yy, filters_x, filters_y)
% x: slow frequency signal
% y: fast frequency signal
% hiobeen.han@kaist.ac.kr
%
if nargin<6, MIfactor=1000; end