|
137 | 137 | end |
138 | 138 |
|
139 | 139 | cnt = 0; |
| 140 | +B = sparse(prod(sizY(1:end-1)),length(patches)); |
| 141 | +MASK = zeros(sizY(1:end-1)); |
| 142 | +F = zeros(length(patches),sizY(end)); |
140 | 143 | for i = 1:length(patches) |
141 | 144 | for k = 1:K |
142 | 145 | if k <= size(RESULTS(i).A,2) |
|
152 | 155 | end |
153 | 156 | end |
154 | 157 | if length(sizY) == 3 |
| 158 | + b_temp = sparse(sizY(1),sizY(2)); |
| 159 | + b_temp(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) = reshape(RESULTS(i).b,patches{i}(2)-patches{i}(1)+1,patches{i}(4)-patches{i}(3)+1); |
| 160 | + MASK(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) = MASK(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) + 1; |
155 | 161 | P.sn(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) = reshape(RESULTS(i).P.sn,patches{i}(2)-patches{i}(1)+1,patches{i}(4)-patches{i}(3)+1); |
156 | 162 | P.active_pixels(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) = P.active_pixels(patches{i}(1):patches{i}(2),patches{i}(3):patches{i}(4)) + ... |
157 | 163 | reshape(RESULTS(i).P.active_pixels,patches{i}(2)-patches{i}(1)+1,patches{i}(4)-patches{i}(3)+1); |
|
167 | 173 | P.c1 = [P.c1;RESULTS(i).P.c1]; |
168 | 174 | P.gn = [P.gn;RESULTS(i).P.gn]; |
169 | 175 | P.neuron_sn = [P.neuron_sn;RESULTS(i).P.neuron_sn]; |
| 176 | + B(:,i) = b_temp(:); |
| 177 | + F(i,:) = RESULTS(i).f; |
170 | 178 | end |
171 | 179 | A(:,cnt+1:end) = []; |
| 180 | +A = spdiags(1./MASK(:),0,prod(sizY(1:end-1)),prod(sizY(1:end-1)))*A; |
| 181 | +B = spdiags(1./MASK(:),0,prod(sizY(1:end-1)),prod(sizY(1:end-1)))*B; |
172 | 182 | C = cell2mat({RESULTS(:).C}'); |
173 | 183 | S = cell2mat({RESULTS(:).S}'); |
174 | 184 | ff = find(sum(A,1)==0); |
|
207 | 217 | end |
208 | 218 | fprintf(' done. \n'); |
209 | 219 | %% classify components |
210 | | -ff = classify_components(Am,Pm,options); |
211 | | -A = Am(:,ff); |
212 | | -C = Cm(ff,:); |
| 220 | +% ff = classify_components(Am,Pm,options); |
| 221 | +% A = Am(:,ff); |
| 222 | +% C = Cm(ff,:); |
| 223 | +A = Am; |
| 224 | +C = Cm; |
213 | 225 |
|
214 | 226 | %% update spatial components |
215 | 227 | fprintf('Updating spatial components...'); |
|
226 | 238 | % cnt = cnt + fm(i)-fp(i)+1; |
227 | 239 | % end |
228 | 240 |
|
229 | | -bsum = zeros(length(patches),1); |
230 | | -for i = 1:length(patches) |
231 | | - bsum(i) = sum(RESULTS(i).b); |
232 | | -end |
233 | | -bsum = bsum/sum(bsum); |
234 | | -f_p = cell2mat({RESULTS(:).f}'); |
235 | | -fin = mean(spdiags(bsum,0,length(patches),length(patches))*f_p); |
236 | | -fin = medfilt1(fin,11); |
| 241 | +% bsum = zeros(length(patches),1); |
| 242 | +% for i = 1:length(patches) |
| 243 | +% bsum(i) = sum(RESULTS(i).b); |
| 244 | +% end |
| 245 | +% bsum = bsum/sum(bsum); |
| 246 | +% f_p = cell2mat({RESULTS(:).f}'); |
| 247 | +% fin = mean(spdiags(bsum,0,length(patches),length(patches))*f_p); |
| 248 | +% fin = medfilt1(fin,11); |
237 | 249 |
|
| 250 | +fin = mean(F); |
| 251 | +for iter = 1:10 |
| 252 | + bin = max(B*(F*fin')/norm(fin)^2,0); |
| 253 | + fin = max((bin'*B)*F/norm(bin)^2,0); |
| 254 | +end |
| 255 | +%% |
238 | 256 | % PROCESS PATCHES |
239 | 257 | options.d1 = sizY(1); |
240 | 258 | options.d2 = sizY(2); |
|
0 commit comments