Skip to content

Instantly share code, notes, and snippets.

View rysk-t's full-sized avatar

Ryosuke Takeuchi rysk-t

  • Nagoya Univ.
  • Japan
View GitHub Profile
@rysk-t
rysk-t / eyemove_mov.m
Created January 29, 2016 05:40
movie render example
% 画像
im = imread('eight.tif');
imagesc(i); colormap gray; axis image; hold on
% dummy 視線データ
x = [linspace(50,125,50) linspace(125,200,50) linspace(200, 250, 50)];
y = [linspace(150,50,50) linspace(50,200,50) linspace(200,50,50)];
x = x+3*randn(size(x));
y = y+0*randn(size(y));
tic
clear List
curPATH = pwd;
bSlshPoint = strfind(curPATH, '\');
wienSize = [3 3];
List = dir('*.jpg');
resPATH = ['..\' curPATH(bSlshPoint(end)+1:end) '_re2'];
mkdir(resPATH)
cont = [0.15 0.9];
@rysk-t
rysk-t / scanOptim.py
Created January 26, 2016 06:29
process scansnap *.jpg files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import codecs
import sys
import os
import glob
import time
import matplotlib.pyplot as plt
import numpy as np
@rysk-t
rysk-t / file0.mat
Last active December 21, 2015 11:28
matlab関数フィッティング (正弦波フィット) ref: http://qiita.com/rysk-t/items/62c74367e9614de9c027
x = pi*(0:30:360)/180;
y = 2*rand(1)*sin(x-randn(1)*pi+pi/2)+0.2;
yraw = y+0.17*randn(size(x)); % 正規乱数を足す.このデータにフィッティングする.
@rysk-t
rysk-t / FitSin.m
Last active January 6, 2016 08:11
function [optparam, fo, sinfunc] = FitSin(x, y)
% [optparam, fo, sinfunc] = FitSin(x, y)
%
%
% Fitting Data to following function with "lsqnonlin"
% sinfunc = @(v, x) (v(1)*sin(x-v(2))+v(3));
%
% x: xaxis (radian)
% y: actuial value
%
function [params, f, flag, lamb, coeff, ey] = TPgaussianFit(x, y, x0, options)
% function [params f, flag, lamb] = vonMises(x, y, x0, options)
% func = @(v, x) ... % Von mises function
% v(1) + v(2)*exp(-1* ((x*pi/180) - v(3)).^2 * (1/(2*v(4)^2)))
%
% x-range should be 0~360
func = @(v, x) ...
v(1) + v(2)*exp(-1* ((x*pi/180) - v(3)).^2 * (1/(2*v(4)^2))) ...
+ v(5)*exp(-1* ((x*pi/180) - v(3)+v(6)).^2 * (1/(2*v(4)^2)));
@rysk-t
rysk-t / pdusteg.m
Created December 9, 2015 06:25
pdistによる距離計算 (MATLAB)
Xdif = pdist(X(:));
Ydif = pdist(Y(:));
cDist = sqrt(Xdif.^2 + Ydif.^2);
@rysk-t
rysk-t / getjpgFilePath.m
Created November 2, 2015 00:11
MATLABで、あるフォルダ以下のサブフォルダのリストを作る => 任意の拡張子のファイルパスを取得 (ここでは*.jpg)
ldirs = genpath(pwd);
ldirs = [';' ldirs];
sepidx = strfind(ldirs, ';');
for i = 1:length(sepidx)-1
gpath{i} = ldirs(sepidx(i)+1:sepidx(i+1)-1);
end
j = 1;
for i = 1:length(gpath)
@rysk-t
rysk-t / getdirs
Created November 2, 2015 00:10
あるフォルダ以下のサブフォルダのリストを作る => 任意の拡張子のファイルパスを取得 (ここでは*.jpg)
ldirs = genpath(pwd);
ldirs = [';' ldirs];
sepidx = strfind(ldirs, ';');
for i = 1:length(sepidx)-1
gpath{i} = ldirs(sepidx(i)+1:sepidx(i+1)-1);
end
j = 1;
for i = 1:length(gpath)
@rysk-t
rysk-t / multipeak_vonmises.m
Created October 8, 2015 18:32
vonmises distribution fit with matlab
twopeakVonmises = @(v, x) ...
v(1) + v(2)*exp(-1* ((x*pi/180) - v(3)).^2 * (1/(2*v(4)^2))) ...
+ v(5)*exp(-1* ((x*pi/180) - v(3)+v(6)).^2 * (1/(2*v(4)^2)));
options = optimoptions('fmincon', 'MaxIter', 100000,'GradObj','off');
for i = 1:size(stimResp.meanVal, 1)
tmp = (stimResp.meanVal(i,1:end-1)-1);
fcn = @(v) sum(abs((twopeakVonmises(v,ORvar) - tmp)));
v(1) = min(tmp); % baseline