<div dir="ltr"><span style="color:rgb(20,24,35);font-family:'lucida grande',tahoma,verdana,arial,sans-serif;font-size:13px;line-height:17.940000534057617px">Dear FieldTrippers,</span><br><div><br></div><div>I'm Dragos Stanciu and I'm working on my MSc in Neuroinformatics dissertation at the University of Edinburgh. My project involves analysis of resting-state functional connectivity using graph theory in Alzheimer's disease based on MEG data.</div>
<div><br></div><div>Each of my subjects has a number of 10s epochs (trials) associated with him/her. I was able to compute the coherence and weighted phase lag index measures (with <i>ft_freqanalysis </i>and <i>ft_connectivityanalysis) </i>by treating my 10s epochs as trials, but now I would like to reduce the amount of noise in the estimation of the frequency spectrum by employing Welch's method. </div>
<div><br></div><div>For this, I split each 10s epoch in 2s segments (minitrials) with 50% overlap:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  [<font face="courier new, monospace">sep_epoch_data] = ft_redefinetrial(cfg_cut, single_epoch_data)</font><i>. </i></blockquote><div><div><br></div><div>I then apply <i>ft_preprocessing </i>on the minitrials: </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace"> [processed_single_epoch] = ft_preprocessing(cfg, sep_epoch_data);</font></blockquote><div> </div><div>I then do frequency analysis on the preprocessed segmented data:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<font face="courier new, monospace">[single_epoch_freq] = ft_freqanalysis(cfg_freq, processed_single_epoch);</font></blockquote><div>where</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
display(cfg_freq)<br>        method: 'mtmfft'<br>         taper: 'hanning'<br>        foilim: [0.5000 4]<br>        output: 'powandcsd'<br>       channel: {148x1 cell}    % 148 channels labelled from A1 to A148<br>
     keeptrial: 'no'     % don't keep the minitrials, as we want to average them<br>    keeptapers: 'no'</blockquote><div>Please note that I average the minitrials (<i>keeptrial = 'no'</i>) as I want to get an average of the frequencies.<br>
</div><div><br></div><div>The resulting <i>single_epoch_freq</i> structure looks like:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
display(single_epoch_freq)     <br>label: {148x1 cell}    <br>       dimord: 'chan_freq'<br>         freq: [0.5001 1.0002 1.5004 2.0005 2.5006 3.0007 3.5008 4.0009]<br>    powspctrm: [148x8 double]<br>     labelcmb: {10878x2 cell}     % channel combinations (148*147/2)<br>
    crsspctrm: [10878x8 double]<br>          cfg: [1x1 struct]</blockquote></div><div><br></div><div>The last step is to append the averaged frequency structures of each 10s epoch together and perform connectivity analysis on the main 10s epochs. I do the concatenation like so:</div>
<div><div><font face="courier new, monospace" size="1">freq_avgs_powspctrm = [freq_avgs_powspctrm; permute(single_epoch_freq.powspctrm, [3,1,2])];</font></div><div><font face="courier new, monospace" size="1"><br></font></div>
<div><font face="courier new, monospace" size="1">freq_avgs_crsspctrm = [freq_avgs_crsspctrm; permute(single_epoch_freq.crsspctrm, [3,1,2])];</font></div></div><div><br></div><div>The idea behind <i>permute(..., [3, 1, 2])</i> is that I want the first dimension to represent trials, the second dimension channel combinations and the third dimension frequencies, as this is needed for the input of <i>ft_connectivity_wpli </i>(Repetitions x Channelcombination (x Frequency)).</div>
<div><br></div><div>I then call<font face="courier new, monospace"> stat_conn = ft_connectivityanalysis(cfg_conn, freq_avgs);</font></div><div>where:</div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
display(cfg_conn)<br>     method: 'wpli_debiased'<br>    channel: {148x1 cell}</blockquote></div><div>and</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
display(freq_avgs)<br>     powspctrm: [4x148x8 double]      % as I have 4 ten second epochs<br>    crsspctrm: [4x10878x8 double]     % as I have 4 ten second epochs<br>        label: {148x1 cell}<br>       dimord: 'chan_freq'<br>
         freq: [0.5001 1.0002 1.5004 2.0005 2.5006 3.0007 3.5008 4.0009]<br>     labelcmb: {10878x2 cell}<br>          cfg: [1x1 struct]</blockquote><div><br></div><div>The error that I get when running <i>ft_connectivityanalysis</i> is:</div>
<div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Error using cat<br>CAT arguments dimensions are not consistent.<br>
Error in ft_checkdata>fixcsd (line 1170)<br>    data.crsspctrm = cat(catdim, data.powspctrm, data.crsspctrm);</blockquote></div><div><br></div><div>When debugging, <i>catdim</i> is equal to 1. The error occurs because the 2nd dimension of data.powspctrm and data.crsspctrm are not equal (former is 148, latter is 10878). Do you have any suggestions on getting around this problem? Should I construct <i>freq_avgs </i>(data input to ft_connectivityanalysis) differently? I'm also open to different approaches to working out Welch's method in FieldTrip.</div>
<div><br></div><div>Please download this archive that contains my test script and 4 example 10s epochs of a subject: <a href="https://www.dropbox.com/s/js7pztai02f5p27/Welch_fieldtrip.zip">https://www.dropbox.com/s/js7pztai02f5p27/Welch_fieldtrip.zip</a> The code should make things clearer (or the opposite).</div>
<div> </div><div>Observations: I thought about using <i>ft_freqanalysis_mtmwelch</i>, but apparently it's deprecated.</div></div><div><br></div><div>Thank you all in advance for your feedback.</div><div><br></div><div>
Kind regards,</div><div>Dragos Stanciu</div></div>