-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC5_Permuting_SEEG_ECOG_cross_subject_classifciations.m
74 lines (71 loc) · 4.38 KB
/
C5_Permuting_SEEG_ECOG_cross_subject_classifciations.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
% This code shuffles contact labels and recalcualtes the classification
% performance (AUCs) 1000 times to generate the null distribution for statistical
% inference: this was done for all of the six classifications we performed including
% Within-patient classification (interictal and ictal)
% Across-patient generalisation (interictal and ictal)
% Across-time generalisation (interictal to ictal and vice versa)]
% It does it separately for SEEG and ECOG Patients
% INPUTS: classification data from C4_Classif_gen_acrss_patnt_inter_or_ictl_cmb_feat_ovrsp_EEGECOG
% OUTPUTS: classification data + random data to be plotted by C6_Plotting_classification_and_feature_import_SEEG_ECOG
%%
clc;
clear all;
close all;
SEEG=2; % 1=seeg; 2==ecog
%% 3 and 4: across-patient generalisation
ictal_or_inter='interictal';
if SEEG==1
load(['Generalisation_performance_across_subjects_SEEG_',ictal_or_inter,'_all_feats_comb_crcted_feats_ovrsmp_imp_100_10_30bags.mat'])
else
load(['Generalisation_performance_across_subjects_ECOG_',ictal_or_inter,'_all_feats_comb_crcted_feats_ovrsmp_imp_100_10_30bags.mat'])
end
classif=1; % 1= decision-tree classification
ff=1; % 1= all feaures included
iter_rand=1; % 1= number of iterations
for iter_equalis=1:size(Ground_truth,2) % iterations
for p=1:size(Ground_truth,3) % patients
Performance_acrss_subj_inter(ff,iter_equalis,p,iter_rand,1:7)=Evaluate(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions{ff,iter_equalis,p,iter_rand,classif});
[~,~,~,Performance_acrss_subj_inter(ff,iter_equalis,p,iter_rand,8)]=perfcurve(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions{ff,iter_equalis,p,iter_rand,classif},1);
for rep=1:1000 % repititions
Predictions_tmp=randsample(Predictions{ff,iter_equalis,p,iter_rand,classif},length(Predictions{ff,iter_equalis,p,iter_rand,classif}));
Performance_rand_acrss_subj_inter(ff,iter_equalis,p,iter_rand,1:7,rep)=Evaluate(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions_tmp);
[~,~,~,Performance_rand_acrss_subj_inter(ff,iter_equalis,p,iter_rand,8,rep)]=perfcurve(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions_tmp,1);
end
end
end
Performance_acrss_subj_inter=squeeze(Performance_acrss_subj_inter);
Performance_rand_acrss_subj_inter=squeeze(Performance_rand_acrss_subj_inter);
[3]
ictal_or_inter='ictal';
if SEEG==1
load(['Generalisation_performance_across_subjects_SEEG_',ictal_or_inter,'_all_feats_comb_crcted_feats_ovrsmp_imp_100_10_30bags.mat'])
else
load(['Generalisation_performance_across_subjects_ECOG_',ictal_or_inter,'_all_feats_comb_crcted_feats_ovrsmp_imp_100_10_30bags.mat'])
end
classif=1; % 1= decision-tree classification
ff=1; % 1= all feaures included
iter_rand=1; % 1= number of iterations
for iter_equalis=1:size(Ground_truth,2) % iterations
for p=1:size(Ground_truth,3) % patients
Performance_acrss_subj_ictal(ff,iter_equalis,p,iter_rand,1:7)=Evaluate(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions{ff,iter_equalis,p,iter_rand,classif});
[~,~,~,Performance_acrss_subj_ictal(ff,iter_equalis,p,iter_rand,8)]=perfcurve(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions{ff,iter_equalis,p,iter_rand,classif},1);
for rep=1:1000 % repititions
Predictions_tmp=randsample(Predictions{ff,iter_equalis,p,iter_rand,classif},length(Predictions{ff,iter_equalis,p,iter_rand,classif}));
Performance_rand_acrss_subj_ictal(ff,iter_equalis,p,iter_rand,1:7,rep)=Evaluate(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions_tmp);
[~,~,~,Performance_rand_acrss_subj_ictal(ff,iter_equalis,p,iter_rand,8,rep)]=perfcurve(Ground_truth{ff,iter_equalis,p,iter_rand},Predictions_tmp,1);
end
end
end
Performance_acrss_subj_ictal=squeeze(Performance_acrss_subj_ictal);
Performance_rand_acrss_subj_ictal=squeeze(Performance_rand_acrss_subj_ictal);
[1]
%% Saving the data and the permuted null data for all 6 classifications
if SEEG==1
save('random_permutations_SEEG.mat',...
'Performance_acrss_subj_ictal','Performance_acrss_subj_inter',...
'Performance_rand_acrss_subj_ictal','Performance_rand_acrss_subj_inter','-v7.3')
else
save('random_permutations_ECOG.mat',...
'Performance_acrss_subj_ictal','Performance_acrss_subj_inter',...
'Performance_rand_acrss_subj_ictal','Performance_rand_acrss_subj_inter','-v7.3')
end