Skip to content

Commit

Permalink
Fix misspelled code in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
vergaloy committed Apr 22, 2024
1 parent cb59e1f commit 0e3866e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 180 deletions.
81 changes: 0 additions & 81 deletions Motion_Correction/other codes/MR_Log_demon_MC_batch.asv

This file was deleted.

13 changes: 0 additions & 13 deletions Motion_Correction/other codes/MR_Log_demon_MC_batch.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,3 @@



opt{1,1} = struct('niter',100, 'sigma_fluid',1,...
'sigma_diffusion',5, 'sigma_i',1,...
'sigma_x',1, 'do_display',plotme, 'do_plotenergy',plotme);
opt{2,1} = struct('niter',100, 'sigma_fluid',1,...
'sigma_diffusion',5, 'sigma_i',1,...
'sigma_x',1, 'do_display',plotme, 'do_plotenergy',plotme);
opt{3,1} = struct('niter',20, 'sigma_fluid',3,...
'sigma_diffusion',3, 'sigma_i',1,...
'sigma_x',1, 'do_display',plotme, 'do_plotenergy',plotme);
opt{4,1} = struct('niter',20, 'sigma_fluid',3,...
'sigma_diffusion',3, 'sigma_i',1,...
'sigma_x',2, 'do_display',plotme, 'do_plotenergy',plotme);

168 changes: 84 additions & 84 deletions Motion_Correction/other codes/frame_reg_PV.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,101 @@
% register movies with the hierarchical movement correction
% Jinghao Lu, 09/01/2017

hreg = tic;
%% initialization %%
%%% initialize parameters %%%
[pixh, pixw, nf] = size(m);

%%% prepare parallel computing %%%
if isempty(gcp('nocreate'))
parpool(feature('numCores'));
end
%%% select gpu %%%
select_gpu;
%%% preprocess Y first %%%
dthres = 0.1;
mskpre = uint8(dominant_patch(imaxn, dthres));
knl = fspecial('gaussian', [pixh, pixw], min(pixh, pixw) / 4);
maxallc = normalize(single(imaxn) .* knl);
maskc = uint8(normalize(imgaussfilt(feature2_comp(maxallc, 0, 100, 5), ...
100 * size(maxallc) / max(size(maxallc)))) > 0.4);
ttype = class(m(1, 1, 1));
stype = parse_type(ttype);
hreg = tic;
%% initialization %%
%%% initialize parameters %%%
[pixh, pixw, nf] = size(m);

%%% prepare parallel computing %%%
if isempty(gcp('nocreate'))
parpool(feature('numCores'));
end

%%% select gpu %%%
select_gpu;

%%% preprocess Y first %%%
dthres = 0.1;
mskpre = uint8(dominant_patch(imaxn, dthres));
knl = fspecial('gaussian', [pixh, pixw], min(pixh, pixw) / 4);
maxallc = normalize(single(imaxn) .* knl);
maskc = uint8(normalize(imgaussfilt(feature2_comp(maxallc, 0, 100, 5), ...
100 * size(maxallc) / max(size(maxallc)))) > 0.4);
ttype = class(m(1, 1, 1));
stype = parse_type(ttype);
% nsize = pixh * pixw * nf * stype; %%% size of single %%%
% nbatch = batch_compute(nsize);
% ebatch = ceil(nf / nbatch);
% idbatch = [1: ebatch: nf, nf + 1];
% nbatch = length(idbatch) - 1;
m = m.*mskpre;
m = m.*mskpre;

%%% get translation score %%%
fprintf('Begin initial computation of translation score \n')
nsize = pixh * pixw * nf * stype * 2; %%% size of single in parallel %%%
mq = 0.01;
%%% get translation score %%%
fprintf('Begin initial computation of translation score \n')
nsize = pixh * pixw * nf * stype * 2; %%% size of single in parallel %%%
mq = 0.01;


acorr= get_trans_score(m, [], 1, 1, mq, maskc);
acorr= get_trans_score(m, [], 1, 1, mq, maskc);
% acorr(max(1, idbatch(i) - 1): idbatch(i + 1) - 2) = get_trans_score(tmp, [], 1, 1, mq);
end
end

%%% cluster movie into hierarchical stable-nonstable sections %%%
[stt, stp, flag, scl, mc_flag] = hier_clust_PV(acorr, Fs, pixs, scl, stype, m); %%% flag: real or fake clusters %%%
time = toc(hreg);
fprintf(['Done initialization, ', num2str(time), ' seconds \n'])

%%% cluster movie into hierarchical stable-nonstable sections %%%
[stt, stp, flag, scl, mc_flag] = hier_clust_PV(acorr, Fs, pixs, scl, stype, m); %%% flag: real or fake clusters %%%
if mc_flag
%% intra-section registration %%
fprintf('Begin intra-section \n')
m = intra_section_PV(m, stt, stp, pixs, scl, sigma_x, sigma_f, sigma_d, flag, maskc);
time = toc(hreg);
fprintf(['Done initialization, ', num2str(time), ' seconds \n'])

if mc_flag
%% intra-section registration %%
fprintf('Begin intra-section \n')
m = intra_section_PV(m, stt, stp, pixs, scl, sigma_x, sigma_f, sigma_d, flag, maskc);
time = toc(hreg);
fprintf(['Done intra-section, ', num2str(time), ' seconds \n'])

%% update stable section %%
[sttn, stpn] = section_update(stt, stp, nf);

%% nonstable-section registration %%
fprintf('Begin nonstable-section \n')
m = nonstable_section(m, sttn, stpn, se, pixs, scl, sigma_x, sigma_f, sigma_d, maskc);
time = toc(hreg);
fprintf(['Done nonstable-section, ', num2str(time), ' seconds \n'])

%% inter-section registration %%
fprintf('Begin inter-section ... ')
m = inter_section(m, sttn, se, pixs, scl, sigma_x, sigma_f, sigma_d, maskc);
time = toc(hreg);
fprintf(['Done inter-section, ', num2str(time), ' seconds \n'])
end

%% spatiotemporal stabilization %%
m = frame_stab(m);

%% final preparation for output %%
%%% final score %%%
fprintf('Begin final computation of translation score \n')
nsize = pixh * pixw * nf * stype * 2; %%% size of single in parallel %%%
nbatch = batch_compute(nsize);
ebatch = ceil(nf / nbatch);
idbatch = [1: ebatch: nf, nf + 1];
nbatch = length(idbatch) - 1;
acorrf = zeros(1, nf - 1);
imax = zeros(pixh, pixw);
mx = 0;
mn = 0;
for i = 1: nbatch
tmp = m.reg(1: pixh, 1: pixw, max(1, idbatch(i) - 1): idbatch(i + 1) - 1);
acorrf(max(1, idbatch(i) - 1): idbatch(i + 1) - 2) = get_trans_score(tmp, [], 1, 1, [], maskc);
mx = max(mx, max(max(max(tmp, [], 1), [], 2), [], 3));
mn = min(mx, min(max(min(tmp, [], 1), [], 2), [], 3));
imax = max(imax, max(tmp, [], 3));
end
imax = imax - mn;
imax = imax / (mx - mn);

%%% normalize %%%
m = normalize_batch(m.Properties.Source, 'reg', mx, mn, idbatch);
fprintf(['Done intra-section, ', num2str(time), ' seconds \n'])

%% update stable section %%
[sttn, stpn] = section_update(stt, stp, nf);

%% nonstable-section registration %%
fprintf('Begin nonstable-section \n')
m = nonstable_section(m, sttn, stpn, se, pixs, scl, sigma_x, sigma_f, sigma_d, maskc);
time = toc(hreg);
fprintf(['Done frame reg, total time: ', num2str(time), ' seconds \n'])
fprintf(['Done nonstable-section, ', num2str(time), ' seconds \n'])

%% inter-section registration %%
fprintf('Begin inter-section ... ')
m = inter_section(m, sttn, se, pixs, scl, sigma_x, sigma_f, sigma_d, maskc);
time = toc(hreg);
fprintf(['Done inter-section, ', num2str(time), ' seconds \n'])
end

%% spatiotemporal stabilization %%
m = frame_stab(m);

%% final preparation for output %%
%%% final score %%%
fprintf('Begin final computation of translation score \n')
nsize = pixh * pixw * nf * stype * 2; %%% size of single in parallel %%%
nbatch = batch_compute(nsize);
ebatch = ceil(nf / nbatch);
idbatch = [1: ebatch: nf, nf + 1];
nbatch = length(idbatch) - 1;
acorrf = zeros(1, nf - 1);
imax = zeros(pixh, pixw);
mx = 0;
mn = 0;
for i = 1: nbatch
tmp = m.reg(1: pixh, 1: pixw, max(1, idbatch(i) - 1): idbatch(i + 1) - 1);
acorrf(max(1, idbatch(i) - 1): idbatch(i + 1) - 2) = get_trans_score(tmp, [], 1, 1, [], maskc);
mx = max(mx, max(max(max(tmp, [], 1), [], 2), [], 3));
mn = min(mx, min(max(min(tmp, [], 1), [], 2), [], 3));
imax = max(imax, max(tmp, [], 3));
end
imax = imax - mn;
imax = imax / (mx - mn);

%%% normalize %%%
m = normalize_batch(m.Properties.Source, 'reg', mx, mn, idbatch);
time = toc(hreg);
fprintf(['Done frame reg, total time: ', num2str(time), ' seconds \n'])
end

2 changes: 1 addition & 1 deletion docs/Prep.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The function used to downsample video sessions would depende on the format of th

=== ".isdx (Inscopix)"
``` matlab
Downsample_inscopix(ds_f, outpath, theFiles)
Downsample_Inscopix(ds_f, outpath, theFiles)
```
This function reads Inscopix video files, downsamples them, and saves the resulting frames as an HDF5 (.h5) file.

Expand Down
2 changes: 1 addition & 1 deletion docs/TLDR.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Run the following functions:
```
=== ".isdx (Inscopix)"
``` matlab
Downsample_inscopix(4)
Downsample_Inscopix(4)
```

### 2) Motion Correction:
Expand Down

0 comments on commit 0e3866e

Please sign in to comment.