Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- load('P300data.mat')
- epochs = extract_epochs(P300Data(:,4),flash_times,flash_ids,0.1*Fs,0.6*Fs);
- p2p_vals = peak2peak(epochs.data, 2);
- epochs.data = epochs.data(p2p_vals < 100, :);
- epochs.ids = epochs.ids(p2p_vals < 100);
- features_target = epochs.data(epochs.ids == 2, :);
- features_non_target = epochs.data(epochs.ids == 1, :);
- target_erp = mean(features_target, 1);
- nontarget_erp = mean(features_non_target, 1);
- hold on
- times = ((1:size(epochs.data,2)) - 0.1*Fs)/Fs;
- plot(times, target_erp)
- plot(times, nontarget_erp)
- xlabel('Time (ms)')
- ylabel('Potential (uV)')
- legend('Target', 'Non-target')
- var = epochs.data;
- features = p300_features(var');
- features2 = p300_features(features_target');
- features3 = p300_features(features_non_target');
- features2_labels = ones( length(features2), 1 );
- features3_labels = 2 * ones( length(features2), 1 );
- both = [features2; features3];
- both_labels = [features2_labels; features3_labels];
- figure
- scatter3( features2(:, 1), features2(:, 2), features2(:, 3), 'g' ) ;
- hold on
- scatter3( features3(:, 1), features3(:, 2), features3(:, 3), 'r' ) ;
- hold off
- legend('target', 'non-target')
- model = fitcdiscr( both, both_labels, 'DiscrimType', 'linear') ;
- CVmodel = crossval(model, 'KFold', 5);
- CVerror = kfoldLoss(CVmodel);
- model2 = fitcsvm( both, both_labels, 'KernelFunction', 'RBF');
- CVmodel1 = crossval(model2, 'KFold', 5);
- CVerror1 = kfoldLoss(CVmodel1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement