Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Ruud Meulenbroek David Rosenbaum, Mary Klein Breteler, Bert Steenbergen 12 May 2005 in a Prehension Study.

Similar presentations

Presentation on theme: "Using Ruud Meulenbroek David Rosenbaum, Mary Klein Breteler, Bert Steenbergen 12 May 2005 in a Prehension Study."— Presentation transcript:

1 Using Ruud Meulenbroek David Rosenbaum, Mary Klein Breteler, Bert Steenbergen 12 May 2005 in a Prehension Study

2 Overview 1.Sneak Preview Report of experimental results to colleagues 2.Use of Matlab Principle File I/O Data preprocessing Finding relevant time indices in behaviour Plotting Calculating critical performance variables Time-normalizing functions Creating a data matrix for statistical analyses Write output file for SPSSX

3 Topic: “Hand shaping in grasping” Background –Maximum aperture is linearly scaled to object size (Jeannerod 1981; Paulignan et al. 1991,1997; Smeets, 1999) Research questions –Also when being blindfolded? –What about the rotations of the joints in the hand? Newell, K. M., Scully, D. M., McDonald, P. V., & Baillargeon, R. (1989). Task constraints and infant grip configurations. Developmental Psychobiology, 22, 817-832. Sneak preview - Report of experimental results to colleagues -

4 Theory Motion planning –Entails goal-posture selection –Tuned to multiple task constraints Rosenbaum, D. A., Meulenbroek, R.G.J., Jansen, C., Vaughan, J. (2002). Posture-based motion planning: Applications to grasping. Psychological Review, 108, 708-734. Meulenbroek, R.G.J., Kappers, A.L., & Mutsaarts, M. (2001). Does haptic space play a role in the planning and execution of grasping movements? Poster presented at the 'Neural control of space coding and action production' meeting in Lyon (France), March 22-24, 2001 Sneak preview

5 Simulation Slow movementFast movement The orientation of the ‘opposition axis’ reflects the final arm-hand posture Sneak preview

6 Experiment 10 Participants 9 Objects (cylinders of appr. 20 cm height and a diameter of 0.3, 1.3, 2.3, 3.3, 4.3, 5.3, 6.3, 7.3, 8.3 cm) 2 Modality Conditions: (Vision present versus absent; eyes open versus closed; ABBA counterbalancing) 10 Replications (resulting in 180 trials per subject) Sneak preview

7 Experimental Task –The participant sat comfortably at a table... –with the left and right hand on two pieces of sandpaper fixated on the table top, appr. 20 cm in front of left and right shoulder –At the start of each trial the experimenter placed a cylinder in the non-dominant hand of the participant –The participant held the bottom half of the cylinder with opposing thumb and fingers (of the non-dominant hand) –An acoustic go-signal was presented –The participant’s task was to grasp with the dominant hand the top half of the cylinder that he/she held in the non-dominant hand –In half the trials the participant was asked to close his/her eyes before the cylinder was placed in his/her non-dominant hand Sneak preview

8 Method Optotrak 3020 (NDI, Canada) Infrared cameras Data acquisition Infrared light emitting diodes Trunk Hand Finger joints ForearmUpper arm Pen “Rigid bodies” Bouwhuisen, C.F., Meulenbroek, R.G.J., & Thomassen, A.J.W.M. (2002). A 3D motion-tracking method in graphonomic research: Possible applications in future handwriting recognition studies. International Journal of Pattern Recognition, 35(5), 1039-1047. Sneak preview

9 Data acquisition –Optotrak 3020; two time-locked camera systems –8 IREDs on the joints of the hand –Sampling rate of 200 Hz –Recording interval of 3 s –Preprocessing: low-pass filtering (<8 Hz) + Sneak preview

10 IRED configuration and aperture index 1 2 3 4 5 7 6 8 Aperture (‘opposition axis’ ) Sneak preview

11 Use of Matlab KISS : Keep It Simple Stupid (David Rosenbaum) Principle

12 Use of Matlab Constants, loop parameters, toggle switches % segmentation.m % clear all; % constants Fs=200; % Hz sec=1/Fs; filtfreq_low=8; filtfreq_high=0.0; % number of subjects and data files ibsubject=1; iesubject=12; ibfile=1; iefile=180; % toggle switches iplot=1; filter=1; outputwanted=1; Give your matlab programme a sensible name! Clear entire memory! Set constants Set loop parameters Exploit toggle switches (0=Off;1=On)

13 Use of Matlab Windows, name of file with design codes % windows for plotting purposes if iplot==1 fig1=figure('position',[5 300 400 220]); fig2=figure('position',[400 300 400 220]); end; % subject loop for subject=ibsubject:iesubject, pp=subject % without semi-colon to provide feedback in command window! ppstr=int2str(pp); % read the data from the design file design.txt prefix=['C:\Ruud\Projects\Objectsize\data\pp' ppstr '\']; fname=['design']; ext=['.txt']; filename=[prefix fname ext]; eval(['load ' filename]); design=eval(fname);

14 % put design information in separate arrays trialnr=design(:,1); vision=design(:,2); cylinder_size=design(:,3); ntrials=length(trialnr); % data file loop for jfile=1:ntrials, % feedback on filenumber in command window file=trialnr(jfile) % again without semicolon! fstr=int2str(file); % pick up IRED displacement data ext=['.otd']; if jfile<10 fname=['C#000' fstr]; end; if jfile>9 & jfile<100 fname=['C#00' fstr]; end; if jfile>99 fname=['C#0' fstr]; end; filename=[prefix fname ext]; Use of Matlab Design information, file loop, filename datafile

15 Use of Matlab Read data file % read IRED displacement data from file [hdr,cdata] = fpfread(filename); X1 Y1 Z1 X2 Y2 Z2 Time (samples) fpread.m is separate m-file Units: mm

16 Use of Matlab Preprocessing IRED displacement data % interpolate missing data points ndim=size(cdata); ns_ireds=ndim(1); for idim=1:ndim(2), h=cdata(:,idim); hi=interpolate_missing_data_points(h); cdata(:,idim)=hi; end; % convert to cm for idim=1:ndim(2), cdata(:,idim)=cdata(:,idim)./10; end; % Detect missing data value (-36973140302885665500000000000.0000) % and interpolate linearly function [x]=interpolate_missing_data_points(s); mdv=-36973140302885665500000000000.0000; ns=length(s); if s(1)==mdv i=1; while s(i)==mdv i=i+1; end; s(1:i)=s(i+1); end; for i=2:ns-1, if s(i)==mdv ib=i-1; j=i; while ((s(j)==mdv) & (j1 for k=ib:ie, s(k)=s(ib-1); end; end end; ds=(s(ie)-s(ib))./(ie-ib+1); for k=ib:ie, s(k)=s(ib)+((k-ib+1).*ds); end; x=s;

17 Use of Matlab Preprocessing IRED displacement data: A. filtering % filter data for idim=1:ndim(2), h=cdata(:,idim); hf=filteren(h,Fs,filtfreq_low); cdata(:,idim)=hf; end; Filter = 3rd-order Butterworth filter Applied forward and backward to prevent phase shift function[smooth]=filteren(data,Fs,Fc) % FILTEREN.M % function file voor filteren met verwijdering van de inslinger-effecten % Fs is de sample frequentie % Fc is de afsnijfrequentie [m,n]=size(data); Fs=Fs./2; [B,A]=butter(3,Fc/Fs); % 3e orde filter. % 6e orde low-pass filter, zero phase lag. for j=1:n smooth(:,j) = filtfilt(B,A,data(:,j)); end

18 Use of Matlab Preprocessing IRED displacement data: B. filtering % filter data for idim=1:ndim(2), h=cdata(:,idim); hf=filteren(h,Fs,filtfreq_low); cdata(:,idim)=hf; end; Red = raw signal Blue = smoothed signal Filter = 3rd-order Butterworth filter Applied forward and backward to prevent phase shift

19 Use of Matlab Additional arrays to prepare plotting % number of samples, time axis, y=0 axis ns=ndim(1); t=[1:ns].*sec; t=t'; y0=zeros(1,ns); y0=y0';

20 Use of Matlab Prepare plotting of top view of hand IRED positions % put IRED data in separate 3D matrix for i=1:ndim(1), for j=1:8, j1=j; k=(j1-1).*3+1; handx(i,j)=cdata(i,k); handy(i,j)=cdata(i,k+1); handz(i,j)=cdata(i,k+2); end; cdata 600x24 115200 double array handx 600x8 38400 double array handy 600x8 38400 double array handz 600x8 38400 double array

21 Use of Matlab Plot top view of hand % Plot XY plot if iplot==1, figure(fig1); set(gcf,'Color','white'); title('Top View'); hold on; axis equal; view(2); for i=1:4:600, plot3(handx(i,:),handy(i,:),handz(i,:),'k'); end; xlabel('X (cm)'); ylabel('Y (cm)'); end; % of if iplot==1 Start End

22 Use of Matlab Determine wrist speed function 1 2 3 4 5 7 6 8 % Determine wrist speed xw=handx(:,4); yw=handy(:,4); zw=handz(:,4); dxw=afgeleid(xw,Fs); dyw=afgeleid(yw,Fs); dzw=afgeleid(zw,Fs); vw=sqrt(dxw.^2+dyw.^2+dzw.^2); function [afgeleide]=afgeleid(data,sf) % AFGELEID.M % dit programma differentieert een willekeurige data set data die staat in een matrix % sf = samplefrequentie in Hz; Ron Jacobs, juli 1989 [m,n]=size(data); afgeleide=zeros(m,n); for i=3:m-2, afgeleide(i,:)=(-data(i-2,:)*1.5-data(i-1,:)*4+data(i+1,:)*4+data(i+2,:)*1.5)*(sf/14); end afgeleide(1,:) = afgeleide(3,:); afgeleide(2,:) = afgeleide(3,:); afgeleide(m,:) = afgeleide(m-2,:); afgeleide(m-1,:) = afgeleide(m-2,:);

23 Use of Matlab Check wrist speed function % Check wrist speed function in command window plot(vw); xlabel(‘samples’); ylabel(‘wrist speed (cm/s);

24 Use of Matlab Find critical time indices in wrist speed function % Find start and end of movement and time index of maximum speed [vmax,tvmax]=max(vw); vthreshold=.05.*vmax; ib=tvmax; while vw(ib)>=vthreshold & ib>2 ib=ib-1; end; ie=tvmax; while vw(ie)>=vthreshold & ie { "@context": "", "@type": "ImageObject", "contentUrl": "", "name": "Use of Matlab Find critical time indices in wrist speed function % Find start and end of movement and time index of maximum speed [vmax,tvmax]=max(vw); vthreshold=.05.*vmax; ib=tvmax; while vw(ib)>=vthreshold & ib>2 ib=ib-1; end; ie=tvmax; while vw(ie)>=vthreshold & ie=vthreshold & ib>2 ib=ib-1; end; ie=tvmax; while vw(ie)>=vthreshold & ie

25 Use of Matlab Determine aperture-time function % Determine aperture-time function for i=1:ndim(1); dx=handx(i,1)-handx(i,8); dy=handy(i,1)-handy(i,8); dz=handy(i,1)-handy(i,8); aperture(i)=sqrt(dx.^2+dy.^2+dz.^2); end; 1 2 3 4 5 7 6 8

26 Use of Matlab Check aperture-time function % Check aperture function in command window plot(aperture); xlabel(‘samples’); ylabel(‘aperture (cm);

27 Use of Matlab Find critical time indices in aperture-time function % Find maximum aperture and moment of maximum aperture [maxapt,tmaxapt]=max(aperture); mommaxapt=100.*((tmaxapt-ib)./(ie-ib)); tvmaxapt maxapt

28 Use of Matlab Calculate amplitude-scaled wrist speed function to plot simultaneously with aperture-time function % Calculate amplitude scaled wrist speed function scalefactor=max(aperture)./max(vw); vws=vw.*scalefactor; Define reference lines of critical time indices for plotting % Data for reference line in plotting tref(1)=tmaxapt;tref(2)=tmaxapt; aptref(1)=0;aptref(2)=maxapt; % Data for reference line in plotting trefv(1)=tvmax;trefv(2)=tvmax; vwref(1)=0;vwref(2)=max(vws);

29 Use of Matlab Plot aperture-time and normalized speed functions if iplot==1, figure(fig2); set(gcf,'Color','white'); title('Normalized Speed & Aperture')'; hold on; axis([t(ib) t(ie) 0 max(aperture)]); plot(t(ib:ie),aperture(ib:ie),'r'); plot(t(tref),aptref,'k'); plot(t(ib:ie),vws(ib:ie),'k-'); plot(t(trefv),vwref,'k'); xlabel('Time (s)'); ylabel('Aperture (cm)'); end; % of if iplot==1

30 Example: Prehension kinematics Time (s) Aperture (cm) Normalized speed (arbitrary units) Sneak preview

31 IRED configuration and joint angles 1 2 3 4 5 7 6 8 j1 j2 j3 j4 j5 j6 Sneak preview

32 Use of Matlab Determine joint angles in hand % Constants degtorad=pi./180; radtodeg=1./degtorad; % Determine enclosed angle of hand joints (n=6) for ired=1:6, for i=1:ns, pos1(1)=handx(i,ired); pos1(2)=handy(i,ired); pos1(3)=handz(i,ired); pos2(1)=handx(i,ired+1); pos2(2)=handy(i,ired+1); pos2(3)=handz(i,ired+1); pos3(1)=handx(i,ired+2); pos3(2)=handy(i,ired+2); pos3(3)=handz(i,ired+2); joint(i,ired)=angle2d_signed(pos1,pos2,pos3); end; function[alfa]=angle2d_signed(pos1,pos2,pos3); % calculates the 2D joint angle % Mary Klein Breteler, March 2002 % orientation of first segment th=atan2(pos2(1)-pos1(1),pos2(2)-pos1(2)); % orientation of second segment relative to first segment Rz = [cos(th) -sin(th) 0; sin(th) cos(th) 0; 0 0 1]; vec = pos2(1:2) - pos3(1:2); vec = [vec/norm(vec) 0]; vecrot = (Rz*vec')'; % angle alfa=atan2(vecrot(1),vecrot(2)); beta=unwrap(alfa); alfa=beta.*180/pi; % only positive values if alfa < 0, alfa = alfa + 360; end

33 Example: Joint rotations j1 j2 j3 j5 j6 j4 Note that joint angles may exceed 180 degs, partially due to their placement, i.e. imperfect alignment, and partially due to overextension. Sneak preview

34 Use of Matlab Calculating critical performance variables, e.g. % Find start and end of movement ib=fileib(jfile); ie=fileie(jfile); [vmax,tvmax]=max(vw(ib:ie)); tvmax=tvmax+ib; momvmax=100.*((tvmax-ib)./(ie-ib)); % Determine maximum and moment of maximum joint angles for j=1:6, [jointmax,tjointmax]=max(joint(ib:ie,j)); maxjntang(j)=jointmax; tmaxjntang(j)=100.*((tjointmax)./(ie-ib)); end;

35 Use of Matlab Time normalizing functions % store time-normalized kinematic functions n1=ie-ib+1; n2=50; vwtn=time_normalize(vw(ib:ie),n1,n2); % function [tx]=time_normalize(x,n1,n2); % % x = 1-dimensionaal input array (check op rij of kolom array) % n1 = lengte van input array x % n2 = gewenste lengte van outputarray tx % function [tx]=time_normalize(x,n1,n2); s=1:n1; step=(n1-1)./(n2-1); si=1:step:n1; tx=interp1(s,x,si,'spline'); 1.Resample function to 50 data points 2.Write resampled function to output file 3.Process resampled functions in Excel/SPSSX

36 Use of Matlab Creating a data matrix for statistical analysis % clear output arrays output=zeros(15,1); if outputwanted==1 output(1)=pp; output(2)=file; output(3)=vision(file); % vision output(4)=objectsize(file); % size output(5)=(ie-ib).*sec; % MT output(6)=vmax; % peak speed output(7)=momvmax; % moment peak speed (%MT) output(8)=maxapt; % peak aperture (cm) …Etc.

37 Use of Matlab - Write outputfile for SPSSX % Write outputfile of, say 8 variables (independent + dependent) per observation if outputwanted==1 ext_out=['.dat']; fnameout=['output_new']; outname=[prefix fnameout ext_out]; fid=fopen(outname,'a'); f='%8.3f '; f_last='%8.3f\n'; % Take care number of f's equals number of output variables minus 1 outputformat=([f f f f f f f f_last]); fprintf(fid,outputformat,output); fclose(fid); end; % of outputwanted==1

Download ppt "Using Ruud Meulenbroek David Rosenbaum, Mary Klein Breteler, Bert Steenbergen 12 May 2005 in a Prehension Study."

Similar presentations

Ads by Google