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 / plot_change_detect.py
Last active August 29, 2015 14:20
Get Movement Data from cam, Plot and Save it
#! -*- coding:utf-8 -*-
import sys; reload(sys); sys.setdefaultencoding('utf-8')
import cv2; import numpy as np; from cv2 import cv;
from time import time
import matplotlib.pyplot as plt
try: from psychopy.core import quit;
except: pass
""" [1] 데이터 플랏 윈도우 세팅 """
fig = plt.figure(); # 그래프를 그리기 위한 변수 정의
@Hio-Been
Hio-Been / kist_tactile_integrated_(2015-04-28c).py
Created August 13, 2015 11:55
kist_tactile_integrated_(2015-04-28c) for MEG tactile experiment (built up with PsychoPy2, win x86)
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Vibrotactile Experiment (Version: 2015-04-28)
Made by Hio-been Han & Dongmyeong Lee @KIST.jeelab
Written in python2.7 with PsychoPy2 (www.psychopy.org by J. Pierce)
Revision/Error report -> hiobeen@yonsei.ac.kr
"""
@Hio-Been
Hio-Been / leap_image_streaming.py
Created April 19, 2016 09:36
Python2 code for image streaming with Leap motion device
import leap_image, sys, Leap, time, numpy as np
from matplotlib import pyplot as plt
import cv2
import cv2.cv as cv
colormap = 'gist_gray'
fig = plt.figure()
my_figure = plt.imshow(np.ones([420,420]),vmin=0,vmax=235,cmap=colormap)
fig.show(); plt.ion()
__author__ = 'Hiobeen_MBPR'
#!/usr/bin/python2
""" (0) Import modules """
import facemorpher, os
# Get a list of image paths in a folder
""" (1) Path & Variable setting """
fd = '/Users/Hiobeen_MBPR/PycharmProjects/python_sketchpad/pics/'
filelist_temp = os.listdir(fd)
@Hio-Been
Hio-Been / hb_ds115_preproc.m
Last active April 30, 2016 08:36
openfmri ds115 preprocessing (ver 1.0.0)
% ---- script structure ----
% %% (0) Set dataset directory and subject list
%
% % 0-1 : Set subject list
% % 0-2 : Set directory
% % 0-3 : Set anatomy & functional image to handle easily
% % 0-3-1 : ANATOMY unzip & reorient
% % 0-3-2 : FUNCTIONAL de-compress (batch TRs into single TR)
%
% %% (1) Start preprocessing batch loop
function success = hb_mat2ARFF(v,arff_filename, relationtxt , titletxt)
%success = hb_mat2ARFF(v,arff_filename, relationtxt , titletxt)
% *.mat binary to WEKA ARFF
% hiobeen@yonsei.ac.kr
if nargin < 4
titletxt = 'temp.arff';
end ; if nargin < 3
relationtxt ='hb_variable';
end ; if nargin < 2
@Hio-Been
Hio-Been / hb_3Dto1D.m
Created April 30, 2016 14:38
MATLAB function for convert fMRI data of 4D (X,Y,Z+time) into 2D (space,time)
function [v,nBad,badIdx] = hb_3Dto1D(mat)
% Convert fMRI data of 4D (X,Y,Z+time) into 2D (space,time)
sizes = size(mat);
v = nan([sizes(1)*sizes(2)*sizes(3),sizes(4)]);
% 3D to 1D
for idx = 1:size(mat, 4)
temp = mat(:,:,:,idx);
v(:,idx) = temp(:);
#! -*-coding: utf-8 -*-
__author__ = 'Hio-been'
import pandas.io.data as web
from datetime import datetime
import matplotlib.pyplot as plt
import os, sys; reload(sys); sys.setdefaultencoding('utf-8')
import numpy as np
#https://gist.github.com/Han-Hiobeen/faba03d188452981c1ed
@Hio-Been
Hio-Been / hb_getConnectivity_ds115.m
Created June 1, 2016 16:13
hb_getConnectivity_ds115.m
%% calculate functional connectivity between two voxels
% function [ connectivity_collection,...
% basic_r, basic_cr, basic_cr_lag,... % correlation and cross-corr for HIGHPASS (replica)
% band_r, band_cr, band_cr_lag,... % correlation and cross-corr for BANDPASS
% band_ch, band_plv ] = ...
% hb_getConnectivity_ds115(hp1, hp2, bp1, bp2)
function [ connectivity_collection,...
basic_r, basic_cr, basic_cr_lag,... % correlation and cross-corr for HIGHPASS (replica)
band_r, band_cr, band_cr_lag,... % correlation and cross-corr for BANDPASS
@Hio-Been
Hio-Been / hb_anovaContrast_withStats.m
Created June 13, 2016 18:31
[pval, ci, stats] = hb_anovaContrast_withStats(stats, cont_coeffs, alpha)
function [pval, ci, stats] = hb_anovaContrast_withStats(stats, cont_coeffs, alpha)
%% INPUT data type
%
% stats <- structure type %
% stats.Ns : [1 x nCondition] matrix, number of samples
% stats.Ms : [1 x nCondition] matrix, means
% stats.Ss : [1 x nCondition] matrix, standard deviations
% cont_coeffs <- [ 1, -1, 0, 0 ...]; % should be length at nCondition
%
% written by Hio-Been Han, for GOSHIMTONG 2016-1, YONSEI PSYCHOLOGY