Exemple #1
0
def SVM_full_sequences_16itemsY(subject):
    SVM_funcs.apply_SVM_filter_16_items_epochs_habituation(
        subject,
        times=[0.120, 0.190],
        window=True,
        sliding_window=True,
        cleaned=False)
Exemple #2
0
def SVM_full_sequences_16items1(subject):
    # subject = config.subjects_list[0]
    SVM_funcs.apply_SVM_filter_16_items_epochs(subject,
                                               times=[0.130, 0.210],
                                               window=True,
                                               sliding_window=True,
                                               cleaned=True)
Exemple #3
0
def SVM_full_sequences_16items(subject):
    # ----- We test on the 16 items sequences. We average the predictions of the decoders between 140 and 180 ms -----
    SVM_funcs.apply_SVM_filter_16_items_epochs(subject,
                                               times=[0.140, 0.180],
                                               window=True,
                                               sliding_window=True)
    SVM_funcs.apply_SVM_filter_16_items_epochs_habituation(
        subject, times=[0.140, 0.180], window=True, sliding_window=True)
Exemple #4
0
def SVM_features_number_ofOpenedChunks(subject,
                                       load_residuals_regression=False,
                                       cleaned=True):
    SVM_funcs.SVM_feature_decoding_wrapper(
        subject,
        'OpenedChunks',
        SVM_dec=SVM_funcs.regression_decoder(),
        balance_features=False,
        distance=False,
        load_residuals_regression=load_residuals_regression,
        cross_val_func=None,
        list_sequences=[3, 4, 5, 6, 7])
Exemple #5
0
def SVM_features_stimID(subject,
                        load_residuals_regression=True,
                        cross_validation=None):
    SVM_funcs.SVM_feature_decoding_wrapper(
        subject,
        'StimID',
        load_residuals_regression=load_residuals_regression,
        list_sequences=[3, 4, 5, 6, 7],
        cross_val_func=cross_validation)
Exemple #6
0
def SVM_features_number_ofOpenedChunks(subject,
                                       load_residuals_regression=True):
    if load_residuals_regression:
        resid_suffix = 'resid_cv_'
    else:
        resid_suffix = 'full_data_'
    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'OpenedChunks',
        SVM_dec=SVM_funcs.regression_decoder(),
        load_residuals_regression=load_residuals_regression,
        list_sequences=[3, 4, 5, 6, 7],
        crop=[-0.1, 0.4],
        cross_val_func=None,
        balance_features=False,
        distance=False)
    save_name = config.SVM_path + subject + '/feature_decoding/' + resid_suffix + 'Number_Open_Chunks' + '_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
Exemple #7
0
def SVM_features_repeatalter(subject,
                             load_residuals_regression=False,
                             cross_validation=None):
    SVM_funcs.SVM_feature_decoding_wrapper(
        subject,
        'RepeatAlter',
        load_residuals_regression=load_residuals_regression,
        list_sequences=[3, 4, 5, 6, 7],
        cross_val_func=cross_validation)
Exemple #8
0
def SVM_features_withinchunk(subject,
                             load_residuals_regression=False,
                             cross_validation=None):
    SVM_funcs.SVM_feature_decoding_wrapper(
        subject,
        'WithinChunkPosition',
        load_residuals_regression=load_residuals_regression,
        list_sequences=[4, 5, 6],
        cross_val_func=cross_validation,
        nvalues_feature=4)
Exemple #9
0
def SVM_quad_ordpos(subject, cleaned=True):
    SVM_funcs.SVM_feature_decoding_wrapper(
        subject,
        'WithinChunkPosition',
        load_residuals_regression=False,
        list_sequences=[4],
        cross_val_func=None,
        filter_from_metadata="StimPosition > 2 and StimPosition < 15",
        nvalues_feature=4,
        clean=cleaned)
Exemple #10
0
def localize_standard_VS_deviant_code(subject,n_permutations = 2000,n_channels = 30,select_grad=False,cleaned=True):

    # ----------- load the epochs ---------------
    epochs = epoching_funcs.load_epochs_items(subject, cleaned=cleaned)
    epochs.pick_types(meg=True)

    # ----------- balance the position of the standard and the deviants -------
    # 'local' - Just make sure we have the same amount of standards and deviants for a given position. This may end up with
    #     1 standards/deviants for position 9 and 4 for the others.
    epochs_balanced = epoching_funcs.balance_epochs_violation_positions(epochs,balance_param="local")
    # ----------- do a sliding window to smooth the data -------
    epochs_balanced = epoching_funcs.sliding_window(epochs_balanced)

    # =============================================================================================
    toi = 0.165
    epochs_for_decoding = epochs_balanced.copy().crop(tmin=toi, tmax = toi)
    training_inds, testing_inds = SVM_funcs.train_test_different_blocks(epochs_for_decoding, return_per_seq=False)
    y_violornot = np.asarray(epochs_for_decoding.metadata['ViolationOrNot'].values)
    labels_train = [y_violornot[training_inds[i]] for i in range(2)]
    labels_test = [y_violornot[testing_inds[i]] for i in range(2)]

    performance_loc = compute_sensor_weights_decoder(epochs_for_decoding,
                                                          SVM_funcs.SVM_decoder(),
                                                          training_inds,
                                                          labels_train,
                                                          testing_inds,
                                                          labels_test, None,
                                                          None, n_permutations,
                                                          n_channels,select_grad=select_grad)

    suffix = ''
    if select_grad:
        suffix = 'only_grad'

    save_path = config.result_path + '/localization/Standard_VS_Deviant/'
    utils.create_folder(save_path)
    save_path_subject = save_path + subject + '/'+suffix
    utils.create_folder(save_path_subject)

    np.save(save_path_subject + 'results'+str(n_permutations)+'_permut'+str(n_channels)+'_chans'+'_'+str(round(toi*1000))+'.npy', performance_loc)
Exemple #11
0
def SVM_quad_ordpos(subject):

    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'WithinChunkPosition',
        load_residuals_regression=True,
        list_sequences=[4],
        crop=[-0.1, 0.4],
        cross_val_func=None,
        filter_from_metadata="StimPosition > 2 and StimPosition < 15")
    save_name = config.SVM_path + subject + '/feature_decoding/' + 'resid_' + 'WithinChunkPosition' + '_quads_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'WithinChunkPosition',
        load_residuals_regression=False,
        list_sequences=[4],
        crop=[-0.1, 0.4],
        cross_val_func=None,
        filter_from_metadata="StimPosition > 2 and StimPosition < 15")
    save_name = config.SVM_path + subject + '/feature_decoding/' + 'full_data_' + 'WithinChunkPosition' + '_quads_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
Exemple #12
0
def SVM_features_stimID_eeg(subject, load_residuals_regression=True):
    if load_residuals_regression:
        resid_suffix = 'resid_cv_'
    else:
        resid_suffix = 'full_data_'
    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'StimID',
        load_residuals_regression=load_residuals_regression,
        crop=[-0.1, 0.4],
        cross_val_func=None,
        meg=False)
    save_name = config.SVM_path + subject + '/feature_decoding/' + resid_suffix + 'StimID' + '_EEGONLY_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
Exemple #13
0
def SVM_features_chunkBeg(subject, load_residuals_regression=True):
    if load_residuals_regression:
        resid_suffix = 'resid_cv_'
    else:
        resid_suffix = 'full_data_'
    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'ChunkBeginning',
        load_residuals_regression=load_residuals_regression,
        list_sequences=[3, 4, 5, 6, 7],
        crop=[-0.1, 0.4],
        cross_val_func=None)
    save_name = config.SVM_path + subject + '/feature_decoding/' + resid_suffix + 'ChunkBeg' + '_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
Exemple #14
0
def SVM_features_withinchunk_train_quads_test_others(
        subject, load_residuals_regression=True):
    if load_residuals_regression:
        resid_suffix = 'resid_cv_'
    else:
        resid_suffix = 'full_data_'
    score, distance, times = SVM_funcs.SVM_decode_feature(
        subject,
        'WithinChunkPosition',
        load_residuals_regression=load_residuals_regression,
        crop=[-0.1, 0.4],
        cross_val_func=SVM_funcs.train_quads_test_others,
        balance_features=False,
        filter_from_metadata="StimPosition > 2 and StimPosition < 15")
    save_name = config.SVM_path + subject + '/feature_decoding/' + resid_suffix + 'WithinChunkPosition_train_Quads_test_others' + '_score_dict.npy'
    np.save(save_name, {'score': score, 'times': times, 'distance': distance})
Exemple #15
0
def SVM_GAT_all_sequences(subject):
    SVM_funcs.GAT_SVM(subject,
                      load_residuals_regression=True,
                      sliding_window=True)
Exemple #16
0
def GAT_SVM_separate_seq(subject):
    SVM_funcs.GAT_SVM_trained_separate_sequences(
        subject, load_residuals_regression=True, sliding_window=True)
Exemple #17
0
def SVM_full_sequences_16items2(subject):
    SVM_funcs.apply_SVM_filter_16_items_epochs(subject,
                                               times=[0.210, 0.410],
                                               window=True,
                                               sliding_window=True,
                                               cleaned=True)
Exemple #18
0
def SVM_generate_different_sequences(subject):
    # SVM_funcs.generate_SVM_separate_sequences(subject, load_residuals_regression=True,sliding_window=True)
    SVM_funcs.GAT_SVM_trained_separate_sequences(
        subject, load_residuals_regression=True, sliding_window=True)