This file contains hidden or 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
| % 画像 | |
| 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)); |
This file contains hidden or 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
| 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]; |
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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
| 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)); % 正規乱数を足す.このデータにフィッティングする. |
This file contains hidden or 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 [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 | |
| % |
This file contains hidden or 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 [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))); |
This file contains hidden or 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
| Xdif = pdist(X(:)); | |
| Ydif = pdist(Y(:)); | |
| cDist = sqrt(Xdif.^2 + Ydif.^2); |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| 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 |