-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotFilteredFD.m
99 lines (79 loc) · 3.36 KB
/
PlotFilteredFD.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
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
function [] = PlotPowerSpect(subject,numVols,filteredFD,f,P1,P2,freqA,psdxA,freqB,psdxB)
% ------------------------------------------------------------------------------
% Plot
% ------------------------------------------------------------------------------
FSize = 10;
h1 = figure('color','w', 'units', 'centimeters', 'pos', [0 0 21 29.7], 'name',['FD power spectrum: ',subject]); box('on'); movegui(h1,'center');
h2 = suptitle(['Filtered FD:: ',subject]);
pos = get(h2,'Position');
set(h2,'Position',[pos(1)*1, pos(2)*0.5, pos(3)*1]);
% ------------------------------------------------------------------------------
% Plot FD
% ------------------------------------------------------------------------------
sp1 = subplot(4,2,1);
pos1 = get(sp1,'Position');
plot(filteredFD)
hold on
title('filtered fdJenk','fontweight','bold')
ylabel('mm')
xlabel('time points')
xlim([1 numVols])
ylim([0 max(filteredFD)+(max(filteredFD)*.10)])
set(sp1,'XTickLabel','');
set(gca,'FontSize',FSize)
% Add text to plot
filteredFD_m = mean(filteredFD); % mean FD
filteredFD_Max = max(filteredFD);
filteredFD_Perc = sum(filteredFD > 0.025) / numVols * 100; % spike percentage
str1 = ['Mean = ',num2str(filteredFD_m,'%0.2f'),'mm. Max value of spike = ',num2str(filteredFD_Max,'%0.2f'),'mm.Percentage above threshold = ',num2str(filteredFD_Perc,'%0.1f'),'%'];
yLimits = ylim;
text(round(numVols*.05),yLimits(2) - yLimits(2)*.2,str1,...
'HorizontalAlignment','left',...
'VerticalAlignment','middle',...
'Color','black',...
'FontSize', FSize)
% overlay threshold line
line([0 numVols],[0.025 0.025],'LineStyle','--','Color','k')
% ------------------------------------------------------------------------------
% Plot single-sided amplitude powerpectrum
% ------------------------------------------------------------------------------
sp2 = subplot(4,2,3);
pos2 = get(sp2,'Position');
plot(f,P1)
grid on
ylim([0 max(P1)])
title('Single-Sided Amplitude Spectrum of FD after filtering')
xlabel('f (Hz)')
ylabel('Power')
set(gca,'FontSize',FSize)
% ------------------------------------------------------------------------------
% Plot scaled powerpectrum
% ------------------------------------------------------------------------------
sp3 = subplot(4,2,5);
pos3 = get(sp3,'Position');
plot(freqA,10*log10(psdxA))
grid on
title('Scaled FD Periodogram Using FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency')
set(gca,'FontSize',FSize)
% ------------------------------------------------------------------------------
% Plot normalised powerpectrum
% ------------------------------------------------------------------------------
sp4 = subplot(4,2,7);
pos4 = get(sp4,'Position');
plot(freqB/pi,10*log10(psdxB))
grid on
title('Normalised FD Periodogram Using FFT')
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Power/Frequency')
set(gca,'FontSize',FSize)
% ------------------------------------------------------------------------------
% Sizing
% ------------------------------------------------------------------------------
% [left bottom width height]
set(sp1,'Position',[pos1(1)*.6, pos1(2)*1, pos1(3)*2.5, pos1(4)*1]);
set(sp2,'Position',[pos2(1)*.6, pos2(2)*1, pos2(3)*2.5, pos2(4)*1]);
set(sp3,'Position',[pos3(1)*.6, pos3(2)*0.95, pos3(3)*2.5, pos3(4)*1]);
set(sp4,'Position',[pos4(1)*.6, pos4(2)*0.6, pos4(3)*2.5, pos4(4)*1]);
end