function legTrackerEthogram(trans) %legTrackerEthogram constructs ethograms given a transition matrix, as in %figure 3d of Kain et al. %Usage: %legTrackerEthogram(trans) %trans = 12x12 transition matrix generated from a sequence of behavioral % labels. %make a list of nice positions for each behavioral node nodePos=[]; nodePos=[nodePos;-0.5 1.0]; %nothing nodePos=[nodePos; 0.0 1.0]; %adjustments nodePos=[nodePos;-1.3 2.0]; %fwd nodePos=[nodePos;-0.6 2.5]; %turn in place nodePos=[nodePos; 0.1 2.5]; %crabwalk nodePos=[nodePos; 0.8 2.0]; %complex motion nodePos=[nodePos;-1.3 0.0]; %L1 groom nodePos=[nodePos;-0.6 -0.5]; %head groom nodePos=[nodePos; 0.0 -1.4]; %L2-3 groom nodePos=[nodePos; 0.1 -0.5]; %abd groom nodePos=[nodePos; 0.8 0.0]; %L3 groom nodePos=[nodePos;-0.5 -1.4]; %other %how far apart to make the ndoes scaling=1.5; nodePos=nodePos*scaling; %start figure figure; hold on; %put nodes into figure plot(nodePos(:,1),nodePos(:,2),'ro', 'MarkerSize', 10); %visualization parameters edgeCutoff=0.00; minEdge=0.5; maxEdge=4; arrowSpace=0.4; gapMag=0.12; %for all pairs of behavioral labels for i=1:12 for j=1:12 %add an edge if the transition is frequent enough if trans(i,j)>edgeCutoff % determine start and end points of the transition edge startPos=nodePos(i,:); endPos=nodePos(j,:); dX=nodePos(j,1)-nodePos(i,1); dY=nodePos(j,2)-nodePos(i,2); %with a gap for the arrowhead offSet=gapMag*[-dY dX]/sqrt(dX^2+dY^2); lineLength=sqrt(sum((startPos-endPos).^2)); perc=(lineLength-arrowSpace)/lineLength; %arrowhead size changes with line thickness colInten=1-trans(i,j); xVec=[startPos(1) startPos(1)+dX*perc]+offSet(1)*(1-colInten); yVec=[startPos(2) startPos(2)+dY*perc]+offSet(2)*(1-colInten); %draw the line line(xVec,yVec,'lineWidth', trans(i,j)*(maxEdge-minEdge)+minEdge, 'Color', [colInten colInten colInten]); end end end %frame figure xlim([-2 3]*scaling); ylim([-2 3]*scaling); axis square hold off;