{Cavalieri Macros written by Glen MacDonald, Hearing Development Laboratories RL-30, Univ. Washington, (206) 543-8360, glenmac@u.washington.edu. March 16, 1993 rev April 6, 1993 Thanks to Ed Huff and Wayne Rasband for their suggestions.} var {global variables} Geometric,Gridsize,Pelpermicron,N3,N2,N1:real; pointCount,Count1,Count2,Count3,Count4,ClickCount,x,y,randomvalue,limit,width,height,expon,color:integer; Macro 'Set Scale [S]'; begin Pelpermicron:=GetNumber('How many pixels per micron?',1.07); SetScale(pelpermicron,'µm'); end; Macro 'Capture Image, with Scale [G]'; var capt:integer; begin If capt>0 then begin StopCapturing; capt:=0; exit; end; If capt=0 then begin StartCapturing; capt:=1; exit; end; if pelpermicron>0 then SetScale(pelpermicron,'µm') else SetScale(0,'pixels'); end; macro '(---'; begin end; Procedure WaitForButton; begin repeat until Button; repeat until not button; end; macro 'Identify Sample [I]'; begin RequiresVersion(1.49); GetPicSize(width,height); SetOptions('Area,Mean,Std.Dev,X-YCenter,Major,Minor,User1,User2'); SetPrecision(1); SetMajorLabel('Count1'); SetMinorLabel('Count2'); SetUser1Label('Count3'); SetUser2Label('Count4'); N1:=GetNumber('Slide Number:',3); N2:=GetNumber('Section:',1); N3:=GetNumber('Other Identifier:',0); SetCounter(rCount+1);{store the counter} ClickCount:=rCount; Count1:=0; Count2:=0; Count3:=0; Count4:=0; end; Procedure CountPoints; begin SetCursor('cross'); WaitForButton; getMouse(x,y); Measure; PointCount:=PointCount+1; MakeOvalRoi(x,y,8,8); Fill; end; macro 'Count First Label [1]'; begin killroi;{get around the NotInBounds error} SetForegroundColor(1); PointCount:=0; getMouse(x,y); repeat while (x>0) and (y>0) do begin CountPoints; end; if (x<0) or (y<0) then begin Count1:=PointCount-1;{delete terminating count} UpdateResults; SetCounter(clickCount); end; beep; exit; end; macro 'Count Second Label [2]'; begin killroi; SetForegroundColor(2); PointCount:=0; getMouse(x,y); repeat while (x>0) and (y>0) do begin CountPoints; end; if (x<0) or (y<0) then begin Count2:=PointCount-1;{delete terminating count} UpdateResults; SetCounter(clickCount); end; beep; exit; end; macro 'Count Third Label [3]'; begin killroi; SetForegroundColor(3); PointCount:=0; getMouse(x,y); repeat while (x>0) and (y>0) do begin CountPoints; end; if (x<0) or (y<0) then begin Count3:=PointCount-1;{delete terminating count} UpdateResults; SetCounter(clickCount); end; beep; exit; end; macro 'Count Fourth Label [4]'; begin killroi; SetForegroundColor(4); PointCount:=0; getMouse(x,y); repeat while (x>0) and (y>0) do begin CountPoints; end; if (x<0) or (y<0) then begin Count4:=PointCount-1;{delete terminating count} UpdateResults; SetCounter(clickCount); end; beep; exit; end; macro 'Done with Counts [D]'; begin if ClickCount=0 then begin PutMessage('The first sample has not been identified.'); exit; end; SetForegroundColor(254); rX[rCount]:=geometric; rY[rCount]:=expon; rMajor[rCount]:=Count1; rMinor[rCount]:=Count2; rUser1[rCount]:=Count3; rUser2[rCount]:=Count4; rArea[rCount]:=N1; rStdDev[rCount]:=N3; rMean[rCount]:=N2; UpdateResults; SetCounter(clickCount); end; macro '(---'; begin end; {Grid - draws a template grid of squares over the screen, with user designated square size and starting area for the randomly located origin.} Procedure LineNumber; begin Gridsize:=GetNumber('Width of each square, in pixels:', 40); if Gridsize=0 then begin PutMessage('Choose an interval greater than 0!'); exit; end; GetPicSize(width,height); linesv:=(width/Gridsize);{number of vertical lines} linesh:=(height/Gridsize);{number of horizontal lines} end; Procedure MeasureGrid; begin MakeRoi(xr,yr,GridSize,GridSize); measure; Geometric:=rArea[rCount]; expon:=2; KillRoi; SetCounter(clickCount); end; Procedure RandomStart; {var startinterval,xr,yr:integer;} begin startinterval:=GetNumber('Random region, in squares:',1); xr:=(random*(startinterval*Gridsize)); yr:=(random*(startinterval*Gridsize)); end; Macro 'Point Count Grid [P]'; var i,xr,yr,x,y,xf,yf,left,top,x1,y1,x2,y2:integer; linesvcorr,lineshcorr,startinterval,linesv,linesh:real; begin SetForegroundColor(color); SetLineWidth(1); GetPicSize(width,height); LineNumber;{divides picH and picW by the interval farapart to get the number of lines to fill the picture} RandomStart; lineshcorr:=(linesh+1); linesvcorr:=(linesv+1); MoveTo(xr,yr); {go to the random starting point} xf:=Gridsize; LineTo(xr,height);{draw first vertical line from random start to x-axis} MakeLineroi(xr,yr,xr,height); {line from random start to bottom} for i:=1 to linesvcorr do begin {fill screen with vertical lines} DrawBoundary; {mark this line} MoveRoi(xf,0); {move left by lineinterval, down by 0} end; MoveTo(xr,yr); yf:=Gridsize; LineTo(width,yr);{draw first horizontal line} MakeLineRoi(xr,yr,width,yr); for i:=1 to lineshcorr do begin {fill screen with horizontal lines} DrawBoundary; MoveRoi(0,yf); end; MeasureGrid; end; Macro 'Counting Frame [F]'; var FrameSize:real; height,width,xf1,yf1,xf2,yf2,xf3,yf3,xf4,yf4:integer; begin GetPicSize(width,height); FrameSize:=GetNumber('Frame Length (pixels)',400); xf1:=(width-FrameSize)/2; yf1:=(Height-FrameSize)/2; SetLineWidth(2); MakeRoi(xf1,yf1,FrameSize,Framesize); end; Macro 'Draw Frame Boundary [B]'; begin measure; Geometric:=rArea[rCount]; expon:=2; DrawBoundary; KillRoi; SetCounter(clickCount); end; Macro 'Measure Length [L]'; begin SetLineWidth(1); Measure; Geometric:=rLength[rCount]; expon:=1; DrawBoundary; KillRoi; SetCounter(clickCount); end; macro '(---'; begin end; {Random Numbers Macros, rev. May 18, 1994} {Press U to set the upper limit for a given session and to generate a random integer between 1 and the upperlimit. R generates random integers between 1 and the upperlimit.} var randomvalue,limit,i,HowMany:integer; Procedure RandomNumber; begin randomvalue:=round(random*limit); repeat randomvalue:=round(random*limit); until randomvalue > 0; end; Procedure UpperLimit; begin limit:=GetNumber('Upper limit?',30); RandomNumber; PutMessage(randomvalue); end; Macro 'Upper Limit for Random Numbers [U]'; begin UpperLimit; end; Macro 'Random Numbers [R]'; begin if limit >0 then begin RandomNumber; PutMessage(randomvalue); end; if limit = 0 then UpperLimit; end; Macro 'List of Random Numbers [L]'; begin SetOptions('User1'); SetUser1Label('Random'); limit:=GetNumber('Upper limit?',10); HowMany:=GetNumber('How many random numbers?',30); repeat for i:=1 to HowMany do begin SetCounter(rCount+1); RandomNumber; rUser1[rCount]:=randomvalue; UpDateResults; end; Macro 'ReSet Counter [C]'; begin SetCounter(0); end; macro '(---'; begin end; Macro 'Set Grid Color'; begin ShowMessage(' Red is 1 \ Green is 2 \ Blue is 3 \ Yellow is 4 \ Aqua is 5 \ Magenta is 6 \ The default is aqua (5)'); color:=GetNumber('What color for the grid?',5); end; Macro 'Enhance Contrast [E]'; begin EnhanceContrast; end; Macro 'Flip Horizontal [H]'; begin FlipHorizontal; end; Macro 'Flip Vertical [V]'; begin FlipVertical; end;