<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello,</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am running into an error with the connectivity script, where the output values are NaN. See below for the code section.</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
%% Compute coherence
<div><br>
</div>
<div>if computecoh == 1</div>
<div>    </div>
<div>    if strcmp(reference,'car')</div>
<div>        load([restdir 'rest_preproc_car_matched.mat'])</div>
<div>    elseif strcmp(reference,'csd')</div>
<div>        load([restdir 'rest_preproc_csd_matched.mat'])</div>
<div>    end</div>
<div>    </div>
<div>    % 1. Create TFRs by condition - frequency over time</div>
<div>    cfg             = [];</div>
<div>    cfg.channel     = [lfchans rfchans lpchans rpchans];</div>
<div>    cfg.output      = 'fourier';</div>
<div>    cfg.method      = 'mtmconvol';</div>
<div>    cfg.taper       = 'hanning';</div>
<div>    cfg.foi         = 2:1:50;</div>
<div>    cfg.toi         = -1:0.05:3;</div>
<div>    cfg.t_ftimwin   = 3./cfg.foi; % [lf hf].*cfg.foi; % length of time window; number of cycles per time window</div>
<div>    cfg.keeptrials  = 'yes';</div>
<div>    cfg.pad         = 10;</div>
<div>    [tfa_rest]      = ft_freqanalysis(cfg,rest_preproc);</div>
<div>    </div>
<div>    save([conndir 'tfa_forconn_rest_' reference '.mat'],'tfa_rest');</div>
<div>    </div>
<div>    </div>
<div>    % COMPUTE CONNECTIVITY METRICS</div>
<div>    </div>
<div>    % ~~ select relevant time period </div>
<div>    cfg             = [];</div>
<div>    cfg.latency     = [0.001 2];</div>
<div>    [tfa_rest]      = ft_selectdata(cfg, tfa_rest);</div>
<div>    </div>
<div>    % Coherence</div>
<div>    cfg             = [];</div>
<div>    cfg.method      = 'coh';</div>
<div>    cfg.complex     = 'imag'; %'abs'</div>
<div>    cfg.channelcmb  = ft_channelcombination('all',tfa_rest.label);</div>
<div>    rest_cohconn    = ft_connectivityanalysis(cfg,tfa_rest);</div>
<div>    </div>
<div>    save([conndir 'rest_cohconn_',reference,'.mat'],'rest_cohconn');</div>
<div>    </div>
<div>    clear *_coh tfa* rest_preproc</div>
<div>    </div>
<div>end</div>
<div><br>
</div>
<div>% to visualize each pair's coherence values</div>
<div>% figure;imagesc(squeeze(rest_cohconn.cohspctrm(1,6,:,:))); colorbar</div>
<div><br>
</div>
<div>%% Extract coherence values</div>
<div><br>
</div>
<div>if extract == 1</div>
<div>    </div>
<div>    load([conndir 'rest_cohconn_',reference,'.mat']);</div>
<div>    </div>
<div>    % Extract channel index</div>
<div>    lfchanidx=[]; rfchanidx=[]; lpchanidx=[]; rpchanidx=[];</div>
<div>    for c=1:numel(lfchans)</div>
<div>        lfchanidx(c) = find(strcmp(lfchans{c},rest_cohconn.label));</div>
<div>    end</div>
<div>    for c=1:numel(rfchans)</div>
<div>        rfchanidx(c) = find(strcmp(rfchans{c},rest_cohconn.label));</div>
<div>    end</div>
<div>    for c=1:numel(lpchans)</div>
<div>        lpchanidx(c) = find(strcmp(lpchans{c},rest_cohconn.label));</div>
<div>    end</div>
<div>    for c=1:numel(rpchans)</div>
<div>        rpchanidx(c) = find(strcmp(rpchans{c},rest_cohconn.label));</div>
<div>    end</div>
<div>    </div>
<div>    % identify frequency range of interest</div>
<div>    lowf = find(lf == rest_cohconn.freq);</div>
<div>    highf = find(hf == rest_cohconn.freq);</div>
<div>    freq = [lowf:highf];</div>
<div>    clear lowf highf</div>
<div>    </div>
<div>    % average over frequency range of interest, outputs chan x chan matrix</div>
<div>    cohdata = abs(mean(mean(rest_cohconn.cohspctrm(:,:,freq,:),3),4));</div>
<div>    </div>
<div>    % left - frontal vs parietal</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lfchanidx)</div>
<div>        for d = 1:numel(lpchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(lfchanidx(c),lpchanidx(d));</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    left_fvsp_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % right - frontal vs parietal</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(rfchanidx)</div>
<div>        for d = 1:numel(rpchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(rfchanidx(c),rpchanidx(d));</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    right_fvsp_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % frontal - right vs left</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lfchanidx)</div>
<div>        for d = 1:numel(rfchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(lfchanidx(c),rfchanidx(d));</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    frontal_lvsr_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % parietal - right vs left</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lpchanidx)</div>
<div>        for d = 1:numel(rpchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(lpchanidx(c),rpchanidx(d),:);</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    parietal_lvsr_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % left frontal vs right parietal</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lfchanidx)</div>
<div>        for d = 1:numel(rpchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(lfchanidx(c),rpchanidx(d),:);</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    lfrpcoh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % right frontal vs left parietal</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(rfchanidx)</div>
<div>        for d = 1:numel(lpchanidx)</div>
<div>            cohtmp(cnt,1) = cohdata(rfchanidx(c),lpchanidx(d),:);</div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    rflpcoh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    % right frontal and parietal vs left frontal and parietal</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lfchanidx)+numel(lpchanidx)</div>
<div>        for d = 1:numel(rfchanidx)+numel(rpchanidx)</div>
<div>            if c <= numel(lfchanidx) % left frontal</div>
<div>                if d <= numel(rfchanidx)</div>
<div>                    cohtmp(cnt,1) = cohdata(lfchanidx(c),rfchanidx(d),:);</div>
<div>                else</div>
<div>                    cohtmp(cnt,1) = cohdata(lfchanidx(c),rpchanidx(d-numel(rfchanidx)),:);</div>
<div>                end</div>
<div>            else % left parietal</div>
<div>                if d <= numel(rfchanidx)</div>
<div>                    cohtmp(cnt,1) = cohdata(lpchanidx(c-numel(lfchanidx)),rfchanidx(d),:);</div>
<div>                else</div>
<div>                    cohtmp(cnt,1) = cohdata(lpchanidx(c-numel(lfchanidx)),rpchanidx(d-numel(rfchanidx)),:);</div>
<div>                end</div>
<div>            end</div>
<div>            </div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    leftvsright_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>    </div>
<div>    % frontal vs parietal (left and right)</div>
<div>    cnt = 1;</div>
<div>    for c = 1:numel(lfchanidx)+numel(rfchanidx)</div>
<div>        for d = 1:numel(lpchanidx)+numel(rpchanidx)</div>
<div>            if c <= numel(lfchanidx) %  left</div>
<div>                if d <= numel(lpchanidx)</div>
<div>                    cohtmp(cnt,1) = cohdata(lfchanidx(c),lpchanidx(d),:);</div>
<div>                else</div>
<div>                    cohtmp(cnt,1) = cohdata(lfchanidx(c),rpchanidx(d-numel(lpchanidx)),:);</div>
<div>                end</div>
<div>            else %  right</div>
<div>                if d <= numel(rfchanidx)</div>
<div>                    cohtmp(cnt,1) = cohdata(rfchanidx(c-numel(lfchanidx)),lpchanidx(d),:);</div>
<div>                else</div>
<div>                    cohtmp(cnt,1) = cohdata(rfchanidx(c-numel(lfchanidx)),rpchanidx(d-numel(lpchanidx)),:);</div>
<div>                end</div>
<div>            end</div>
<div>            </div>
<div>            cnt = cnt + 1;</div>
<div>        end</div>
<div>    end</div>
<div>    % ~ average across electrode pairs</div>
<div>    frontalvsparietal_coh = mean(cohtmp); clear cohtmp</div>
<div>    </div>
<div>end</div>
<div><br>
</div>
<div>% Save File</div>
<div>filename = strcat('rest_cohconn_roi_',num2str(lf),'_',num2str(hf),'_',reference,'.mat');</div>
<div>save([conndir filename], '*_coh','*chans');</div>
<div><br>
</div>
Thank you for your time and help.</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sincerely,</div>
<div>
<div style="font-family: "Times New Roman", Times, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div></div>
<div></div>
<div></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p style="margin-top:0px; margin-bottom:0px"></p>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-size:12pt; font-family:"Times New Roman",Times,serif">Michelle (Yee Suet) Wong</span></div>
<span style="font-family:"Times New Roman",Times,serif"></span>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="font-size:12pt; font-family:"Times New Roman",Times,serif">BHK, MSc, PhD Candidate</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-size:12pt; font-family:"Courier New",monospace"><span style="color:rgb(33,33,33); font-family:"Times New Roman",Times,serif; font-size:16px">Western University</span><br>
</span></div>
<span style="font-family:"Times New Roman",Times,serif"></span>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="font-size:12pt; font-family:"Times New Roman",Times,serif">School of </span><font color="#212121" face="Courier New, monospace"><span style="font-family:"Times New Roman",Times,serif">Kinesiology </span></font></div>
<span style="font-family:"Times New Roman",Times,serif"></span>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-family:"Times New Roman",Times,serif"></span><font color="#212121" face="Courier New, monospace"><span style="font-family:"Times New Roman",Times,serif">Faculty of Health Sciences</span></font></div>
<span style="font-family:"Times New Roman",Times,serif"></span>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="font-size:12pt; font-family:"Courier New",monospace"><span style="color:rgb(33,33,33); font-family:"Times New Roman",Times,serif; font-size:16px">Exercise, Mobility, and Brain Health
 Lab</span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(33,33,33)">
<span style="font-family:"Times New Roman",Times,serif"></span><span style="font-size:12pt; font-family:"Times New Roman",Times,serif">London, Ontario, Canada</span></div>
<div><span style="font-size:12pt; font-family:"Courier New",monospace"><br>
</span></div>
<br>
<p style="margin-top:0px; margin-bottom:0px"></p>
</div>
</div>
</div>
</div>
</body>
</html>