<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Philip,
<div class=""><br class="">
</div>
<div class="">It is not possible to use ft_redefinetrial on time-frequency data, I am pretty sure that the function’s help is pretty clear on how it ought to be used.</div>
<div class=""><br class="">
</div>
<div class="">I don’t know what you mean with ‘boundary effects’, but perhaps it brings you some peace of mind to know that ft_freqanalysis only returns an estimate of time-resolved power for those time points for which the shifting time-window if completely
 filled with data samples. Otherwise it will return a NaN.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 18 Nov 2021, at 21:41, philip Joadavi via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Dear all,
<div class=""><br class="">
</div>
<div class="">I have continuous EEG data and I would like to first compute the time-frequency analysis to avoid any boundary effects etc, and then define my trials.</div>
<div class="">so I want to do the following:</div>
<div class="">1- time frequency analysis</div>
<div class="">2- define trials</div>
<div class="">3- average over TRF trials</div>
<div class="">4- average over subjects</div>
<div class=""><br class="">
</div>
<div class="">However, after defining the trials, my 3dimential data becomes 2 dimensional. I would like to know if there is any function in FieldTrip that I can use to keep the trial dimension as it is?</div>
<div class="">I would also like to know how can I get the average over my TRF over trials and subjects with the same dimension. </div>
<div class=""><br class="">
</div>
<div class="">here is the code I'm using:</div>
<div class="">
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg <span class="gmail-Apple-converted-space">          </span>= [];</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trials<span class="gmail-Apple-converted-space">    </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'all'</span>;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.channel <span class="gmail-Apple-converted-space">  </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'EEG'</span>;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.output<span class="gmail-Apple-converted-space">    </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'pow'</span>; <span class="gmail-Apple-converted-space">        </span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.method<span class="gmail-Apple-converted-space">    </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'mtmconvol'</span>; <span class="gmail-Apple-converted-space">  </span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.taper <span class="gmail-Apple-converted-space">    </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'hanning'</span>; <span class="gmail-Apple-converted-space">    </span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.pad <span class="gmail-Apple-converted-space">      </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'nextpow2'</span>;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.keeptrials = <span class="gmail-s1" style="color:rgb(160,32,240)">'yes'</span>;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.foi <span class="gmail-Apple-converted-space">      </span>= 10:.5:40;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.toi <span class="gmail-Apple-converted-space">      </span>= data.time{1};</div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">
</p>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.t_ftimwin = 0.5*ones(size(cfg.foi));</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:10px;line-height:normal;font-family:Courier">
</p>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
df{t} <span class="gmail-Apple-converted-space">        </span>= ft_freqanalysis(cfg,data);</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
--------</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg <span class="gmail-Apple-converted-space">                    </span>= [];</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.fsample <span class="gmail-Apple-converted-space">            </span>= fsample;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trialdef.prestim<span class="gmail-Apple-converted-space">    </span>= preStim ;
<span class="gmail-Apple-converted-space">      </span><span class="gmail-s1" style="color:rgb(34,139,34)">% sec</span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trialdef.poststim <span class="gmail-Apple-converted-space">  </span>= postStim ;<span class="gmail-Apple-converted-space">     
</span><span class="gmail-s1" style="color:rgb(34,139,34)">% sec</span></div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trialdef.events <span class="gmail-Apple-converted-space">    </span>= data.trial{1}(e,:);</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trialfun<span class="gmail-Apple-converted-space">            </span>= <span class="gmail-s2" style="color:rgb(160,32,240)">
'eegTrialFun'</span>;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trialdef.eventvalue = eventValue;</div>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.keeptrials          = <span class="gmail-s2" style="color:rgb(160,32,240)">'yes'</span>;</div>
<p class="gmail-p2" style="margin:0px;font:10px Courier;min-height:12px"><span class="gmail-Apple-converted-space"> </span><br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg <span class="gmail-Apple-converted-space">                    </span>= ft_definetrial(cfg);</div>
</div>
<div class="">----------</div>
<div class="">
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
cfg.trials<span class="gmail-Apple-converted-space">              </span>= <span class="gmail-s1" style="color:rgb(160,32,240)">
'all'</span>;</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
d <span class="gmail-Apple-converted-space">                      </span>= ft_redefinetrial(cfg,df{t});</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
<div style="margin: 0px; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<br class="">
</div>
</div>
<div class="">Thanks a lot!</div>
<div class="">Philip</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!50nUOvdSkbOxHrYmv3dc-wRl08NnWvOp2dVISpmsJOi73PlIA2x8i2AtGIO3v5fggpzjFshrLVify-5T3U6PqqAB37YElXhaK9UtJw$
<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>