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 / generatePoissonSig.m
Created June 9, 2021 05:54
practical poisson event generator
function [spikes, tv] = generatePoissonSig(fs, prbprc_per_s, dur, refPeriod, n_ev)
% e.g. [spikes, tv] = generatePoissonSig(100, 5, 210, 5.5, [1 Inf])
tv = linspace(0, dur, dur*(fs));
spikes = logical(tv*0);
k=0;
evProb = prbprc_per_s/fs;
% evProb
lastSpikeSec = 0;
while 1
@rysk-t
rysk-t / HV_checker-TriggrtNIdaq.ipynb
Created September 13, 2019 10:01
psychopy_with_NIDaqmx
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
% Auto-generated by Data Acquisition Toolbox Analog Input Recorder on 2018/11/05 16:12:30
close all
%% Create Data Acquisition Session
% Create a session for the specified vendor.
s = daq.createSession('ni');
%% Set Session Properties
% Set properties that are not using default values.
s.Rate = 5000;
s.IsContinuous = true;
@rysk-t
rysk-t / dotPlot.m
Created October 18, 2017 09:44
dotplot
function [sh, lh, mp] = dotPlot(X, G, Wid, med, beas)
% [sh, lh, mp] = dotPlot(X, G, Wid, med, beas)
%
% load fisheriris.mat
% [sh, lh, mp] = dotPlot(meas(:,3), species, .25, false, true)
%
% input:
% X: data
% G: Group
% Wid: width of dot distribution (default: .35)
%% functions
function myax2
myax
p = findobj(gcf,'Type','Axes');
set(p,'FontSize', 8, 'FontName', 'Arial', 'box', 'off', 'TickDir', 'out');
end
%% 初期化
clear variables
close all;
%% 定数,ディレクトリ
NPWIDTH = 10;
rootDir = 'C:\Users\rysk\Documents\MATLAB\oskd';
roiRoot = [rootDir filesep 'RoiSet'];
meanImgName = [rootDir filesep 'averaged.tif'];
@rysk-t
rysk-t / ROIconv2.m
Created October 5, 2017 23:20
conv2 as a moving ROI
img = double(2^8-imread('eight.tif')); % ここは適宜
figure;
subplot(1,2,1)
imagesc(img); axis image;
title('Image')
% 直径をマニュアルで決めるとき
% circROI = imellipse;
% circPos = getPosition(circROI);
function shuffled_idx = ratio_shuffle(len, ratio)
% hidx = 1:4:length(tune(:));
% hidxs = hidx(randperm(length(hidx)));
% tune_h = tune;
% tune_h(hidx) = tune(hidxs);
shuffled_idx = 1:len;
soi = randperm(len);
soi_s = soi(1:floor(len*ratio));
soi_s = soi_s(randperm(length(soi_s)));
shuffled_idx(soi(1:floor(len*ratio))) = soi_s;
% Happy - Unhappy!
Happy_dir = 'E:\Drives\Google ドライブ\testData\selected_happy';
Neutl_dir = 'E:\Drives\Google ドライブ\testData\selected_neutral';
%% load Happy
hfiles = dir([Happy_dir filesep '*.png']);
nfiles = dir([Neutl_dir filesep '*.png']);
targSize = 64;
clear imgs
@rysk-t
rysk-t / calcium_ezPlot.m
Last active June 13, 2017 11:44
MATLAB script: first step of calcium imaging data
%% 読み込みファイル (uigetfileを使うと良い)
clear all;
imname = 'Registered_03.tif';
%% Tiff header情報の の読み取り
tObj = Tiff(imname, 'r');
tags = tObj.getTagNames;
info = imfinfo(imname);
tic