Skip to content

Commit

Permalink
added neuropil coef in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
marius10p committed Feb 18, 2017
1 parent 7d1a7f0 commit 385ec15
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
7 changes: 6 additions & 1 deletion SpikeDetection/run_deconvolution3.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
[NT, NN] = size(Ff);

ops.fs = getOr(ops, 'fs', ops.imageRate/ops.nplanes);
[coefNeu, inomax] = my_ica(Ff, Fneu, ops.fs, coefDefault);

if ~isfield(stat, 'neuropilCoefficient')
[coefNeu, inomax] = my_ica(Ff, Fneu, ops.fs, coefDefault);
else
coefNeu = [stat.neuropilCoefficient];
end

Ff = Ff - bsxfun(@times, Fneu, coefNeu(:)');

Expand Down
1 change: 1 addition & 0 deletions gui2P/new_main.m
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ function pushbutton98_Callback(hObject, eventdata, h)

function pushbutton99_Callback(hObject, eventdata, h)
hval = max(0, [h.dat.stat.cmpct]-1);
% hval = max(0, [h.dat.stat.aspect_ratio]-1);
h.dat.cl.rands = .1 + .8 * min(1, .5 * hval/mean(hval));
h.dat.cl.rands_orig = h.dat.cl.rands;
redraw_figure(h);
Expand Down
7 changes: 6 additions & 1 deletion gui2P/redraw_fluorescence.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ function redraw_fluorescence(h)
axis tight
hold on

coefNeu = 0.7;
if isfield(h.dat.stat, 'neuropilCoefficient')
coefNeu = h.dat.stat(ichosen).neuropilCoefficient;
end

if isfield(h.dat, 'FcellNeu')
plot(my_conv_local(medfilt1(double(Fneu), 3), 3))
plot(coefNeu * my_conv_local(medfilt1(double(Fneu), 3), 3))
end

box off
Expand Down
24 changes: 17 additions & 7 deletions signalExtraction/extractSignals.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,25 @@
indNoNaN = find(~ops.badframes);
ix = cumsum(~ops.badframes) + 1;
ix = ix(ops.badframes);
ix(ix>numel(indNoNaN)) = numel(indNoNaN);
ix(ix>numel(indNoNaN)) = numel(indNoNaN);

F(:, ops.badframes) = F(:, indNoNaN(ix));
F(:, ops.badframes) = F(:, indNoNaN(ix));
Fneu(:, ops.badframes) = Fneu(:, indNoNaN(ix));

dF = F - Fneu;
sd = std(dF, [], 2);

% figure out the ICA coefficients here <--- FIX THIS
ops.fs = getOr(ops, 'fs', ops.imageRate/ops.nplanes);
%
[coefNeu, inomax] = my_ica(F', Fneu', ops.fs, 0.7);
dF = F - bsxfun(@times, Fneu, coefNeu(:));

% dF = F - Fneu;

sd = std(dF, [], 2);
sdN = std(Fneu, [], 2);

sk(:, 1) = skewness(dF, [], 2);
sk(:, 2) = sd/mean(sd);
sk(:, 2) = sd./sdN;
sk(:, 3) = (max(dF, [], 2)-median(dF, 2))./sd;
sk(:, 4) = (prctile(dF, 95, 2)-median(dF, 2))./sd;

Expand All @@ -127,10 +136,11 @@
stat(j).maxMinusMed = sk(j,3);
stat(j).top5pcMinusMed = sk(j,4);
stat(j).blockstarts = [0 cumsum(ops.Nframes)];
stat(j).iplane = ops.iplane;
stat(j).iplane = ops.iplane;
stat(j).neuropilCoefficient = coefNeu(j);
end

%%
%
csumNframes = [0 cumsum(ops.Nframes)];
Fcell = cell(1, length(ops.Nframes));
FcellNeu = cell(1, length(ops.Nframes));
Expand Down

0 comments on commit 385ec15

Please sign in to comment.