stat = 'beta' #choose whether you want to use the single subject tstats or betas for the analysis
if stat == 'beta':
    dat2use = deepcopy(data)
elif stat == 'tstat':
    dat2use = deepcopy(data_t)

#for channel in ['FCz', 'Cz', 'CPz', 'Pz', 'POz', 'Oz']:
for channel in ['FCz', 'Cz', 'Pz']:
    tmin = 0
    tmax = 1
    
    #incorrect vs definitely correct
    t_ivsd, clu_ivsd, clupv_ivsd, _ = runclustertest_epochs(data = dat2use,
                                                            contrast_name = 'incorrvsdef',
                                                            channels = [channel],
                                                            tmin = tmin,
                                                            tmax = tmax,
                                                            gauss_smoothing = None,
                                                            out_type = 'indices', n_permutations = 10000
                                                            )
    clutimes = deepcopy(dat2use['incorrect'][0]).crop(tmin = tmin, tmax = tmax).times
    masks_ivsd = np.asarray(clu_ivsd)[clupv_ivsd <= 0.05]
    
    
    #incorrect vs just correct
    t_ivsj, clu_ivsj, clupv_ivsj, _ = runclustertest_epochs(data = dat2use,
                                                            contrast_name = 'incorrvsjust',
                                                            channels = [channel],
                                                            tmin = tmin,
                                                            tmax = tmax,
                                                            gauss_smoothing = None,
                                                            out_type = 'indices', n_permutations = 10000
            legend = 'upper right', picks = channel,
            ci = .68, show_sensors = False, title = 'electrode ' + channel,
            truncate_xaxis=False
            )
gave = mne.grand_average(data['incorrvscorr'])

deepcopy(gave).plot_joint(times = np.arange(0.1,0.7,.1),
                title = 'incorr vs corr')
        
#%%
tmin, tmax = 0, 1
for channel in ['FCz', 'Cz']:
    t_ern, clu_ern, clupv_ern, h0_ern = runclustertest_epochs(data = data,
                                                              contrast_name = 'incorrvscorr',
                                                              channels = [channel],
                                                              tmin = tmin,
                                                              tmax = tmax,
                                                              gauss_smoothing = None,
                                                              out_type = 'indices', n_permutations = 'Default'
                                                              )
    clutimes = deepcopy(data['grandmean'][0]).crop(tmin = tmin, tmax = tmax).times
    masks_ern = np.asarray(clu_ern)[clupv_ern < 0.05]
            
    
    fig = plt.figure()
    ax = plt.axes()
    mne.viz.plot_compare_evokeds(
        evokeds = dict(
                corr   = data['correct'],
                incorr = data['incorrect'],
                diff   = data['incorrvscorr']
                ),
예제 #3
0
                             title='incorrect vs just correct',
                             times=np.arange(0.1, 0.6, 0.05))
gave_justvsdef.plot_joint(picks='eeg',
                          topomap_args=dict(outlines='head', contours=0),
                          title='just correct vs definitely correct',
                          times=np.arange(0.1, 0.6, 0.05))

#%%
#nonpara cluster t test to see where diff is significant
tmin, tmax = 0, 1
channel = 'FCz'
t_ivsd, clu_ivsd, clupv_ivsd, H0_ivsd = runclustertest_epochs(
    data=data,
    channels=[channel],
    contrast_name='incorrvsdef',
    tmin=tmin,
    tmax=tmax,
    gauss_smoothing=None,
    out_type='indices',
    n_permutations='Default')
masks_ivsd = np.asarray(clu_ivsd)[clupv_ivsd <= 0.05]

t_ivsj, clu_ivsj, clupv_ivsj, H0_ivsj = runclustertest_epochs(
    data=data,
    channels=[channel],
    contrast_name='incorrvsjust',
    tmin=tmin,
    tmax=tmax,
    gauss_smoothing=None,
    out_type='indices',
    n_permutations='Default')
예제 #4
0
                                 ci=.68,
                                 show_sensors=False,
                                 title='electrode ' + channel,
                                 truncate_xaxis=False)
gave = mne.grand_average(data['errorincorrvscorr'])

deepcopy(gave).plot_joint(times=np.arange(0.1, 0.7, .1),
                          title='error in incorrect vs correct trials')

tmin, tmax = 0, 1
for channel in ['FCz', 'Cz']:
    t_ern, clu_ern, clupv_ern, h0_ern = runclustertest_epochs(
        data=data,
        contrast_name='errorincorrect',
        channels=[channel],
        tmin=tmin,
        tmax=tmax,
        gauss_smoothing=None,
        out_type='indices',
        n_permutations='Default')
    clutimes = deepcopy(data['grandmean'][0]).crop(tmin=tmin, tmax=tmax).times
    masks_ern = np.asarray(clu_ern)[clupv_ern < 0.05]

    fig = plt.figure()
    ax = plt.axes()
    mne.viz.plot_compare_evokeds(
        evokeds=dict(
            corr=data['errorcorrect'],
            incorr=data['errorincorrect'],
            #diff   = data['errorincorrvscorr'],
            all=data['error']),
예제 #5
0
        for channel in ['FCz', 'Cz']:
            dictobj[contrast][channel] = []

clutimes = deepcopy(data['correct'][0]).crop(tmin=tmin, tmax=tmax).times
for contrast in [
        'confdiff_correct', 'confdiff_incorrect', 'confdiff_incorrvscorr',
        'confdiff'
]:
    # for contrast in ['confdiff']:
    for channel in ['FCz', 'Cz']:
        t_cope[contrast][channel], clu_cope[contrast][channel], clupv_cope[
            contrast][channel], h0_cope[contrast][
                channel] = runclustertest_epochs(data=data,
                                                 contrast_name=contrast,
                                                 channels=[channel],
                                                 tmin=tmin,
                                                 tmax=tmax,
                                                 gauss_smoothing=None,
                                                 out_type='indices',
                                                 n_permutations=5000)
        masks_cope[contrast][channel] = np.asarray(
            clu_cope[contrast][channel])[clupv_cope[contrast][channel] < 0.05]

for channel in ['FCz']:
    fig = plt.figure()
    ax = fig.subplots(1)
    mne.viz.plot_compare_evokeds(
        evokeds=dict(correct=data['confdiff_correct'],
                     incorrect=data['confdiff_incorrect'],
                     difference=data['confdiff_incorrvscorr'],
                     all_trials=data['confdiff']),
        colors=dict(correct='#4daf4a',
예제 #6
0
#for channel in ['FCz', 'Cz', 'CPz', 'Pz', 'POz', 'Oz']:
#for channel in ['FCz', 'Cz', 'CPz', 'Pz', 'POz', 'Oz']:
for channel in ['FCz', 'Cz', 'Pz']:
    tmin = 0
    tmax = 1
    clutimes = deepcopy(dat2use['incorrect'][0]).crop(tmin=tmin,
                                                      tmax=tmax).times

    #three contrasts of interest here:

    #incorrect vs definitely correct
    t_ivsd, clu_ivsd, clupv_ivsd, _ = runclustertest_epochs(
        data=dat2use,
        contrast_name='errorincorrvsdef',
        channels=[channel],
        tmin=tmin,
        tmax=tmax,
        gauss_smoothing=None,
        out_type='indices',
        n_permutations=10000)
    masks_ivsd = np.asarray(clu_ivsd)[clupv_ivsd <= 0.05]

    #incorrect vs just correct
    t_ivsj, clu_ivsj, clupv_ivsj, _ = runclustertest_epochs(
        data=dat2use,
        contrast_name='errorincorrvsjust',
        channels=[channel],
        tmin=tmin,
        tmax=tmax,
        gauss_smoothing=None,
        out_type='indices',
예제 #7
0
            ci = .68, show_sensors = False, title = 'electrode ' + channel,
            truncate_xaxis=False
            )
gave = mne.grand_average(data['incorrvscorr'])

deepcopy(gave).plot_joint(times = np.arange(0.1,0.7,.1),
                title = 'incorr vs corr - RM reference',
                picks='eeg')
        

tmin, tmax = 0, 1
for channel in ['FCZ', 'CZ', 'CPZ', 'PZ']:
    t_ern, clu_ern, clupv_ern, h0_ern = runclustertest_epochs(data = data,
                                                              contrast_name = 'incorrvscorr',
                                                              channels = [channel],
                                                              tmin = tmin,
                                                              tmax = tmax,
                                                              gauss_smoothing = None,
                                                              out_type = 'indices', n_permutations = 'Default'
                                                              )
    clutimes = deepcopy(data['grandmean'][0]).crop(tmin = tmin, tmax = tmax).times
    masks_ern = np.asarray(clu_ern)[clupv_ern < 0.05]
            
    
    fig = plt.figure()
    ax = plt.axes()
    mne.viz.plot_compare_evokeds(
        evokeds = dict(
                corr   = data['correct'],
                incorr = data['incorrect'],
                diff   = data['incorrvscorr']
                ),
예제 #8
0
            show_sensors = False, title = 'electrode: '+channel, truncate_xaxis = False)    

# this is reassuring there arent differences in ERP shape based on cueing at either the frontal electrodes of interest
# or at posterior visual (central because central stimulus) electrodes

    
tmin, tmax = 0,1 #set time window for the clustering

#gonna store things in a dictionary so we dont need to constantly rerun
t_ern, clu_ern, clupv_ern, h0_ern = dict(), dict(), dict(), dict()
masks_ern = dict()
clutimes = deepcopy(data['grandmean'][0].crop(tmin = tmin, tmax = tmax).times)
for channel in ['FCz', 'Cz','Pz', 'POz', 'Oz']:
    t_ern[channel], clu_ern[channel], clupv_ern[channel], h0_ern[channel] = runclustertest_epochs(data = data,
                                                                                                  contrast_name = 'cuedvsneutral',
                                                                                                  channels = [channel],
                                                                                                  tmin = tmin, tmax = tmax,
                                                                                                  gauss_smoothing = None,
                                                                                                  out_type = 'indices', n_permutations = 5000)
    masks_ern[channel] = np.asarray(clu_ern[channel])[clupv_ern[channel] < 0.05]

#no clusters survive permutation testing at any electrode, for the difference between cued and neutral
#given this fact, having these regressors (neutral and cued categorical regressors) in the model
# only increases model complexity without better explaining the data in a meaningful way, so we can remove them
#%%
    
#first pass look at scalp topographies (joint plot) for neutral/cued trials and their difference
mne.grand_average(deepcopy(data['pside'])).plot_joint(times = np.arange(0.05, 0.7, 0.1), title = 'probed side (lvsr)')

#plot some posterior channels also incase there are posterior differences based on cueing
for channel in ['PO3', 'PO7', 'O1']:
    mne.viz.plot_compare_evokeds(