{This file contains additional macros that work with stacks.} procedure CheckForStack; begin if nPics=0 then begin PutMessage('This macro requires a stack.'); exit; end; if nSlices=0 then begin PutMessage('This window is not a stack.'); exit; end; end; macro 'Add Slice [A]'; begin CheckForStack; AddSlice end; macro 'Delete Slice [D]'; begin CheckForStack; DeleteSlice end; macro 'First Slice [F]'; begin CheckForStack; SelectSlice(1) end; macro 'Last Slice [L]'; begin CheckForStack; SelectSlice(nSlices) end; macro '(-' begin end; macro 'Smooth'; var i:integer; begin CheckForStack; for i:= 1 to nSlices do begin SelectSlice(i); SetOption; Smooth; end; end; macro 'Invert'; var i:integer; begin CheckForStack; for i:= 1 to nSlices do begin SelectSlice(i); Invert; end; end; macro 'Make Surface Plot MovieÉ'; var i,OldStack,NewStack:integer; N,PlotWidth,PlotHeight:integer; ScaleFactor:real; OneToOne:boolean; begin RequiresVersion(1.50); CheckForStack; SaveState; OldStack:=PicNumber; N:=nSlices; PlotWidth:=GetNumber('Surface Plot Width:',300); PlotHeight:=GetNumber('Surface Plot Height:',PlotWidth); SetNewSize(PlotWidth,PlotHeight); MakeNewStack('Stack'); NewStack:=PicNumber; SelectPic(OldStack); for i:= 1 to N do begin SelectSlice(1); SurfacePlot; SelectAll; Copy; Dispose; SelectPic(NewStack); if i<>1 then AddSlice; Paste; SelectPic(OldStack); DeleteSlice; end; Dispose; {OldStack} RestoreState; end; macro 'Make Expression MovieÉ [E]'; { Requires the Expression 3.0b filter plug-in, which is available by anonymous FTP from zippy.nimh.nih.gov, in the /pub/nih-image/plug-ins directory. } var width,height,nframes,i:integer; begin RequiresVersion(1.56); width:=GetNumber('Width:',200); height:=GetNumber('Height:',width); nframes:=GetNumber('Number of Frames:',50); SetNewSize(width,height); MakeNewStack('Stack'); MakeNewWindow('Temp'); CallFilter('Reset'); for i:=1 to nframes do begin SelectWindow('Temp'); CallFilter('Expression 3.0'); SelectAll; Copy; SelectWindow('Stack'); if i<>1 then AddSlice; paste; end; SelectWindow('Temp'); Dispose; end; macro 'Animate Stack'; var i,delay:integer; begin RequiresVersion(1.56); CheckForStack; i:=0; delay:=0.1; repeat i:=i+1; if i>nSlices then i:=1; Wait(delay); SelectSlice(i); if KeyDown('shift') then delay:=1.5*delay; if delay>1 then delay:=1; if KeyDown('control') then delay:=0.66*delay; if KeyDown('option') then beep; ShowMessage('delay=',delay:4:2); until button; end;