Skip to content

Commit

Permalink
Fix some important bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
vergaloy committed Sep 10, 2024
1 parent f37e9ff commit a9c7c2b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions Align_sessions/int_var.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
%Size of blood vessels [min diameter max diameter] in pixels.
addParameter(inp,'FinalAlignmentWithNeuronShapes',0) % Add an extra alignment iteration utilizing only neuron shapes after CaliAli
addParameter(inp,'Force_BVz',0) % Fore the use of BVz for alignment, even if BVz stability score is low.
addParameter(inp,'batch_sz',0) % Number of frames to use per batch. If batch_sz=0, then the number of frame per batch is equal to the number of frames per_session.
%%
addParameter(inp,'dynamic_spatial',0) % not currently in use
addParameter(inp,'datename',0) % not currently in use
Expand Down
4 changes: 2 additions & 2 deletions CNMF-e/CaliAli_modified_codes/scale_to_noise.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function scale_to_noise(neuron)
% We estimate the noise from the remnant between the raw and deconvolved calcium trace.
% we use a moving window of size=num
if size(neuron.options.F,2)>1
c=cumsum(neuron.options.F)';
if size(get_batch_size(neuron,0),2)>1
c=cumsum(get_batch_size(neuron,0))';
c=[[0;c(1:end-1)]+1,c];
else
c=[neuron.frame_range(1),neuron.frame_range(2)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
d2=neuron.options.d2;
gSig=neuron.options.gSig;
n_enhanced=neuron.n_enhanced;
fn=[0,cumsum(neuron.options.F)];
fn=[0,cumsum(get_batch_size(neuron,0))];
for i=progress(1:size(fn,2)-1)
Y = neuron.load_patch_data([],[fn(i)+1,fn(i+1)]);
if ~ismatrix(Y); Y = reshape(Y, d1*d2, []); end % convert the 3D movie to a matrix
Expand Down
2 changes: 1 addition & 1 deletion CNMF-e/runCNMFe.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function runCNMFe(in,PNR_th,Coor_th,gSig,sf)

%% Optional post-process
scale_to_noise(neuron);
neuron.C_raw=detrend_Ca_traces(neuron.Fs*2,neuron.C_raw,neuron.CaliAli_opt.F);
neuron.C_raw=detrend_Ca_traces(neuron.Fs*2,neuron.C_raw,get_batch_size(neuron));
justdeconv(neuron,'thresholded','ar2',0);
denoise_thresholded(neuron,5);

Expand Down
4 changes: 4 additions & 0 deletions Other_codes/Experimental/get_batch_size.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
end
F=neuron.CaliAli_opt.F;

if neuron.CaliAli_opt.batch_sz>0
F=diff(round(linspace(1,sum(F),round(sum(F)/neuron.CaliAli_opt.batch_sz)+1)));
end

if neuron.CaliAli_opt.dynamic_spatial==1
ses=20;
if length(F)<ses
Expand Down

0 comments on commit a9c7c2b

Please sign in to comment.