<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="">
Dear Anqi,
<div class=""><br class="">
</div>
<div class="">I can imagine indeed that (the rather old code of) ft_freqgrandaverage does not deal elegantly with subject-specific missing channel data. Indeed, when I read the code at <a href="https://urldefense.com/v3/__https://github.com/fieldtrip/fieldtrip/blob/master/ft_freqgrandaverage.m__;!!HJOPV4FYYWzcc1jazlU!9jLKntTeLg3NY3-97TjouwQfEZrJWMD78ZXV8zQuqrD1V8Sefrz7OcGadGUVnacYJQU7mmPTlnFPkTiW1qkQzjnsv8yb9iLPcld8jg$" class="">https://github.com/fieldtrip/fieldtrip/blob/master/ft_freqgrandaverage.m</a>
 there is no mention of a cfg.nanmean option in the help documentation of the function, nor can I find anything relating to nans in the code itself. It is still on the to-do list to replace the function’s code by a more up-to-date functionality, possibly using
 a sequence of calls to ft_appendfreq (using cfg.appenddim = ‘rpt’), and then a call to ft_selectdata (in case cfg.keepindividual=’no’), with cfg.avgoverrpt = ‘yes’, and using an optional cfg.nanmean = ‘yes’. I don’t have time to work on this myself anytime
 soon, but would be happy to guide you through the process in making the required changes to the code yourself. The best way to get started would be to create a new issue on the fieldtrip github repository, and then start working towards a mergable pull request
 in an issue branch of your own forked copy of the fieldtrip repo (<a href="https://urldefense.com/v3/__https://www.fieldtriptoolbox.org/development/git/__;!!HJOPV4FYYWzcc1jazlU!9jLKntTeLg3NY3-97TjouwQfEZrJWMD78ZXV8zQuqrD1V8Sefrz7OcGadGUVnacYJQU7mmPTlnFPkTiW1qkQzjnsv8yb9iKSE_JzRA$" class="">https://www.fieldtriptoolbox.org/development/git/</a>).</div>
<div class=""><br class="">
</div>
<div class="">Looking forward to push this forward.</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 6 Feb 2023, at 09:12, Lei, A. (Anqi) 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 class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">Dear FieldTrip list,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">I have a quick question about using “ft_freqgrandaverage” to calculate a group average of powerspectrum while ignoring missing channels across subjects.<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">Some subjects in my dataset have bad channels so I dropped these channels and replaced their values with NaNs instead of doing interpolation. However, “ft_freqgrandaverage” doesn’t seem to ignore these
 NaNs while calculating the grand mean so I ended up with a lot of missing channels in my group average – is there a way for the function to ignore channels with NaNs? (I tried to use cfg.nanmean = 'yes' but it didn’t work).<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">Thank you!<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">Best,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-family: Arial, sans-serif;" class="">Anqi<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
</div>
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!66mu5bmMHKtOoPWBY9-mb7-6gEfnMaiO829WRAA8vv14awdcOZ6uFK0h-Ck9yMlzTOaaz5HcOn4_m2ZvwRlYhU_wjp25TPA75_8YGA$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!66mu5bmMHKtOoPWBY9-mb7-6gEfnMaiO829WRAA8vv14awdcOZ6uFK0h-Ck9yMlzTOaaz5HcOn4_m2ZvwRlYhU_wjp25TPA75_8YGA$</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>