{ Macro for clipping pieces of various images to a montage and a stack The ExtraAddOn line below determines how much of a border to place around the pieces in the montage By Mark Vivino 2/14/94 301-402-2633 } var RoiLeft,RoiTop,RoiWidth,RoiHeight:integer; OldLeft,OldTop:integer; MontageWidth,MontageHeight:integer; MontagePid, StackPid,ExtraAddOn:integer; WindowName:string; macro 'Make montage and stack window [1]'; var WidthPieces, HeightPieces:integer; begin RequiresVersion(1.54); GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); if RoiWidth=0 then begin PutMessage('This macro expects a ROI to be drawn.'); exit; end; ExtraAddOn := 20; SetBackgroundColor(0); WindowName := WindowTitle; WidthPieces := Getnumber('How many ROIs to copy along X axis',5); HeightPieces := Getnumber('How many ROIs to copy along Y axis',5); MontageWidth :=RoiWidth*WidthPieces + ExtraAddOn*WidthPieces + ExtraAddOn; MontageHeight :=RoiHeight*HeightPieces+ExtraAddOn*HeightPieces + ExtraAddOn; SetNewSize(MontageWidth,MontageHeight); MakeNewWindow('Montage'); MontagePid := PidNumber; SetNewSize(RoiWidth,ROIHeight); MakeNewStack('Analysis stack'); StackPid := PidNumber; OldLeft:=ExtraAddOn; OldTop := ExtraAddOn; SelectWindow(WindowName); end; macro 'Add to montage and stack window [2]'; var OriginalPid:Integer; begin if WindowTitle='Montage' then begin PutMessage('Be sure your ROI is showing on the data to be copied and re-run macro'); exit; end; if WindowTitle='Analysis stack' then begin PutMessage('Be sure your ROI is showing on the data to be copied and re-run macro'); exit; end; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); if RoiWidth=0 then begin PutMessage('You must select your ROI before you run this macro'); exit; end; Copy; OriginalPid := PidNumber; If Not PidExists(MontagePid) then exit; SelectPic(MontagePid); MakeRoi(OldLeft,OldTop,RoiWidth,RoiHeight); OldLeft := OldLeft+RoiWidth+ExtraAddOn; if OldLeft >= (MontageWidth-ExtraAddOn) then begin OldLeft :=ExtraAddOn; OldTop := OldTop+RoiHeight+ExtraAddOn; end; Paste; If Not PidExists(StackPid) then exit; SelectPic(StackPid); Paste; If (OldTop + RoiHeight+ExtraAddOn) > MontageHeight then exit; AddSlice; SelectPic(OriginalPid); end; macro 'Restore ROI to new window [3]'; begin MakeRoi(0,0,RoiWidth,RoiHeight); end;