-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixPepi.m
61 lines (52 loc) · 1.82 KB
/
FixPepi.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
function [mn, peakind] = FixPepi(Time, Pepi, Vdot, mn, peakind)
%Brad Edwards, PhD
%Inputs: Time vector, Pepi vector, and the indices of start inspiration
%(peakind) and peak pressure (mn)
%Outputs: new indcies of start inspiration and and peak pressure on user input
peakind=peakind';
% Filter Pepi signal
dt=(Time(end)-Time(1))/(length(Time)-1);
backup_mn=mn;
fh = figure;
while 1
% plot current volumes with start insp and peak insp
% First you have the option to delete points
subplot(2,1,1), plot(Time, Pepi); hold on
hmin = plot(Time(mn(:,1)), Pepi(mn(:,1)),'r.','MarkerSize',20);
hmax = plot(Time(peakind), Pepi(peakind),'g.','MarkerSize',20);
title('Left click deletes BAD Pepi Nadir data point (also deletes paired insp value), right click to finish')
hold off;
subplot(2,1,2), plot(Time, Vdot,'b',[Time(1), Time(end)], [0,0],'r');
scrsz = get(0,'ScreenSize');
set(fh,'OuterPosition',[1 1 scrsz(3) scrsz(4)]);
[x,y,button]=ginput(1);
if button==3
break
close(fh)
end
TimeFromClickToPeakPepi = Time(peakind)-x;
[~,i]=min(abs(TimeFromClickToPeakPepi));
mn(i,:)=[];
peakind(i)=[];
end
while 1
% This code moves the insp value to where you want it
subplot(2,1,1), plot(Time, Pepi); hold on
hmin = plot(Time(mn(:,1)), Pepi(mn(:,1)),'r.','MarkerSize',20);
hmax = plot(Time(peakind), Pepi(peakind),'g.','MarkerSize',20);
title('Left click to move peak Pepi to x location, right click to finish')
hold off;
subplot(2,1,2), plot(Time, Vdot,'b',[Time(1), Time(end)], [0,0],'r');
scrsz = get(0,'ScreenSize');
set(fh,'OuterPosition',[1 1 scrsz(3) scrsz(4)]);
[x,y,button]=ginput(1)
if button==3
break
close(fh)
end
TimeFromClickToPeakPepi = Time(peakind)-x;
[y,i]=min(abs(TimeFromClickToPeakPepi));
oldpeakind=peakind(i)';
newpeakind=find(Time>x,1);
peakind(i)=newpeakind;
end