Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. load('P300data.mat')
  2. epochs = extract_epochs(P300Data(:,4),flash_times,flash_ids,0.1*Fs,0.6*Fs);
  3.  
  4. p2p_vals = peak2peak(epochs.data, 2);
  5. epochs.data = epochs.data(p2p_vals < 100, :);
  6. epochs.ids = epochs.ids(p2p_vals < 100);
  7.  
  8. features_target = epochs.data(epochs.ids == 2, :);
  9. features_non_target = epochs.data(epochs.ids == 1, :);
  10.  
  11. target_erp = mean(features_target, 1);
  12. nontarget_erp = mean(features_non_target, 1);
  13.  
  14. hold on
  15. times = ((1:size(epochs.data,2)) - 0.1*Fs)/Fs;
  16. plot(times, target_erp)
  17. plot(times, nontarget_erp)
  18. xlabel('Time (ms)')
  19. ylabel('Potential (uV)')
  20. legend('Target', 'Non-target')
  21.  
  22. var = epochs.data;
  23. features = p300_features(var');
  24. features2 = p300_features(features_target');
  25. features3 = p300_features(features_non_target');
  26.  
  27. features2_labels = ones( length(features2), 1 );
  28. features3_labels = 2 * ones( length(features2), 1 );
  29.  
  30. both = [features2; features3];
  31. both_labels = [features2_labels; features3_labels];
  32.  
  33. figure
  34. scatter3( features2(:, 1), features2(:, 2), features2(:, 3), 'g' ) ;
  35. hold on
  36. scatter3( features3(:, 1), features3(:, 2), features3(:, 3), 'r' ) ;
  37. hold off
  38. legend('target', 'non-target')
  39.  
  40. model = fitcdiscr( both, both_labels, 'DiscrimType', 'linear') ;
  41. CVmodel = crossval(model, 'KFold', 5);
  42. CVerror = kfoldLoss(CVmodel);
  43.  
  44. model2 = fitcsvm( both, both_labels, 'KernelFunction', 'RBF');
  45. CVmodel1 = crossval(model2, 'KFold', 5);
  46. CVerror1 = kfoldLoss(CVmodel1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement