{ Markup Macro -- Allows the setting of Markup Image in 2 and 3 dimensions. Selected ROIs are copied to a ROI image and can be set to a certain value (e.g. The Markup Group value.) Markup group values are set in the assignment macro. Presently, the maximum number of groups are 16 but this can be easily extend. version 1.0 22 June 1994 Doug Morris - University of Illinois - Biomedical Magnetic Resonance Lab dmorris@bmrl.med.uiuc.edu } var cnumber,status,tstatus,dtime,loadimage,fillitvar:integer; numc,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16:integer; tstack,dstack:string; procedure CheckForStack; { CheckForStack procedure will allow check to see if a stack exists } 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; procedure help; begin NewTextWindow('Markup Macros Help',450,250); Writeln(''); Writeln(' 1) Setup Mask Window - Sets up the appropriate window for '); Writeln(' for storing the user generated markup masks. This must be '); Writeln(' performed before before anything else.'); Writeln(''); Writeln(' 2) Assign Markup Values - Assigns a value to the each of the markup'); Writeln(' groups. A maximum of 16 groups or compartments are allowed.'); Writeln(' This must be preformed prior to any markup operations.'); Writeln(''); Writeln(' 3) Select Group [G] - assigns a Group number for the masks '); Writeln(' generated by the Mark ROI macro. You may choose any group '); Writeln(' within the number assigned.'); Writeln(''); Writeln(' 4) Mark ROI [M] - Copies an ROI and fills it with a markup group value '); Writeln(' in the Window ROItemp. This routine places the ROI at the same'); Writeln(' coordinates in the mask image as the original image. The routine'); Writeln(' handles 2D and 3D files. Any ROI tool available to NIH Image '); Writeln(' may be used. (e.g. Density Slicing, misc ROI tools, line tools)' ); Writeln(''); Writeln(' 5) Place ROI [R] - This routine places the ROI at the same'); Writeln(' coordinates in the mask image as the original image. The routine'); Writeln(' handles 2D and 3D files. It does not assign fill values to the ROI '); Writeln(''); Writeln(' 6) ROI Info - reports ROI dimensions and coordinates in terms of'); Writeln(' (x,y) coordinates of the upper left corner and the width and'); Writeln(' height of the ROI.'); Writeln(''); Writeln(' 7) Help - View this text.'); end; macro ' == Markup Macros ==' ; begin help; end; macro '(-' begin end; macro ' - Setup Markup Macros -' begin end; macro 'Setup Mask Window'; { Setup Mask Window and Get it ready to take Data } var xsize,ysize,n,i:integer; begin GetPicSize(xsize,ysize); SetNewSize(xsize,ysize); n:=nSlices; if nSlices < 2 then begin MakeNewWindow('ROItemp'); end; if nSlices > 2 then begin MakeNewStack('ROItemp'); for i:=1 to n-1 do begin AddSlice; end; SelectSlice(1) ; end; rUser1[1]:=StringtoNum('1'); end; macro 'Assign Markup Values'; { Select Group Number you assign to your ROI } var i:integer; begin numc:=GetNumber('Number of Groups?',2); if numc > 16 then begin PutMessage('Limited to 16 groups'); Exit; end; for i:=1 to numc do begin if i=1 then c1:=GetNumber('Group Value?',16); if i=2 then c2:=GetNumber('Group Value?',32); if i=3 then c3:=GetNumber('Group Value?',48); if i=4 then c4:=GetNumber('Group Value?',64); if i=5 then c5:=GetNumber('Group Value?',80); if i=6 then c6:=GetNumber('Group Value?',96); if i=7 then c7:=GetNumber('Group Value?',112); if i=8 then c8:=GetNumber('Group Value?',128); if i=9 then c9:=GetNumber('Group Value?',144); if i=10 then c10:=GetNumber('Group Value?',160); if i=11 then c11:=GetNumber('Group Value?',176); if i=12 then c12:=GetNumber('Group Value?',192); if i=13 then c13:=GetNumber('Group Value?',208); if i=14 then c14:=GetNumber('Group Value?',224); if i=15 then c15:=GetNumber('Group Value?',240); if i=16 then c16:=GetNumber('Group Value?',255); end; end; macro '(-' begin end; macro ' - Markup Operations -' begin end; macro 'Select Group [G]'; { Select Group Number you which to assign your ROI } begin cnumber:=GetNumber('Which Group?',1); if ((cnumber < 1) OR (cnumber > numc)) then begin PutMessage('Only Groups 1 through ',numc:2:0,' are valid!'); Exit; end; rUser2[1]:=cnumber; end; procedure maskit; { Macro to create markup data numbered groups. The macro copies data from the Image ROI and pastes it into the Mask window. The macro sets the ROI in the Mask window at a certain value. Alternatively, one may place an ROI in the Mask window at natural greyscale intensities. } var r,i,j,xsize,ysize,numx,numy,denomx,denomy,top,top1,left,left1,width,height:integer; npic,lower,upper,whichslice,n:integer; x,y:real; begin if (rUser1[1] <> 1) then begin PutMessage('Use Setup Mask Window First!'); Exit; end; SetOptions('User2'); cnumber:=rUser2[1]; if ((rUser2[1] < 1) OR (rUser2[1] > numc)) then begin PutMessage('Invalid Compartment number!',cnumber); Exit; end; { PutMessage('Compartment number', rUser2[1]:2:0); } numx := 0; numy := 0; denomx := 0; denomy := 0; RequiresVersion(1.53); npic:=PicNumber; n:=nSlices; GetThresholds(lower,upper) ; GetPicSize(xsize,ysize); ResetCounter; if n > 2 then whichslice:=SliceNumber; GetRoi(left,top,width,height); Copy; KillRoi; SelectWindow('ROItemp'); if n > 2 then SelectSlice(whichslice); RestoreRoi; GetRoi(left1,top1,width,height); MoveROI(left-left1,top-top1); Paste; if (fillitvar = 1) then begin if (cnumber = 1) then SetForegroundColor(c1); if (cnumber = 2) then SetForegroundColor(c2); if (cnumber = 3) then SetForegroundColor(c3); if (cnumber = 4) then SetForegroundColor(c4); if (cnumber = 5) then SetForegroundColor(c5); if (cnumber = 6) then SetForegroundColor(c6); if (cnumber = 7) then SetForegroundColor(c7); if (cnumber = 8) then SetForegroundColor(c8); if (cnumber = 9) then SetForegroundColor(c9); if (cnumber = 10) then SetForegroundColor(c10); if (cnumber = 11) then SetForegroundColor(c11); if (cnumber = 12) then SetForegroundColor(c12); if (cnumber = 13) then SetForegroundColor(c13); if (cnumber = 14) then SetForegroundColor(c14); if (cnumber = 15) then SetForegroundColor(c15); if (cnumber = 16) then SetForegroundColor(c16); Fill; end; ResetCounter; KillRoi; SelectPic(npic); if n > 2 then begin SelectSlice(whichslice); end; if ((lower<>0) OR (upper<>0)) then begin SetDensitySlice(255,255); end; end; macro 'Mark ROI [M]'; begin fillitvar:=1; maskit; end; macro 'Place ROI [R]'; begin fillitvar:=0; maskit; end; macro 'ROI Info[I]'; { Gives info for selected ROI } var left,top,width,height:integer; begin GetRoi(left,top,width,height); If (width = 0) then begin PutMessage('ROI must be selected'); Exit; end; If (width <>0) then begin PutMessage('ROI Info: ','left= ',left:4:0,' top= ',top:4:0,' width= ',width:4:0,' height= ',height:4:0); Exit; end; end; macro '(-' begin end; macro 'Help'; begin help; end;