<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello fieldtrip experts,<div class=""><br class=""></div><div class="">I tried ft_connectivity_laggedcoherence and ran in this error: </div><div class=""><br class=""></div><div class=""><i class="">Error in ft_connectivity_laggedcoherence (line 228)</i></div><div class=""><div class=""><i class=""> laggedcrossproduct = fcs1(chancmbind(:,1),tcounter).*conj(fcs2(chancmbind(:,2),tcounter));</i></div></div><div class=""><br class=""></div><div class="">This is the code starting at line 224:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> fcs1(:,colswithnans) = []; fcs2(:,colswithnans) = [];</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class=""><span style="color: #000000" class=""> </span>% sum laggedcrossproducts and power over all timepoints</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> <span style="color: #0433ff" class="">for</span> tcounter=1:length(t1)</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> laggedcrossproduct = fcs1(chancmbind(:,1),tcounter).*conj(fcs2(chancmbind(:,2),tcounter));</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> laggedcps(:,lagindx,trialindx) = laggedcps(:,lagindx,trialindx)+ laggedcrossproduct;</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> power(:,lagindx,1,trialindx) = power(:,lagindx,1,trialindx)+ abs(fcs1(chancmbind(:,1),tcounter)).^2;</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> power(:,lagindx,2,trialindx) = power(:,lagindx,2,trialindx)+ abs(fcs2(chancmbind(:,2),tcounter)).^2;</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> hasdata(trialindx,lagindx) = true;</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> nsmplslaggedcps(lagindx,trialindx) = nsmplslaggedcps(lagindx,trialindx)+1;</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> <span style="color: #0433ff" class="">end</span>;</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I thing my error appeared because I had some columns with NAN’s which were removed (<span style="font-family: Courier; font-size: 10px;" class="">fcs1(:,colswithnans) = []; fcs2(:,colswithnans) = [];</span> ). Then the second dimension of the matrix fcs1 did not match length(t1). </div><div class=""><br class=""></div><div class="">The code runs without error when replacing:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">% for tcounter=1:length(t1)</div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class=""> <span style="color: #0433ff" class="">for</span> tcounter=1:size(fcs1,2)</div></div><div class=""><br class=""></div><div class="">Would the output still be correct?</div><div class=""><br class=""></div><div class="">Thank you!</div><div class=""><br class=""></div><div class="">Stephan</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>