function[meanforce,meanforceNZ,maxforce,stdforce,meanffluc,maxffluc,stdffluc,time,PA,PAmf]=hechttaak(jj,marks,handles,springs) %callibration for first serie prototypes suture task %gets parameters from data after callibration %spring type light Order 1408421 %open the Text file from forcesensor load(['HookinF_' jj '.txt']); eval(['Sensor=HookinF_' num2str(jj) ';']); RTz=Sensor(:,1); RFt=Sensor(:,2); t=Sensor(:,3); mark1=Sensor(:,4); % define time & frequence from data dt=(t(end)/length(t)); ta=(1:length(t))*dt; % define callibration % light spring new prototype medishield %sensor 1 if springs == 1; for i=1:length(t); if RTz(i) > 0.4; Fz(i)=9.4196*RTz(i)^2-14.32*RTz(i)+3.104-0.5; if Fz(i) < 0.0; Fz(i)=0; end end end for i=1:length(t); Ft(i)=-62.065*RFt(i)^2+190.88*RFt(i)-133.25; if Ft(i) < 0.4; Ft(i)=0; end end end Fz=Fz'; % filtering data from high frequenty noize [b,a]=butter(2,0.1,'low'); Fza=filter(b,a,Fz); Fta=filter(b,a,Ft); %removing first bad samples st=round(1/dt); %start after some miliseconds mark=mark1; tfmark=ta;%timeline for all data [Y,I] = max(mark); Imark=I % all data ----------------------------------------------------------------- if marks==1; Fzfa1=Fza(st:length(Fza)); Ftfa1=Fta(st:length(Fta)); tf=ta(st:length(ta)); EXT=0; % all data ----------------------------------------------------------------- % data before first q---------------------------------------------------????????? elseif marks==2; Fzfa1=Fza(st:I); Ftfa1=Fta(st:I); tf=ta(st:I); EXT=0; % data before first q----------------------------------------------------------------- % data after first q----------------------------------------------------------------- elseif marks==3; Fzfa1=Fza(I:length(Fza)); Ftfa1=Fta(I:length(Fta)); tf=ta(I:length(ta)); EXT=length(ta)-length(tf); % data after first q--------------------------------------------------????????? else error('data deel definieren') end markplot=mark*6; % subplot(3,1,1),plot(tf,Fxfa,'b'),hold on % subplot(3,1,1),plot(tfmark,markplot,'r'),hold on % legend('Fx') % subplot(3,1,2),plot(tf,Fyfa,'b'),hold on % subplot(3,1,2),plot(tfmark,markplot,'r'),hold on % legend('Fy') % subplot(3,1,3),plot(tf,Fzfa,'b'),hold on % subplot(3,1,3),plot(tfmark,markplot,'r'),hold on % legend('Fz') % figure(2) % plot(tf,Ff,'b','LineWidth',2),hold on % xlabel('time [s]') % ylabel('abs.force [N]') % axis([0 50 0 6]) %plot forces absolute and maximal energy inside peak. Ff=Fzfa1'; Ft=Ftfa1'; I=find(Ff>0.5);%range of excepted force if I<3; display('data measurement failed'); end J = [I(1)+10 I(1:length(I)-2) I(length(I))+10]; a = J-I; b = find(abs(a)>1); c1 = sort([1 b(2:length(b)-1)-1 b(2:length(b))]); C1=I(c1); for k =1:2:length(C1); A(k)=mean(Ff(C1(k):C1(k+1)))*((C1(k+1)-C1(k))*dt); At(k)=C1(k+1)-C1(k); Mf(k)=mean(Ff(C1(k):C1(k+1))); tbegin(k)=(C1(k)+EXT+st)*dt; teind(k)= (C1(k+1)+EXT+st)*dt; end k =1:2:length(C1); tbegin1=tbegin(k); % begin surface blocks teind1=teind(k); % end surface blocks A1 = A(k); % surface At1=At(k); % time span of surface Mf1=Mf(k); % mean absforce over surface Area1=[A1' At1' Mf1' tbegin1' teind1']; % combined data of surface [Y,X]= max(A1); maxAarea=Area1(X,:);% highest area in surface A1(X)=0;% remove highest area in surface [Y1,X1]= max(A1); maxAarea1=Area1(X1,:);% 1 after highest area in surface A1(X1)=0;% remove 1 after highest area in surface [Y2,X2]= max(A1); maxAarea2=Area1(X2,:);% 2 after highest area in surface [Y1,X1]= max(Mf1); maxMFarea=Area1(X1,:); % highest mean force in surface PA=maxAarea(1); PAmf=maxMFarea(1); % Figuren in GUI axes(handles.axes2) plot(tf,Ff,'b','LineWidth',2),hold on plot(tf,Ft,'m','LineWidth',1),hold on plot(tfmark,markplot,'k','LineWidth',2),hold on text(tfmark(Imark),4.5,' First mark') %plotting the treshold lines--------------------------------------- casepopup=[2 2.5 3.5 1.5 2.5 10 4.5 13];%[small-intest big-intest uterus tuba peritoneum aorta venacv Fasi]=dt matrice to load F box in GUI forcetreshold=casepopup(get(handles.popupmenuforce,'value'));% this valeu comes from GUI=user interface red(1:length(tf))=forcetreshold; yellow=0.75*red; plot(tf,red,'--r','LineWidth',2),hold on plot(tf,yellow,'--y','LineWidth',2),hold on %plotting the treshold lines--------------------------------------- %maximale surface plot([maxAarea(4) maxAarea(5)],[maxAarea(3) maxAarea(3)],'r','LineWidth',2),hold on plot([maxAarea(4) maxAarea(4)],[0 maxAarea(3)],'r','LineWidth',2),hold on plot([maxAarea(5) maxAarea(5)],[0 maxAarea(3)],'r','LineWidth',2),hold on % %2nd maximale surface 2nd % plot([maxAarea1(4) maxAarea1(5)],[maxAarea1(3) maxAarea1(3)],'r','LineWidth',2),hold on % plot([maxAarea1(4) maxAarea1(4)],[0 maxAarea1(3)],'r','LineWidth',2),hold on % plot([maxAarea1(5) maxAarea1(5)],[0 maxAarea1(3)],'r','LineWidth',2),hold on % %3th maximale surface % plot([maxAarea2(4) maxAarea2(5)],[maxAarea2(3) maxAarea2(3)],'r','LineWidth',2),hold on % plot([maxAarea2(4) maxAarea2(4)],[0 maxAarea2(3)],'r','LineWidth',2),hold on % plot([maxAarea2(5) maxAarea2(5)],[0 maxAarea2(3)],'r','LineWidth',2),hold on %Highest mean force with surface plot([maxMFarea(4) maxMFarea(5)],[maxMFarea(3) maxMFarea(3)],'g','LineWidth',2),hold on plot([maxMFarea(4) maxMFarea(4)],[0 maxMFarea(3)],'g','LineWidth',2),hold on plot([maxMFarea(5) maxMFarea(5)],[0 maxMFarea(3)],'g','LineWidth',2),hold on grid on ylabel('Abs force [N]') xlabel('time') legend('Fspan','Fincision') % rounding Fzfb=round(Fzfa1*1000)/1000; minpb= min(min(find(Fzfb))); maxpb= max(max(find(Fzfb))); %start vector at the moment forces are excerted Fzfb=Fzfb(minpb:maxpb); %calculating dF by calculating df/dt [mm/s] Fzfsvb=[Fzfb(1);Fzfb(1:length(Fzfb)-1)]; Fzfdfb=Fzfb-Fzfsvb; Fzfdv=Fzfdfb/dt; %-------------------------------------------------------------------------- %output meanforce=mean(Fzfb);%OUTPUT meanforceNZ=mean(nonzeros(sqrt(Fzfb)));%OUTPUT maxforce=max(Fzfb);%OUTPUT stdforce=std(Fzfb);%OUTPUT meanffluc=mean(nonzeros(Fzfdv));%OUTPUT maxffluc=max(Fzfdv);%OUTPUT stdffluc=std(nonzeros(Fzfdv));%OUTPUT time=t(length(Fzfb));%OUTPUT