function [fluo] = genSimulatedF(t, delay, masks) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generates random fluorescence traces for a set of ROIs for the purposes of %simulating calcium activity % Inputs: % - t: vector of the time steps for the simulation % - delay: scalar of the time to delay before the motor complex and an % increase in the likelihood of calcium transients occuring % - masks: MxNxnNeuron matrix of the ROIs for each neuron % Inputs: % - Fluo: NxT matrix of the fluorescence activity for each ROI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nNeuron = size(masks, 3); tau = 0.6; texp = 0:0.05:2.5; Amp = 1; expf = Amp*2.^(-texp/tau); expmu = 200; baseint = 100; F = ones(length(t), nNeuron); expprob = 1-expcdf(0:length(t), expmu); for fn = 1:nNeuron ind = find(masks(:, :, fn)); nCTs = randi(5)-1; timeCT = randsample(1:(length(t)-51), nCTs); nCTs = randi(100)-1; nCTprob = rand(nCTs, 1); rsamp = randsample(delay:2:(length(t)- 51), nCTs); ind = find(nCTprob > expprob(rsamp-delay+1)'); rsamp(ind) = []; timeCT = [timeCT rsamp]; SNR = rand*6+4; for CT = 1:length(timeCT) mu = SNR*sqrt(baseint); F(timeCT(CT)+(1:51), fn) = F(timeCT(CT)+(1:51), fn)+mu*expf'; end F(:, fn) = F(:, fn) + poissrnd(baseint, size(F(:, fn))); end fluo = (F-baseint)/baseint;