-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_GV.m
More file actions
746 lines (707 loc) · 47.3 KB
/
main_GV.m
File metadata and controls
746 lines (707 loc) · 47.3 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
%author Simone Romano 0522500294
clear variables;
close all;
Subject = 'GV'; % it can be 'AZ', 'GV' or 'JE';
maskPath = 'C:\Users\Simone\Google Drive\Magistrale_IntelligenzaComputazionale\IntelligenzaComputazionale\progetto\progetto neuroscienze\Data\GV\GV\GV_Pre&PostCGsmall.msk';
outputPath = 'C:\Users\Simone\Google Drive\Magistrale_IntelligenzaComputazionale\IntelligenzaComputazionale\progetto\progetto neuroscienze\progetto_SimoneRomano_AlessioPetrozziello\matlab_code\extracted_data_GV\';
% add Neuroelf to the path (change the path accordingly!
%addpath(genpath('../Toolboxes/NeuroElf_v10_4562'))
% adding Spider to the path (change the path accordingly!)
%addpath(genpath('./Toolboxes/spider'));
try
% some initialization: getting the names of files, masks and the
% parameters.
NameFiles = GV_getNameFiles_Salerno(Subject);
Params = GV_initializeParams_Salerno;
% read data and protocols
[Data,Params] = GV_importfMRIdata_Salerno(NameFiles,Params);
[DM,Labels,Params] = GV_importProtocol_Salerno(NameFiles,Params);
% extract Trials
[Trials] = GV_getTrials_Salerno(Data,Labels,Params);
catch
% if for some reason the BV reader does not work or the data are not
% accessible, all the data are here
load([Subject '_data.mat']);
end
%this shows flow of operation by calling defined function.
delimiters1 = 2;
delimiters2 = 7;
%compression of Trials matrix
newTrials = dataCompression( Trials, delimiters1, delimiters2 );
%assembly of 96x2018 rows disperse in newTrials structures
matrix4cluster = assemblySingleData(newTrials);
%----------here split matrix4cluster to reserve 10 record for testing
%matrix4cluster = matrix4cluster(11:96,:);
%----------
%******************CLUSTERING******************%
%pam cluster spearman
[clusteredData_PAM_spearman_10,result_PAM_spearman_10,clusterCenterID_spearman_PAM_10] = clusteringSpearmanPAM(matrix4cluster, 10);
[clusteredData_PAM_spearman_20,result_PAM_spearman_20,clusterCenterID_spearman_PAM_20] = clusteringSpearmanPAM(matrix4cluster, 20);
[clusteredData_PAM_spearman_30,result_PAM_spearman_30,clusterCenterID_spearman_PAM_30] = clusteringSpearmanPAM(matrix4cluster, 30);
[clusteredData_PAM_spearman_40,result_PAM_spearman_40,clusterCenterID_spearman_PAM_40] = clusteringSpearmanPAM(matrix4cluster, 40);
[clusteredData_PAM_spearman_50,result_PAM_spearman_50,clusterCenterID_spearman_PAM_50] = clusteringSpearmanPAM(matrix4cluster, 50);
[clusteredData_PAM_spearman_60,result_PAM_spearman_60,clusterCenterID_spearman_PAM_60] = clusteringSpearmanPAM(matrix4cluster, 60);
[clusteredData_PAM_spearman_70,result_PAM_spearman_70,clusterCenterID_spearman_PAM_70] = clusteringSpearmanPAM(matrix4cluster, 70);
[clusteredData_PAM_spearman_80,result_PAM_spearman_80,clusterCenterID_spearman_PAM_80] = clusteringSpearmanPAM(matrix4cluster, 80);
[clusteredData_PAM_spearman_90,result_PAM_spearman_90,clusterCenterID_spearman_PAM_90] = clusteringSpearmanPAM(matrix4cluster, 90);
[clusteredData_PAM_spearman_100,result_PAM_spearman_100,clusterCenterID_spearman_PAM_100] = clusteringSpearmanPAM(matrix4cluster, 100);
%pam cluster pearson
[clusteredData_PAM_pearson_10,result_PAM_pearson_10,clusterCenterID_pearson_PAM_10] = clusteringPearsonPAM(matrix4cluster, 10);
[clusteredData_PAM_pearson_20,result_PAM_pearson_20,clusterCenterID_pearson_PAM_20] = clusteringPearsonPAM(matrix4cluster, 20);
[clusteredData_PAM_pearson_30,result_PAM_pearson_30,clusterCenterID_pearson_PAM_30] = clusteringPearsonPAM(matrix4cluster, 30);
[clusteredData_PAM_pearson_40,result_PAM_pearson_40,clusterCenterID_pearson_PAM_40] = clusteringPearsonPAM(matrix4cluster, 40);
[clusteredData_PAM_pearson_50,result_PAM_pearson_50,clusterCenterID_pearson_PAM_50] = clusteringPearsonPAM(matrix4cluster, 50);
[clusteredData_PAM_pearson_60,result_PAM_pearson_60,clusterCenterID_pearson_PAM_60] = clusteringPearsonPAM(matrix4cluster, 60);
[clusteredData_PAM_pearson_70,result_PAM_pearson_70,clusterCenterID_pearson_PAM_70] = clusteringPearsonPAM(matrix4cluster, 70);
[clusteredData_PAM_pearson_80,result_PAM_pearson_80,clusterCenterID_pearson_PAM_80] = clusteringPearsonPAM(matrix4cluster, 80);
[clusteredData_PAM_pearson_90,result_PAM_pearson_90,clusterCenterID_pearson_PAM_90] = clusteringPearsonPAM(matrix4cluster, 90);
[clusteredData_PAM_pearson_100,result_PAM_pearson_100,clusterCenterID_pearson_PAM_100] = clusteringPearsonPAM(matrix4cluster, 100);
%Hierarchical Pearson clustering
[Z_pearson_10, cluster_Hierarchical_Pearson_10, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 10);
[Z_pearson_20, cluster_Hierarchical_Pearson_20, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 20);
[Z_pearson_30, cluster_Hierarchical_Pearson_30, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 30);
[Z_pearson_40, cluster_Hierarchical_Pearson_40, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 40);
[Z_pearson_50, cluster_Hierarchical_Pearson_50, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 50);
[Z_pearson_60, cluster_Hierarchical_Pearson_60, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 60);
[Z_pearson_70, cluster_Hierarchical_Pearson_70, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 70);
[Z_pearson_80, cluster_Hierarchical_Pearson_80, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 80);
[Z_pearson_90, cluster_Hierarchical_Pearson_90, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 90);
[Z_pearson_100, cluster_Hierarchical_Pearson_100, dissimilarity_Pearson] = getPearsonHierarchicalClustering(matrix4cluster, 100);
%Hierarchical Spearman clustering
[Z_Spearman_10, cluster_Hierarchical_Spearman_10, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 10);
[Z_Spearman_20, cluster_Hierarchical_Spearman_20, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 20);
[Z_Spearman_30, cluster_Hierarchical_Spearman_30, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 30);
[Z_Spearman_40, cluster_Hierarchical_Spearman_40, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 40);
[Z_Spearman_50, cluster_Hierarchical_Spearman_50, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 50);
[Z_Spearman_60, cluster_Hierarchical_Spearman_60, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 60);
[Z_Spearman_70, cluster_Hierarchical_Spearman_70, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 70);
[Z_Spearman_80, cluster_Hierarchical_Spearman_80, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 80);
[Z_Spearman_90, cluster_Hierarchical_Spearman_90, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 90);
[Z_Spearman_100, cluster_Hierarchical_Spearman_100, dissimilarity_Spearman] = getSpearmanHierarchicalClustering(matrix4cluster, 100);
%******************GENERATION OF NeuroElf MAPS WITH CLUSTERED DATA******************%
%pam spearman maps
neuroElfVisualization(maskPath, result_PAM_spearman_10, strcat(outputPath,'MAP_cluster_PAM_Spearman_10'), 0);
neuroElfVisualization(maskPath, result_PAM_spearman_20, strcat(outputPath,'MAP_cluster_PAM_Spearman_20'), 0);
neuroElfVisualization(maskPath, result_PAM_spearman_30, strcat(outputPath,'MAP_cluster_PAM_Spearman_30'), 0);
neuroElfVisualization(maskPath, result_PAM_spearman_40, strcat(outputPath,'MAP_cluster_PAM_Spearman_40'), 0);
neuroElfVisualization(maskPath, result_PAM_spearman_50, strcat(outputPath,'MAP_cluster_PAM_Spearman_50'), 0);
% neuroElfVisualization(maskPath, result_PAM_spearman_60, strcat(outputPath,'MAP_cluster_PAM_Spearman_60'), 0);
% neuroElfVisualization(maskPath, result_PAM_spearman_70, strcat(outputPath,'MAP_cluster_PAM_Spearman_70'), 0);
% neuroElfVisualization(maskPath, result_PAM_spearman_80, strcat(outputPath,'MAP_cluster_PAM_Spearman_80'), 0);
% neuroElfVisualization(maskPath, result_PAM_spearman_90, strcat(outputPath,'MAP_cluster_PAM_Spearman_90'), 0);
% neuroElfVisualization(maskPath, result_PAM_spearman_100, strcat(outputPath,'MAP_cluster_PAM_Spearman_100'), 0);
%pam pearson maps
neuroElfVisualization(maskPath, result_PAM_pearson_10, strcat(outputPath,'MAP_cluster_PAM_Pearson_10'), 0);
neuroElfVisualization(maskPath, result_PAM_pearson_20, strcat(outputPath,'MAP_cluster_PAM_Pearson_20'), 0);
neuroElfVisualization(maskPath, result_PAM_pearson_30, strcat(outputPath,'MAP_cluster_PAM_Pearson_30'), 0);
neuroElfVisualization(maskPath, result_PAM_pearson_40, strcat(outputPath,'MAP_cluster_PAM_Pearson_40'), 0);
neuroElfVisualization(maskPath, result_PAM_pearson_50, strcat(outputPath,'MAP_cluster_PAM_Pearson_50'), 0);
% neuroElfVisualization(maskPath, result_PAM_pearson_60, strcat(outputPath,'MAP_cluster_PAM_Pearson_60'), 0);
% neuroElfVisualization(maskPath, result_PAM_pearson_70, strcat(outputPath,'MAP_cluster_PAM_Pearson_70'), 0);
% neuroElfVisualization(maskPath, result_PAM_pearson_80, strcat(outputPath,'MAP_cluster_PAM_Pearson_80'), 0);
% neuroElfVisualization(maskPath, result_PAM_pearson_90, strcat(outputPath,'MAP_cluster_PAM_Pearson_90'), 0);
% neuroElfVisualization(maskPath, result_PAM_pearson_100, strcat(outputPath,'MAP_cluster_PAM_Pearson_100'), 0);
%Hierarchical spearman maps
neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_10, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_10'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_20, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_20'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_30, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_30'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_40, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_40'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_50, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_50'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_60, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_60'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_70, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_70'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_80, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_80'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_90, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_90'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Spearman_100, strcat(outputPath,'MAP_cluster_Hierarchical_Spearman_100'), 0);
%Hierarchical pearson maps
neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_10, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_10'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_20, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_20'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_30, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_30'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_40, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_40'), 0);
neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_50, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_50'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_60, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_60'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_70, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_70'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_80, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_80'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_90, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_90'), 0);
% neuroElfVisualization(maskPath, cluster_Hierarchical_Pearson_100, strcat(outputPath,'MAP_cluster_Hierarchical_Pearson_100'), 0);
%******************EXTRACTION OF SELECTED ELEMENTS IN START MATRIX******************%
%pam spearman
newData_10_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_10);
newData_20_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_20);
newData_30_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_30);
newData_40_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_40);
newData_50_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_50);
newData_60_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_60);
newData_70_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_70);
newData_80_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_80);
newData_90_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_90);
newData_100_PAM_spearman = Data(:,clusterCenterID_spearman_PAM_100);
%pam pearson
newData_10_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_10);
newData_20_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_20);
newData_30_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_30);
newData_40_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_40);
newData_50_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_50);
newData_60_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_60);
newData_70_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_70);
newData_80_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_80);
newData_90_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_90);
newData_100_PAM_pearson = Data(:,clusterCenterID_pearson_PAM_100);
%linkage pearson
[clusterCeneterID_pearson_Linkage_10, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_10,'sum');
newData_10_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_10);
[clusterCeneterID_pearson_Linkage_20, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_20,'sum');
newData_20_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_20);
[clusterCeneterID_pearson_Linkage_30, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_30,'sum');
newData_30_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_30);
[clusterCeneterID_pearson_Linkage_40, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_40,'sum');
newData_40_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_40);
[clusterCeneterID_pearson_Linkage_50, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_50,'sum');
newData_50_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_50);
[clusterCeneterID_pearson_Linkage_60, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_60,'sum');
newData_60_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_60);
[clusterCeneterID_pearson_Linkage_70, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_70,'sum');
newData_70_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_70);
[clusterCeneterID_pearson_Linkage_80, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_80,'sum');
newData_80_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_80);
[clusterCeneterID_pearson_Linkage_90, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_90,'sum');
newData_90_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_90);
[clusterCeneterID_pearson_Linkage_100, meancorr] = medoids(dissimilarity_Pearson,cluster_Hierarchical_Pearson_100,'sum');
newData_100_Hierarchical_Pearson = Data(:,clusterCeneterID_pearson_Linkage_100);
%linkage spearman
[clusterCeneterID_spearman_Linkage_10, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_10,'sum');
newData_10_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_10);
[clusterCeneterID_spearman_Linkage_20, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_20,'sum');
newData_20_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_20);
[clusterCeneterID_spearman_Linkage_30, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_30,'sum');
newData_30_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_30);
[clusterCeneterID_spearman_Linkage_40, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_40,'sum');
newData_40_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_40);
[clusterCeneterID_spearman_Linkage_50, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_50,'sum');
newData_50_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_50);
[clusterCeneterID_spearman_Linkage_60, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_60,'sum');
newData_60_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_60);
[clusterCeneterID_spearman_Linkage_70, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_70,'sum');
newData_70_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_70);
[clusterCeneterID_spearman_Linkage_80, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_80,'sum');
newData_80_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_80);
[clusterCeneterID_spearman_Linkage_90, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_90,'sum');
newData_90_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_90);
[clusterCeneterID_spearman_Linkage_100, meancorr] = medoids(dissimilarity_Spearman,cluster_Hierarchical_Spearman_100,'sum');
newData_100_Hierarchical_Spearman = Data(:,clusterCeneterID_spearman_Linkage_100);
%STIMA EMODINAMICA
%from trials structure to 3dMatrix 96x8x2018
trials_as_3d_matrix = trialsTo3dMatrix(Trials);
%-------PAM PEARSON-------%
%Pam Pearson 10 stima emodinamica
Pam_Pearson_10_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_10); %96x8x10
Pam_Pearson_10_hemodynamic = mean(Pam_Pearson_10_3dMatrix,1); %1x8x10
tmp = zeros(8,10);
tmp(:,:) = Pam_Pearson_10_hemodynamic(:,:,:);
Pam_Pearson_10_hemodynamic = tmp;
%Pam Pearson 20 stima emodinamica
Pam_Pearson_20_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_20); %96x8x20
Pam_Pearson_20_hemodynamic = mean(Pam_Pearson_20_3dMatrix,1); %1x8x20
tmp = zeros(8,20);
tmp(:,:) = Pam_Pearson_20_hemodynamic(:,:,:);
Pam_Pearson_20_hemodynamic = tmp;
%Pam Pearson 30 stima emodinamica
Pam_Pearson_30_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_30); %96x8x30
Pam_Pearson_30_hemodynamic = mean(Pam_Pearson_30_3dMatrix,1); %1x8x30
tmp = zeros(8,30);
tmp(:,:) = Pam_Pearson_30_hemodynamic(:,:,:);
Pam_Pearson_30_hemodynamic = tmp;
%Pam Pearson 40 stima emodinamica
Pam_Pearson_40_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_40); %96x8x40
Pam_Pearson_40_hemodynamic = mean(Pam_Pearson_40_3dMatrix,1); %1x8x40
tmp = zeros(8,40);
tmp(:,:) = Pam_Pearson_40_hemodynamic(:,:,:);
Pam_Pearson_40_hemodynamic = tmp;
%Pam Pearson 50 stima emodinamica
Pam_Pearson_50_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_50); %96x8x50
Pam_Pearson_50_hemodynamic = mean(Pam_Pearson_50_3dMatrix,1); %1x8x50
tmp = zeros(8,50);
tmp(:,:) = Pam_Pearson_50_hemodynamic(:,:,:);
Pam_Pearson_50_hemodynamic = tmp;
%Pam Pearson 60 stima emodinamica
Pam_Pearson_60_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_60); %96x8x60
Pam_Pearson_60_hemodynamic = mean(Pam_Pearson_60_3dMatrix,1); %1x8x60
tmp = zeros(8,60);
tmp(:,:) = Pam_Pearson_60_hemodynamic(:,:,:);
Pam_Pearson_60_hemodynamic = tmp;
%Pam Pearson 70 stima emodinamica
Pam_Pearson_70_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_70); %96x8x70
Pam_Pearson_70_hemodynamic = mean(Pam_Pearson_70_3dMatrix,1); %1x8x70
tmp = zeros(8,70);
tmp(:,:) = Pam_Pearson_70_hemodynamic(:,:,:);
Pam_Pearson_70_hemodynamic = tmp;
%Pam Pearson 80 stima emodinamica
Pam_Pearson_80_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_80); %96x8x80
Pam_Pearson_80_hemodynamic = mean(Pam_Pearson_80_3dMatrix,1); %1x8x80
tmp = zeros(8,80);
tmp(:,:) = Pam_Pearson_80_hemodynamic(:,:,:);
Pam_Pearson_80_hemodynamic = tmp;
%Pam Pearson 90 stima emodinamica
Pam_Pearson_90_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_90); %96x8x90
Pam_Pearson_90_hemodynamic = mean(Pam_Pearson_90_3dMatrix,1); %1x8x90
tmp = zeros(8,90);
tmp(:,:) = Pam_Pearson_90_hemodynamic(:,:,:);
Pam_Pearson_90_hemodynamic = tmp;
%Pam Pearson 90 stima emodinamica
Pam_Pearson_100_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_pearson_PAM_100); %96x8x100
Pam_Pearson_100_hemodynamic = mean(Pam_Pearson_100_3dMatrix,1); %1x8x100
tmp = zeros(8,100);
tmp(:,:) = Pam_Pearson_100_hemodynamic(:,:,:);
Pam_Pearson_100_hemodynamic = tmp;
%-------PAM SPEARMAN-------%
%Pam Spearman 10 stima emodinamica
Pam_Spearman_10_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_10); %96x8x10
Pam_Spearman_10_hemodynamic = mean(Pam_Spearman_10_3dMatrix,1); %1x8x10
tmp = zeros(8,10);
tmp(:,:) = Pam_Spearman_10_hemodynamic(:,:,:);
Pam_Spearman_10_hemodynamic = tmp;
%Pam Spearman 20 stima emodinamica
Pam_Spearman_20_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_20); %96x8x20
Pam_Spearman_20_hemodynamic = mean(Pam_Spearman_20_3dMatrix,1); %1x8x20
tmp = zeros(8,20);
tmp(:,:) = Pam_Spearman_20_hemodynamic(:,:,:);
Pam_Spearman_20_hemodynamic = tmp;
%Pam Spearman 30 stima emodinamica
Pam_Spearman_30_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_30); %96x8x30
Pam_Spearman_30_hemodynamic = mean(Pam_Spearman_30_3dMatrix,1); %1x8x30
tmp = zeros(8,30);
tmp(:,:) = Pam_Spearman_30_hemodynamic(:,:,:);
Pam_Spearman_30_hemodynamic = tmp;
%Pam Spearman 40 stima emodinamica
Pam_Spearman_40_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_40); %96x8x40
Pam_Spearman_40_hemodynamic = mean(Pam_Spearman_40_3dMatrix,1); %1x8x40
tmp = zeros(8,40);
tmp(:,:) = Pam_Spearman_40_hemodynamic(:,:,:);
Pam_Spearman_40_hemodynamic = tmp;
%Pam Spearman 50 stima emodinamica
Pam_Spearman_50_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_50); %96x8x50
Pam_Spearman_50_hemodynamic = mean(Pam_Spearman_50_3dMatrix,1); %1x8x50
tmp = zeros(8,50);
tmp(:,:) = Pam_Spearman_50_hemodynamic(:,:,:);
Pam_Spearman_50_hemodynamic = tmp;
%Pam Spearman 60 stima emodinamica
Pam_Spearman_60_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_60); %96x8x60
Pam_Spearman_60_hemodynamic = mean(Pam_Spearman_60_3dMatrix,1); %1x8x60
tmp = zeros(8,60);
tmp(:,:) = Pam_Spearman_60_hemodynamic(:,:,:);
Pam_Spearman_60_hemodynamic = tmp;
%Pam Spearman 70 stima emodinamica
Pam_Spearman_70_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_70); %96x8x70
Pam_Spearman_70_hemodynamic = mean(Pam_Spearman_70_3dMatrix,1); %1x8x70
tmp = zeros(8,70);
tmp(:,:) = Pam_Spearman_70_hemodynamic(:,:,:);
Pam_Spearman_70_hemodynamic = tmp;
%Pam Spearman 80 stima emodinamica
Pam_Spearman_80_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_80); %96x8x80
Pam_Spearman_80_hemodynamic = mean(Pam_Spearman_80_3dMatrix,1); %1x8x80
tmp = zeros(8,80);
tmp(:,:) = Pam_Spearman_80_hemodynamic(:,:,:);
Pam_Spearman_80_hemodynamic = tmp;
%Pam Spearman 90 stima emodinamica
Pam_Spearman_90_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_90); %96x8x90
Pam_Spearman_90_hemodynamic = mean(Pam_Spearman_90_3dMatrix,1); %1x8x90
tmp = zeros(8,90);
tmp(:,:) = Pam_Spearman_90_hemodynamic(:,:,:);
Pam_Spearman_90_hemodynamic = tmp;
%Pam Spearman 100 stima emodinamica
Pam_Spearman_100_3dMatrix = trials_as_3d_matrix(:,:,clusterCenterID_spearman_PAM_100); %96x8x100
Pam_Spearman_100_hemodynamic = mean(Pam_Spearman_100_3dMatrix,1); %1x8x100
tmp = zeros(8,100);
tmp(:,:) = Pam_Spearman_100_hemodynamic(:,:,:);
Pam_Spearman_100_hemodynamic = tmp;
%-------LINKAGE PEARSON-------%
%Linkage Pearson 10 stima emodinamica
Linkage_Pearson_10_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_10); %96x8x10
Linkage_Pearson_10_hemodynamic = mean(Linkage_Pearson_10_3dMatrix,1); %1x8x10
tmp = zeros(8,10);
tmp(:,:) = Linkage_Pearson_10_hemodynamic(:,:,:);
Linkage_Pearson_10_hemodynamic = tmp;
%Linkage Pearson 20 stima emodinamica
Linkage_Pearson_20_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_20); %96x8x20
Linkage_Pearson_20_hemodynamic = mean(Linkage_Pearson_20_3dMatrix,1); %1x8x20
tmp = zeros(8,20);
tmp(:,:) = Linkage_Pearson_20_hemodynamic(:,:,:);
Linkage_Pearson_20_hemodynamic = tmp;
%Linkage Pearson 30 stima emodinamica
Linkage_Pearson_30_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_30); %96x8x30
Linkage_Pearson_30_hemodynamic = mean(Linkage_Pearson_30_3dMatrix,1); %1x8x30
tmp = zeros(8,30);
tmp(:,:) = Linkage_Pearson_30_hemodynamic(:,:,:);
Linkage_Pearson_30_hemodynamic = tmp;
%Linkage Pearson 40 stima emodinamica
Linkage_Pearson_40_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_40); %96x8x40
Linkage_Pearson_40_hemodynamic = mean(Linkage_Pearson_40_3dMatrix,1); %1x8x40
tmp = zeros(8,40);
tmp(:,:) = Linkage_Pearson_40_hemodynamic(:,:,:);
Linkage_Pearson_40_hemodynamic = tmp;
%Linkage Pearson 50 stima emodinamica
Linkage_Pearson_50_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_50); %96x8x50
Linkage_Pearson_50_hemodynamic = mean(Linkage_Pearson_50_3dMatrix,1); %1x8x50
tmp = zeros(8,50);
tmp(:,:) = Linkage_Pearson_50_hemodynamic(:,:,:);
Linkage_Pearson_50_hemodynamic = tmp;
%Linkage Pearson 60 stima emodinamica
Linkage_Pearson_60_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_60); %96x8x60
Linkage_Pearson_60_hemodynamic = mean(Linkage_Pearson_60_3dMatrix,1); %1x8x60
tmp = zeros(8,60);
tmp(:,:) = Linkage_Pearson_60_hemodynamic(:,:,:);
Linkage_Pearson_60_hemodynamic = tmp;
%Linkage Pearson 70 stima emodinamica
Linkage_Pearson_70_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_70); %96x8x70
Linkage_Pearson_70_hemodynamic = mean(Linkage_Pearson_70_3dMatrix,1); %1x8x70
tmp = zeros(8,70);
tmp(:,:) = Linkage_Pearson_70_hemodynamic(:,:,:);
Linkage_Pearson_70_hemodynamic = tmp;
%Linkage Pearson 80 stima emodinamica
Linkage_Pearson_80_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_80); %96x8x80
Linkage_Pearson_80_hemodynamic = mean(Linkage_Pearson_80_3dMatrix,1); %1x8x80
tmp = zeros(8,80);
tmp(:,:) = Linkage_Pearson_80_hemodynamic(:,:,:);
Linkage_Pearson_80_hemodynamic = tmp;
%Linkage Pearson 90 stima emodinamica
Linkage_Pearson_90_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_90); %96x8x90
Linkage_Pearson_90_hemodynamic = mean(Linkage_Pearson_90_3dMatrix,1); %1x8x90
tmp = zeros(8,90);
tmp(:,:) = Linkage_Pearson_90_hemodynamic(:,:,:);
Linkage_Pearson_90_hemodynamic = tmp;
%Linkage Pearson 100 stima emodinamica
Linkage_Pearson_100_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_pearson_Linkage_100); %96x8x100
Linkage_Pearson_100_hemodynamic = mean(Linkage_Pearson_100_3dMatrix,1); %1x8x100
tmp = zeros(8,100);
tmp(:,:) = Linkage_Pearson_100_hemodynamic(:,:,:);
Linkage_Pearson_100_hemodynamic = tmp;
%-------LINKAGE SPEARMAN-------%
%Linkage Spearman 10 stima emodinamica
Linkage_Spearman_10_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_10); %96x8x10
Linkage_Spearman_10_hemodynamic = mean(Linkage_Spearman_10_3dMatrix,1); %1x8x10
tmp = zeros(8,10);
tmp(:,:) = Linkage_Spearman_10_hemodynamic(:,:,:);
Linkage_Spearman_10_hemodynamic = tmp;
%Linkage Spearman 20 stima emodinamica
Linkage_Spearman_20_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_20); %96x8x20
Linkage_Spearman_20_hemodynamic = mean(Linkage_Spearman_20_3dMatrix,1); %1x8x20
tmp = zeros(8,20);
tmp(:,:) = Linkage_Spearman_20_hemodynamic(:,:,:);
Linkage_Spearman_20_hemodynamic = tmp;
%Linkage Spearman 30 stima emodinamica
Linkage_Spearman_30_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_30); %96x8x30
Linkage_Spearman_30_hemodynamic = mean(Linkage_Spearman_30_3dMatrix,1); %1x8x30
tmp = zeros(8,30);
tmp(:,:) = Linkage_Spearman_30_hemodynamic(:,:,:);
Linkage_Spearman_30_hemodynamic = tmp;
%Linkage Spearman 40 stima emodinamica
Linkage_Spearman_40_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_40); %96x8x40
Linkage_Spearman_40_hemodynamic = mean(Linkage_Spearman_40_3dMatrix,1); %1x8x40
tmp = zeros(8,40);
tmp(:,:) = Linkage_Spearman_40_hemodynamic(:,:,:);
Linkage_Spearman_40_hemodynamic = tmp;
%Linkage Spearman 50 stima emodinamica
Linkage_Spearman_50_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_50); %96x8x50
Linkage_Spearman_50_hemodynamic = mean(Linkage_Spearman_50_3dMatrix,1); %1x8x50
tmp = zeros(8,50);
tmp(:,:) = Linkage_Spearman_50_hemodynamic(:,:,:);
Linkage_Spearman_50_hemodynamic = tmp;
%Linkage Spearman 60 stima emodinamica
Linkage_Spearman_60_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_60); %96x8x60
Linkage_Spearman_60_hemodynamic = mean(Linkage_Spearman_60_3dMatrix,1); %1x8x60
tmp = zeros(8,60);
tmp(:,:) = Linkage_Spearman_60_hemodynamic(:,:,:);
Linkage_Spearman_60_hemodynamic = tmp;
%Linkage Spearman 70 stima emodinamica
Linkage_Spearman_70_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_70); %96x8x70
Linkage_Spearman_70_hemodynamic = mean(Linkage_Spearman_70_3dMatrix,1); %1x8x70
tmp = zeros(8,70);
tmp(:,:) = Linkage_Spearman_70_hemodynamic(:,:,:);
Linkage_Spearman_70_hemodynamic = tmp;
%Linkage Spearman 80 stima emodinamica
Linkage_Spearman_80_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_80); %96x8x80
Linkage_Spearman_80_hemodynamic = mean(Linkage_Spearman_80_3dMatrix,1); %1x8x80
tmp = zeros(8,80);
tmp(:,:) = Linkage_Spearman_80_hemodynamic(:,:,:);
Linkage_Spearman_80_hemodynamic = tmp;
%Linkage Spearman 90 stima emodinamica
Linkage_Spearman_90_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_90); %96x8x90
Linkage_Spearman_90_hemodynamic = mean(Linkage_Spearman_90_3dMatrix,1); %1x8x90
tmp = zeros(8,90);
tmp(:,:) = Linkage_Spearman_90_hemodynamic(:,:,:);
Linkage_Spearman_90_hemodynamic = tmp;
%Linkage Spearman 100 stima emodinamica
Linkage_Spearman_100_3dMatrix = trials_as_3d_matrix(:,:,clusterCeneterID_spearman_Linkage_100); %96x8x100
Linkage_Spearman_100_hemodynamic = mean(Linkage_Spearman_100_3dMatrix,1); %1x8x100
tmp = zeros(8,100);
tmp(:,:) = Linkage_Spearman_100_hemodynamic(:,:,:);
Linkage_Spearman_100_hemodynamic = tmp;
%PLOT hemodynamic to pdf
set(gcf, 'PaperPositionMode', 'auto'); %Position plot at left hand corner with width 5 and height 5.
set(gcf, 'PaperSize', [20 20]); %Set the paper to have width 5 and height 5.
set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperType', 'A4');
plot(Pam_Pearson_10_hemodynamic);
title('Pam Pearson 10 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_10_hemodynamic'), 'pdf'); %Save figur
plot([Pam_Pearson_10_hemodynamic Trials(1).HRF]);
title('Pam Pearson 10 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_10_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Pearson_20_hemodynamic);
title('Pam Pearson 20 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_20_hemodynamic'), 'pdf'); %Save figure
plot(Pam_Pearson_20_hemodynamic);
title('Pam Pearson 20 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_20_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Pearson_30_hemodynamic);
title('Pam Pearson 30 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_30_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Pearson_30_hemodynamic Trials(1).HRF]);
title('Pam Pearson 30 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_30_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Pearson_40_hemodynamic);
title('Pam Pearson 40 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_40_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Pearson_40_hemodynamic Trials(1).HRF]);
title('Pam Pearson 40 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_40_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Pearson_50_hemodynamic);
title('Pam Pearson 50 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_50_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Pearson_50_hemodynamic Trials(1).HRF]);
title('Pam Pearson 50 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Pearson_50_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Spearman_10_hemodynamic);
title('Pam Spearman 10 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_10'), 'pdf'); %Save figure
plot([Pam_Spearman_10_hemodynamic Trials(1).HRF]);
title('Pam Spearman 10 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_10_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Spearman_20_hemodynamic);
title('Pam Spearman 20 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_20_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Spearman_20_hemodynamic Trials(1).HRF]);
title('Pam Spearman 20 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_20_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Spearman_30_hemodynamic);
title('Pam Spearman 30 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_30_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Spearman_30_hemodynamic Trials(1).HRF]);
title('Pam Spearman 30 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_30_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Spearman_40_hemodynamic);
title('Pam Spearman 40 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_40_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Spearman_40_hemodynamic Trials(1).HRF]);
title('Pam Spearman 40 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_40_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Pam_Spearman_50_hemodynamic);
title('Pam Spearman 50 hemodynamic');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_50_hemodynamic'), 'pdf'); %Save figure
plot([Pam_Spearman_50_hemodynamic Trials(1).HRF]);
title('Pam Spearman 50 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Pam_Spearman_50_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Pearson_10_hemodynamic);
title('Linkage Pearson 10 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_10_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Pearson_10_hemodynamic Trials(1).HRF]);
title('Linkage Pearson 10 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_10_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Pearson_20_hemodynamic);
title('Linkage Pearson 20 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_20_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Pearson_20_hemodynamic Trials(1).HRF]);
title('Linkage Pearson 20 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_20_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Pearson_30_hemodynamic);
title('Linkage Pearson 30 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_30_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Pearson_30_hemodynamic Trials(1).HRF]);
title('Linkage Pearson 30 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_30_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Pearson_40_hemodynamic);
title('Linkage Pearson 40 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_40_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Pearson_40_hemodynamic Trials(1).HRF]);
title('Linkage Pearson 40 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_40_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Pearson_50_hemodynamic);
title('Linkage Pearson 50 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_50_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Pearson_50_hemodynamic Trials(1).HRF]);
title('Linkage Pearson 50 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Pearson_50_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Spearman_10_hemodynamic);
title('Linkage Spearman 10 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_10_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Spearman_10_hemodynamic Trials(1).HRF]);
title('Linkage Spearman 10 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_10_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Spearman_20_hemodynamic);
title('Linkage Spearman 20 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_20_hemodynamic'), 'pdf'); %Save figures
plot([Linkage_Spearman_20_hemodynamic Trials(1).HRF]);
title('Linkage Spearman 20 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_20_hemodynamic_with_standard'), 'pdf'); %Save figures
plot(Linkage_Spearman_30_hemodynamic);
title('Linkage Spearman 30 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_30_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Spearman_30_hemodynamic Trials(1).HRF]);
title('Linkage Spearman 30 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_30_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Spearman_40_hemodynamic);
title('Linkage Spearman 40 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_40_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Spearman_40_hemodynamic Trials(1).HRF]);
title('Linkage Spearman 40 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_40_hemodynamic_with_standard'), 'pdf'); %Save figure
plot(Linkage_Spearman_50_hemodynamic);
title('Linkage Spearman 50 hemodynamic');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_50_hemodynamic'), 'pdf'); %Save figure
plot([Linkage_Spearman_50_hemodynamic Trials(1).HRF]);
title('Linkage Spearman 50 hemodynamic - with standard');
saveas(gcf, strcat(outputPath, 'Linkage_Spearman_50_hemodynamic_with_standard'), 'pdf'); %Save figure
%**************CLASSIFICATION**************%
%Meanwhile to hemodynamic estimation has been
%used start matrix with only cluster centroid,
%to execute classification will be used again
%compress matrix(96xk).
Pam_Pearson_10_compressMatrix = matrix4cluster(:,clusterCenterID_pearson_PAM_10);
Pam_Pearson_20_compressMatrix = matrix4cluster(:,clusterCenterID_pearson_PAM_20);
Pam_Pearson_30_compressMatrix = matrix4cluster(:,clusterCenterID_pearson_PAM_30);
Pam_Pearson_40_compressMatrix = matrix4cluster(:,clusterCenterID_pearson_PAM_40);
Pam_Pearson_50_compressMatrix = matrix4cluster(:,clusterCenterID_pearson_PAM_50);
Pam_Spearman_10_compressMatrix = matrix4cluster(:,clusterCenterID_spearman_PAM_10);
Pam_Spearman_20_compressMatrix = matrix4cluster(:,clusterCenterID_spearman_PAM_20);
Pam_Spearman_30_compressMatrix = matrix4cluster(:,clusterCenterID_spearman_PAM_30);
Pam_Spearman_40_compressMatrix = matrix4cluster(:,clusterCenterID_spearman_PAM_40);
Pam_Spearman_50_compressMatrix = matrix4cluster(:,clusterCenterID_spearman_PAM_50);
Linkage_Pearson_10_compressMatrix = matrix4cluster(:,clusterCeneterID_pearson_Linkage_10);
Linkage_Pearson_20_compressMatrix = matrix4cluster(:,clusterCeneterID_pearson_Linkage_20);
Linkage_Pearson_30_compressMatrix = matrix4cluster(:,clusterCeneterID_pearson_Linkage_30);
Linkage_Pearson_40_compressMatrix = matrix4cluster(:,clusterCeneterID_pearson_Linkage_40);
Linkage_Pearson_50_compressMatrix = matrix4cluster(:,clusterCeneterID_pearson_Linkage_50);
Linkage_Spearman_10_compressMatrix = matrix4cluster(:,clusterCeneterID_spearman_Linkage_10);
Linkage_Spearman_20_compressMatrix = matrix4cluster(:,clusterCeneterID_spearman_Linkage_20);
Linkage_Spearman_30_compressMatrix = matrix4cluster(:,clusterCeneterID_spearman_Linkage_30);
Linkage_Spearman_40_compressMatrix = matrix4cluster(:,clusterCeneterID_spearman_Linkage_40);
Linkage_Spearman_50_compressMatrix = matrix4cluster(:,clusterCeneterID_spearman_Linkage_50);
% %SVM CLASSIFICATION - matlab functions
% [svm_pam_pearson_10, pred_pam_pearson_10] = kfoldAndSvm_Classification(Pam_Pearson_10_compressMatrix, Labels);
% [svm_pam_pearson_20, pred_pam_pearson_20] = kfoldAndSvm_Classification(Pam_Pearson_20_compressMatrix, Labels);
% [svm_pam_pearson_30, pred_pam_pearson_30] = kfoldAndSvm_Classification(Pam_Pearson_30_compressMatrix, Labels);
% [svm_pam_pearson_40, pred_pam_pearson_40] = kfoldAndSvm_Classification(Pam_Pearson_40_compressMatrix, Labels);
% [svm_pam_pearson_50, pred_pam_pearson_50] = kfoldAndSvm_Classification(Pam_Pearson_50_compressMatrix, Labels);
%
% [svm_pam_spearman_10, pred_pam_spearman_10] = kfoldAndSvm_Classification(Pam_Spearman_10_compressMatrix, Labels);
% [svm_pam_spearman_20, pred_pam_spearman_20] = kfoldAndSvm_Classification(Pam_Spearman_20_compressMatrix, Labels);
% [svm_pam_spearman_30, pred_pam_spearman_30] = kfoldAndSvm_Classification(Pam_Spearman_30_compressMatrix, Labels);
% [svm_pam_spearman_40, pred_pam_spearman_40] = kfoldAndSvm_Classification(Pam_Spearman_40_compressMatrix, Labels);
% [svm_pam_spearman_50, pred_pam_spearman_50] = kfoldAndSvm_Classification(Pam_Spearman_50_compressMatrix, Labels);
%
% [svm_linkage_pearson_10, pred_linkage_pearson_10] = kfoldAndSvm_Classification(Linkage_Pearson_10_compressMatrix, Labels);
% [svm_linkage_pearson_20, pred_linkage_pearson_20] = kfoldAndSvm_Classification(Linkage_Pearson_20_compressMatrix, Labels);
% [svm_linkage_pearson_30, pred_linkage_pearson_30] = kfoldAndSvm_Classification(Linkage_Pearson_30_compressMatrix, Labels);
% [svm_linkage_pearson_40, pred_linkage_pearson_40] = kfoldAndSvm_Classification(Linkage_Pearson_40_compressMatrix, Labels);
% [svm_linkage_pearson_50, pred_linkage_pearson_50] = kfoldAndSvm_Classification(Linkage_Pearson_40_compressMatrix, Labels);
%
% [svm_linkage_spearman_10, pred_linkage_spearman_10] = kfoldAndSvm_Classification(Linkage_Spearman_10_compressMatrix, Labels);
% [svm_linkage_spearman_20, pred_linkage_spearman_20] = kfoldAndSvm_Classification(Linkage_Spearman_20_compressMatrix, Labels);
% [svm_linkage_spearman_30, pred_linkage_spearman_30] = kfoldAndSvm_Classification(Linkage_Spearman_30_compressMatrix, Labels);
% [svm_linkage_spearman_40, pred_linkage_spearman_40] = kfoldAndSvm_Classification(Linkage_Spearman_40_compressMatrix, Labels);
% [svm_linkage_spearman_50, pred_linkage_spearman_50] = kfoldAndSvm_Classification(Linkage_Spearman_50_compressMatrix, Labels);
%GV classifier
[X] = GV_extractFeatures_Salerno(Trials,Splits,Params);
% classify GV
[Results] = GV_classifyCrossVal_Salerno(X,Labels,Splits);
GV_mean_err = [Results.mean_err Results.mean_err Results.mean_err Results.mean_err Results.mean_err]';
%SVM CLASSIFICATION - script Giancarlo Valente - LINEAR KERNEL
[Splits] = GV_createSplits_Salerno(Labels,Params);
for i=10:10:50
eval(sprintf('svm_GV_pam_pearson_%d = GV_classifyCrossVal_Salerno(Pam_Pearson_%d_compressMatrix, Labels, Splits);', i, i));
eval(sprintf('svm_GV_pam_spearman_%d = GV_classifyCrossVal_Salerno(Pam_Spearman_%d_compressMatrix, Labels, Splits);', i, i));
eval(sprintf('svm_GV_linkage_pearson_%d = GV_classifyCrossVal_Salerno(Linkage_Pearson_%d_compressMatrix, Labels, Splits);', i, i));
eval(sprintf('svm_GV_linkage_spearman_%d = GV_classifyCrossVal_Salerno(Linkage_Spearman_%d_compressMatrix, Labels, Splits);', i, i));
end
%SVM CLASSIFICATION - with FEATURES SELECTION
FEATURES_PERCENTAGE = 20; %percentage of features to use for features selection (es. 20% of 96x10 = 96x2)
%RBF KERNEL
kernel = 'rbf'; %since we have few features we use non-linear kernel
for i=10:10:50
eval(sprintf('[svm_pam_pearson_%s_%d_FS, featuresHistory_svm_pam_pearson_%s_%d_FS] = my_GV_classifyCrossVal_Salerno(Pam_Pearson_%d_compressMatrix, Labels, Splits, FEATURES_PERCENTAGE, kernel);',kernel,i,kernel,i,i));
eval(sprintf('[svm_pam_spearman_%s_%d_FS, featuresHistory_svm_pam_spearman_%s_%d_FS] = my_GV_classifyCrossVal_Salerno(Pam_Spearman_%d_compressMatrix, Labels, Splits, FEATURES_PERCENTAGE, kernel);',kernel,i,kernel,i,i));
eval(sprintf('[svm_linkage_pearson_%s_%d_FS, featuresHistory_svm_linkage_pearson_%s_%d_FS] = my_GV_classifyCrossVal_Salerno(Linkage_Pearson_%d_compressMatrix, Labels, Splits, FEATURES_PERCENTAGE, kernel);',kernel,i,kernel,i,i));
eval(sprintf('[svm_linkage_spearman_%s_%d_FS, featuresHistory_svm_linkage_spearman_%s_%d_FS] = my_GV_classifyCrossVal_Salerno(Linkage_Spearman_%d_compressMatrix, Labels, Splits, FEATURES_PERCENTAGE, kernel);',kernel,i,kernel,i,i));
end
%-----------------Errors plot-----------------%
%PAM PEARSON
figure(1)
timeVector_pam_pearson = zeros(1,5)';
for i=1:5
eval(sprintf('timeVector_pam_pearson(i,1) = svm_GV_pam_pearson_%d.mean_err;',i*10));
end
timeVector_pam_pearson_FS = zeros(1,5);
for i=1:5
eval(sprintf('timeVector_pam_pearson_FS(i,1) = svm_pam_pearson_%s_%d_FS.mean_err;',kernel,i*10));
end
%PAM SPEARMAN
figure(2)
timeVector_pam_spearman = zeros(1,5)';
for i=1:5
eval(sprintf('timeVector_pam_spearman(i,1) = svm_GV_pam_spearman_%d.mean_err;',i*10));
end
timeVector_pam_spearman_FS = zeros(1,5);
for i=1:5
eval(sprintf('timeVector_pam_spearman_FS(i,1) = svm_pam_spearman_%s_%d_FS.mean_err;',kernel,i*10));
end
%LINKAGE PEARSON
figure(3)
timeVector_linkage_pearson = zeros(1,5)';
for i=1:5
eval(sprintf('timeVector_linkage_pearson(i,1) = svm_GV_linkage_pearson_%d.mean_err;',i*10));
end
timeVector_linkage_pearson_FS = zeros(1,5);
for i=1:5
eval(sprintf('timeVector_linkage_pearson_FS(i,1) = svm_linkage_pearson_%s_%d_FS.mean_err;',kernel,i*10));
end
%LINKAGE SPEARMAN
figure(4)
timeVector_linkage_spearman = zeros(1,5)';
for i=1:5
eval(sprintf('timeVector_linkage_spearman(i,1) = svm_GV_linkage_spearman_%d.mean_err;',i*10));
end
timeVector_linkage_spearman_FS = zeros(1,5);
for i=1:5
eval(sprintf('timeVector_linkage_spearman_FS(i,1) = svm_linkage_spearman_%s_%d_FS.mean_err;',kernel,i*10));
end
%PAM PEARSON
bar(10:10:50,[timeVector_pam_pearson, timeVector_pam_pearson_FS(:,1), GV_mean_err]);
legend('pam pearson', sprintf('pam pearson FS %s', kernel), 'GV err');
axis([0 60 0 1]);
title('Error Pam Perason');
xlabel('cluster num');
ylabel('err value');
saveas(gcf, strcat(outputPath, sprintf('Pam_Pearson_classification_error_%s',kernel)), 'pdf'); %Save figure
%PAM SPEARMAN
bar(10:10:50,[timeVector_pam_spearman, timeVector_pam_spearman_FS(:,1), GV_mean_err]);
legend('pam spearman', sprintf('pam spearman FS %s', kernel), 'GV err');
axis([0 60 0 1]);
title('Error Pam Spearman');
xlabel('cluster num');
ylabel('err value');
saveas(gcf, strcat(outputPath, sprintf('Pam_Spearman_classification_error_%s',kernel)), 'pdf'); %Save figure
%LINKAGE PEARSON
bar(10:10:50,[timeVector_linkage_pearson, timeVector_linkage_pearson_FS(:,1), GV_mean_err]);
legend('linkage pearson', sprintf('linkage pearson FS %s', kernel), 'GV err');
axis([0 60 0 1]);
title('Error Linkage Pearson');
xlabel('cluster num');
ylabel('err value');
saveas(gcf, strcat(outputPath, sprintf('Linkage_Pearson_classification_error_%s',kernel)), 'pdf'); %Save figure
%LINKAGE SPEARMAN
bar(10:10:50,[timeVector_linkage_spearman, timeVector_linkage_spearman_FS(:,1), GV_mean_err]);
legend('linkage spearman', sprintf('linkage spearman FS %s', kernel), 'GV err');
axis([0 60 0 1]);
title('Error Linkage Spearman');
xlabel('cluster num');
ylabel('err value');
saveas(gcf, strcat(outputPath, sprintf('Linkage_Spearman_classification_error_%s',kernel)), 'pdf'); %Save figure