|
13 | 13 | % register files one by one. use template obtained from file n to |
14 | 14 | % initialize template of file n + 1; |
15 | 15 |
|
16 | | -motion_correct = true; % perform motion correction |
| 16 | +motion_correct = true; % perform motion correction |
17 | 17 | non_rigid = true; % flag for non-rigid motion correction |
18 | 18 | if non_rigid; append = '_nr'; else; append = '_rig'; end % use this to save motion corrected files |
19 | 19 | options_mc = NoRMCorreSetParms('d1',FOV(1),'d2',FOV(2),'grid_size',[128,128],'init_batch',200,... |
20 | | - 'overlap_pre',64,'mot_uf',4,'bin_width',200,'max_shift',24,'max_dev',8,'us_fac',50,... |
| 20 | + 'overlap_pre',32,'mot_uf',4,'bin_width',200,'max_shift',24,'max_dev',8,'us_fac',50,... |
21 | 21 | 'output_type','h5'); |
22 | 22 |
|
23 | 23 | template = []; |
24 | 24 | col_shift = []; |
25 | 25 | for i = 1:numFiles |
26 | 26 | fullname = files(i).name; |
27 | | - [folder_name,file_name,ext] = fileparts(fullname); |
| 27 | + [folder_name,file_name,ext] = fileparts(fullname); |
28 | 28 | options_mc.h5_filename = fullfile(folder_name,[file_name,append,'.h5']); |
29 | | - if motion_correct |
| 29 | + if motion_correct |
30 | 30 | [M,shifts,template,options_mc,col_shift] = normcorre_batch(fullname,options_mc,template); |
31 | 31 | save(fullfile(folder_name,[file_name,'_shifts',append,'.mat']),'shifts','-v7.3'); % save shifts of each file at the respective folder |
32 | 32 | else % if files are already motion corrected convert them to h5 |
|
101 | 101 | 'deconv_method','constrained_foopsi',... % neural activity deconvolution method |
102 | 102 | 'p',p,... % order of calcium dynamics |
103 | 103 | 'ssub',2,... % spatial downsampling when processing |
104 | | - 'tsub',4,... % further temporal downsampling when processing |
| 104 | + 'tsub',2,... % further temporal downsampling when processing |
105 | 105 | 'merge_thr',merge_thr,... % merging threshold |
106 | 106 | 'gSig',tau,... |
107 | 107 | 'max_size_thr',300,'min_size_thr',10,... % max/min acceptable size for each component |
108 | 108 | 'spatial_method','regularized',... % method for updating spatial components |
109 | 109 | 'df_prctile',50,... % take the median of background fluorescence to compute baseline fluorescence |
110 | 110 | 'fr',fr/tsub,... % downsamples |
111 | | - 'space_thresh',0.5,... % space correlation acceptance threshold |
112 | | - 'min_SNR',3.0,... % trace SNR acceptance threshold |
| 111 | + 'space_thresh',0.35,... % space correlation acceptance threshold |
| 112 | + 'min_SNR',2.0,... % trace SNR acceptance threshold |
113 | 113 | 'cnn_thr',0.2,... % cnn classifier acceptance threshold |
114 | 114 | 'nb',1,... % number of background components per patch |
115 | 115 | 'gnb',3,... % number of global background components |
|
118 | 118 |
|
119 | 119 | %% Run on patches (the main work is done here) |
120 | 120 |
|
121 | | -[A,b,C,f,S,P,RESULTS,YrA] = run_CNMF_patches(data,K,patches,tau,0,options); % do not perform deconvolution here since |
122 | | - % we are operating on downsampled data |
| 121 | +[A,b,C,f,S,P,RESULTS,YrA] = run_CNMF_patches(data.Y,K,patches,tau,0,options); % do not perform deconvolution here since |
| 122 | + % we are operating on downsampled data |
123 | 123 | %% compute correlation image on a small sample of the data (optional - for visualization purposes) |
124 | 124 | Cn = correlation_image_max(data,8); |
125 | 125 |
|
126 | 126 | %% classify components |
127 | 127 |
|
128 | 128 | rval_space = classify_comp_corr(data,A,C,b,f,options); |
129 | 129 | ind_corr = rval_space > options.space_thresh; % components that pass the correlation test |
130 | | - % this test will keep processes |
| 130 | + % this test will keep processes |
131 | 131 |
|
132 | 132 | %% further classification with cnn_classifier |
133 | 133 | try % matlab 2017b or later is needed |
|
0 commit comments