|
|
@ -118,7 +118,7 @@ for fileIndex=1:4 |
|
|
|
%% Q.2.1 and Q.2.2 |
|
|
|
dataMedian = median(abs(data)/0.6745); |
|
|
|
|
|
|
|
factorEstimation = polyval(empiricalRule, dataMedian); |
|
|
|
%factorEstimation = polyval(empiricalRule, dataMedian); |
|
|
|
factorEstimation = 4; |
|
|
|
threshold = factorEstimation * dataMedian; |
|
|
|
numberOfSpikes = 0; |
|
|
@ -260,7 +260,21 @@ for fileIndex=1:4 |
|
|
|
% clustering using DB-SCAN algorithm |
|
|
|
% code for DB-SCAN downloaded from here: |
|
|
|
% https://www.peterkovesi.com/matlabfns/ |
|
|
|
[~, dbScanClasses, ~] = dbscan(features(:, 6:7)', 0.4, 20); |
|
|
|
if fileIndex == 1 |
|
|
|
distThreshold = 0.4; |
|
|
|
minPts = 20; |
|
|
|
elseif fileIndex == 2 |
|
|
|
distThreshold = 0.15; |
|
|
|
minPts = 30; |
|
|
|
elseif fileIndex == 3 |
|
|
|
distThreshold = 0.32; |
|
|
|
minPts = 30; |
|
|
|
else |
|
|
|
distThreshold = 0.36; |
|
|
|
minPts = 35; |
|
|
|
end |
|
|
|
|
|
|
|
[~, dbScanClasses, ~] = dbscan(features(:, 6:7)', distThreshold, minPts); |
|
|
|
% fixes classes enumeration |
|
|
|
dbScanClasses(dbScanClasses==1) = 7; |
|
|
|
dbScanClasses(dbScanClasses==3) = 1; |
|
|
@ -293,12 +307,11 @@ for fileIndex=1:4 |
|
|
|
scatter(features(hierarchicalClusters == 2, 6), features(hierarchicalClusters == 2, 7), [], 'r', '*'); |
|
|
|
scatter(features(hierarchicalClusters == 3, 6), features(hierarchicalClusters == 3, 7), [], 'g', '*'); |
|
|
|
scatter(features(hierarchicalClusters == 1, 6), features(hierarchicalClusters == 1, 7), [], 'b', '*'); |
|
|
|
title(['Dataset #' num2str(fileIndex) ' feature plot after clustering with K-Means']); |
|
|
|
title(['Dataset #' num2str(fileIndex) ' feature plot after clustering with hierarchical clustering']); |
|
|
|
xlabel('PCA feature 1'); |
|
|
|
ylabel('PCA feature 2'); |
|
|
|
accuracy = classperf(spikeClass',hierarchicalClusters); |
|
|
|
fprintf('Accuracy achieved with K-Means is %.2f%%\n\n', accuracy.CorrectRate*100); |
|
|
|
|
|
|
|
fprintf('Accuracy achieved with hierarchical clustering is %.2f%%\n\n', accuracy.CorrectRate*100); |
|
|
|
|
|
|
|
% clustering using kmeans algorithm |
|
|
|
rng(1); % For reproducibility |
|
|
|