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 / Python2_Scr_Recorder.py
Last active December 12, 2018 09:48
This simple code iterates (1) capturing the part of the screen using PIL.ImageGrab, and (2) plotting in the matplot.pyplot figure. Drawing function may have few delay.
import numpy as np
from time import *
from matplotlib import pyplot as plt
from PIL import ImageGrab
"""
from ImageGrab import grab
from matplotlib import animation
import cv2
from cv2 import cv
"""
@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(); # 그래프를 그리기 위한 변수 정의
#! -*-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 / 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()
@Hio-Been
Hio-Been / hb_anovaContrast.m
Last active June 13, 2016 18:33
This function performs post-hoc contrast test (different from multiple comparisons) for given dataset with given coefficient vector. Same result would be produced in SPSS [analysis > One-way ANOV > contrast test]. hiobeen@yonsei.ac.kr.
function [pval, ci, stats] = hb_anovaContrast(dataset, cont_coeffs, alpha)
%% INPUT data type
%
% dataset <- cell([ 1, nCondition ]); % each cell contains column vector
% cont_coeffs <- [ 1, -1, 0, 0 ...]; % should be length at nCondition
%
% written by Hio-Been Han, for GOSHIMTONG 2016-1, YONSEI PSYCHOLOGY
% hiobeen@yonsei.ac.kr, 20160420
%
if nargin < 3
__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(:);