# [Eeglablist] ERSP bootstrap outside of newtimef

Mon Oct 23 16:05:32 PDT 2017

```Ok, last followup for today! I have tried two things- the above, and
another method which I'll discuss below. In both cases, comparing tftopo
plots both with the signifs argument and without it turned out identically,
which makes me skeptical of whether what I'm doing is working at all.

The second method I'm trying is:

*    idx = 1;*
*    for k = freqs*
*        [rsignif(idx,:) rbot{idx}] = bootstat({a(idx,:) b(idx,:)}, 'arg1 -
arg2', ...*
*            'basevect', [27 28 29 30 31 32 33 34 35 36 37], 'alpha', 0.01,
'dimaccu', 2);*
*        idx = idx+1;*
*    end*

Where a and b are freqs x samples matrices for the two conditions, averaged
across my channels of interest. So it loops through each frequency,
shuffles samples, and if I understand correctly, should make a comparison
across permutations based on the difference between the two conditions. I
feel like either method should be fine for the purpose of masking the ersps
and I'm not even sure if the rsignifs for these two methods would even be
all that different, but the fact that it doesn't seem to be working
suggests I'm doing something wrong or misunderstanding something.

Best,
Max

On Mon, Oct 23, 2017 at 4:13 PM, Max Cantor <Max.Cantor at colorado.edu> wrote:

> To follow up, I believe I have gotten the code to "work", although I would
> appreciate confirmation on whether what I'm doing is conceptually sound, or
> if I am misunderstanding the code or purpose of the statistic.
>
> Below is my code:
>
> *[rsignif rbot] = bootstat(permute(g_ersp, [2,1,3]), 'mean(arg1,3);',
> 'basevect', [27 28 29 30 31 32 33 34 35 36 37], 'alpha', 0.01, 'dimaccu',
> 2);*
>
> Where g_ersp is a grand average of ersp of 200 samples (of data from ~
> -1000 to 2000ms) x 48 frequencies (log-spaced) x 7 channels. This grand
> average is the difference between two conditions, averaged across all
> subjects, where each subjects ersp is an average across all trials. I
> permute the matrix so that it is freqs x samples x chans, which is similar
> to what bootstat is doing on a subject-by-subject basis in my pop_newtimef
> code, except there it's only one condition, not a difference between
> conditions, and the third dimension is trials instead of channels.
>
> The mean(arg1,3) formula came directly from debugging in bootstat from
> pop_newtimef. While in pop_newtimef this would be averaging across trials,
> if I'm interested in finding which time-frequency clusters are significant
> across all channels (or from the average across all channels), does this
> still make sense?
>
> The baseline vector comes from the baseline I used on these ersp data,
> alpha is consistent with what I did on the single-subject/single-channel
> level, and I don't even know what dimaccu is but this was also taken from
> debug.
>
> rsignif ends up being my freq x 2 matrix which I can input in tftopo, so I
> run this:
>
>
> *tftopo(mean(g_ersp,3), times, freqs, 'logfreq', 'native', 'signifs',
> rsignif);*
>
> So I'm plotting the grand-average difference ersp averaged across all
> channels, using the appropriate times and freqs axis, the ersp were
> natively log-scaled, and my mask is rsignif from above.
>
> To reiterate, is this mask appropriate for these data? Is this showing me
> the time-frequency clusters averaged across all channels which are
> significant (relative to my alpha)?
>
> Thanks,
> Max
>
>
>
> On Thu, Oct 19, 2017 at 5:33 PM, Max Cantor <Max.Cantor at colorado.edu>
> wrote:
>
>> Hi,
>>
>> I've produced grand-averaged TFRs across all of my subjects, at select
>> channels, and taken the difference between two conditions, by looping
>> through pop_newtimef for each subject and each channel of interest across
>> both conditions separately, outputting these into separate 4-D arrays,
>> averaging across subjects, and then taking the difference between the two
>> arrays, such that I end up with an ersp difference array of freq x
>> timepoint x chan.
>>
>> This array is compatible with the tftopo function and I would like to
>> apply a bootstrapped statistical mask to this array through the tftopo
>> function. Testing it with an erspboot mask outputted by pop_newtimef was
>> functional, however this erspboot mask was obviously specific to that
>> particular subject and channel and not appropriate for my grand averaged
>> array.
>>
>> Is there a conceptually and computationally simple way to run this array
>> through the bootstat function (which I believe is what's producing the
>> statistical masking) outside of pop_newtimef and produce a freqs x 2
>> erspboot mask that would be compatible with tftopo, or would it be easier
>> for me to just reformat my array into a fieldtrip structure and use their
>> functions for nonparametric cluster-based permutation testing, which to the
>> best of my knowledge is the mathematical implementation eeglab uses anyway?
>>
>>
>> Thanks,
>> Max
>>
>> --
>> Max Cantor
>> Cognitive Neuroscience of Language Lab
>>
>
>
>
> --
> Max Cantor
> Cognitive Neuroscience of Language Lab
>

--
Max Cantor