procedure DoFilter(type:integer); VAR i, j, picNo: integer; BEGIN picNo := PicNumber; SelectPic(picNo); SetOption; j := 0; if type = 4 then BEGIN WHILE (j < 1) OR (j > 3) DO BEGIN j := GetNumber('Metz: 1-smooth 2-sharp 3-big',j); END; END; IF (nSlices < 2) then BEGIN if type = 1 then smooth; if type = 2 then sharpen; if type = 3 then reduceNoise; if type = 4 then BEGIN if j = 1 then Convolve('metzsmooth'); if j = 2 then Convolve('metzsharp'); if j = 3 then Convolve('metzbig'); END; END; IF (nSlices > 1) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); if type = 1 then smooth; if type = 2 then sharpen; if type = 3 then reduceNoise; if type = 4 then BEGIN if j = 1 then Convolve('metzsmooth'); if j = 2 then Convolve('metzsharp'); if j = 3 then Convolve('metzbig'); END; END; SelectSlice(1); END; END; procedure DoRotate(direction:string); VAR i, N, picNo, pic2No, pic3No, width, height: integer; isTrue: Boolean; BEGIN picNo := PicNumber; isTrue := true; SelectPic(picNo); GetPicSize(width,height); SetNewSize(height,width); SetOption; IF (width = height) THEN BEGIN isTrue := false; END; N := nSlices; IF ( N < 2) THEN BEGIN if direction = 'L' then RotateLeft(isTrue); if direction = 'R' then RotateRight(isTrue); killRoi; ChoosePic(picNo); killRoi; END; IF (N > 1) THEN BEGIN FOR i := 1 TO N DO BEGIN IF ((isTrue = true) AND (i = 1)) THEN BEGIN MakeNewStack('Rotated'); pic2No:=PicNumber; END; ChoosePic(picNo); ChooseSlice(i); if direction = 'L' then RotateLeft(isTrue); if direction = 'R' then RotateRight(isTrue); IF (isTrue = true) THEN BEGIN pic3No := picNumber; ChoosePic(pic3No); SelectAll; Copy; Dispose; ChoosePic(pic2No); paste; IF ( i < N) THEN addSlice; IF ( i = N) THEN BEGIN ChoosePic(picNo); dispose; SelectPic(nPics); ChooseSlice(1); killRoi; END; END; END; END; END; macro '[A] Animate All'; VAR i, j, n, picNo: integer; BEGIN picNo := picNumber; IF (nslices < 2) THEN BEGIN PutMessage('Not all windows are stacks.'); EXIT; END; n := nSlices; FOR i := 1 to nPics DO BEGIN choosePic(i); IF (nslices < 2) THEN BEGIN PutMessage('Not all windows are stacks.'); EXIT; END; IF ((nSlices < n) OR (nSlices > n)) THEN BEGIN PutMessage('All open stacks must have the same number of slices'); EXIT; END; END; i:=0; repeat i:=i+1; if i>nSlices then i:=1; FOR j := 1 to nPics DO BEGIN choosePic(j); selectSlice(i); END; until button; end; macro '[B] Back Projection'; VAR i, j, k, N, OldStack,NewStack, temp, maxCts: integer; RoiLeft, RoiTop, RoiWidth, RoiHeight: integer; Left, Top, Width, Height, transaxials: integer; angle, start, scaleFactor: real; BEGIN SaveState; ChoosePic(nPics); OldStack:=nPics; N:=nSlices; IF (N < 2) THEN BEGIN PutMessage('The window is not a stack.'); EXIT; END; maxCts := 0; start := -45; start := getNumber('Enter starting angle',start); angle := 180; angle := getNumber('Enter Length of arc',angle); angle := angle / nSlices; SetScaling('Bilinear; Same Window'); GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); IF (RoiWidth = 0) THEN BEGIN selectAll; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); END; FOR i:= 1 to N DO BEGIN chooseSlice(i); Measure; if rMax[rCount] > maxCts THEN maxCts := rMax[rCount]; scaleFactor := 256 / maxCts; END; killroi; GetPicSize(Width,Height); SetNewSize(Width,Height); IF (N > 1) THEN BEGIN MakeNewStack('Transaxials'); transaxials:=PicNumber; MakeNewWindow('Projection'); NewStack:=PicNumber; FOR k:= RoiTop+1 TO RoiTop+RoiHeight-1 DO BEGIN FOR i:= 1 to N DO BEGIN tilewindows; ChoosePic(OldStack); ChooseSlice(i); MakeLineRoi(0,k,Width,k); copy; killroi; ChoosePic(NewStack); FOR j:= 0 TO Height-1 DO BEGIN MakeLineRoi(0,j,Width,j); Paste; killroi; END; MultiplyByConstant(scaleFactor); ScaleAndRotate(1,1,start + ((i-1) * angle)); MultiplyByConstant(1/i); ImageMath('add',transaxials,newStack,(i/(i+1)),0,'temp'); ChoosePic(nPics); selectall; copy; dispose; choosePic(transaxials); paste; END; if k < RoiTop + RoiHeight - 1 then addSlice; tilewindows; END; choosePic(nPics); dispose; RestoreState; END; END; macro '[C] Crop images'; VAR i,OldStack,NewStack:integer; RoiLeft,RoiTop,RoiWidth,RoiHeight:integer; N:integer; BEGIN SaveState; OldStack:=PicNumber; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); IF (RoiWidth = 0) THEN BEGIN PutMessage('A rectangular ROI must be created'); EXIT; END; killRoi; N:=nSlices; SetNewSize(RoiWidth,RoiHeight); SetScaling('Bilinear; Create New Window'); SelectPic(OldStack); IF (N < 2) THEN BEGIN makeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); ScaleAndRotate(1,1,0); SelectPic(oldStack); killRoi; SelectPic(nPics); END; IF (N > 1) THEN BEGIN MakeNewStack('Stack'); NewStack:=PicNumber; FOR i:= 1 to N DO BEGIN choosePic(OldStack); chooseSlice(i); makeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); ScaleAndRotate(1,1,0); SelectAll; Copy; dispose; choosePic(NewStack); Paste; IF (i < N) THEN addSlice; END; ChoosePic(oldStack); killRoi; SelectPic(nPics); killRoi; selectSlice(1); END; RestoreState; END; macro '[E] Translate Elscint Images'; {Imports Elscint 8-bit images into a stack.} VAR i,width,height,nImages,offset: integer; patientName,buffer: String; BEGIN RequiresVersion(1.50); patientName := ''; SetImport('8-bit'); SetCustom(256,1,0); Import(''); FOR i := 1 to 15 do BEGIN If (GetPixel(15 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(15 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); FOR i := 1 to 10 do BEGIN If (GetPixel(70 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(70 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); Dispose; SetCustom(256,1,512); Import(''); {Read in header as an image, prompting for file name.} width := GetPixel(6,0); width := width + ( 256 * GetPixel(7,0) ); height := GetPixel(8,0); height := height + ( 256 * GetPixel(9,0) ); FOR i := 1 to 6 do BEGIN If (GetPixel(33 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(33 + i,0) ); patientName := concat(patientName,buffer ); END; END; nImages:=GetPixel(155,0); nImages:=nImages + (GetPixel(156,0) * 256); Dispose; offset:= 2560; SetCustom(width,height,offset,nImages); SetImport('8-bit, Calibrate, Fixed Scale'); Import(''); Beep; Beep; SetPicName(patientName); Save; END; macro '[F] Filter Images'; VAR type: integer; BEGIN type := 0; WHILE (type < 1) OR (type > 4) DO BEGIN type := GetNumber('1-smooth 2-sharp 3-reduce 4-metz',type); DoFilter(type); END; END; macro '[G] Gray Scale'; BEGIN SetPalette('GrayScale'); END; macro '[H] Flip Horizontal'; VAR i, picNo: integer; BEGIN picNo := PicNumber; SelectPic(picNo); SetOption; IF ( nSlices < 2) THEN BEGIN FlipHorizontal; END; IF ( nSlices > 1) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); FlipHorizontal; END; selectSlice(1); END; END; macro '[I] Invert LUT'; BEGIN InvertLUT; END; macro '[L] Look Up Table Import'; { Imports a LUT stored as three column (red, green, blue) text file. If there are four columns then the first column is assumed to conatin sequence numbers and is ignored. } var i,r,g,b, width, height, start, row:integer; begin RequiresVersion(1.53); SetImport('Text'); Import(''); GetPicSize(width,height); if width=3 then begin r:=0; g:=1; b:=2 end else if width=4 then begin r:=1; g:=2; b:=3 end else begin PutMessage('The text file must have either 3 or 4 columns.'); exit; end; if height=255 then start:=1 else if height=256 then start:=0 else begin PutMessage('The text file must have either 255 or 256 rows.'); exit; end; i:=start; row:=0; repeat RedLut[i]:=GetPixel(r,row); GreenLut[i]:=GetPixel(g,row); BlueLut[i]:=GetPixel(b,row); if (i mod 10) = 0 then UpdateLUT; i:=i+1; row:=row+1; until row>=height; UpdateLUT; PropagateLUT; dispose; end; macro '[M] Multiply by Constant'; VAR i, picNo,constant: integer; BEGIN picNo := PicNumber; SelectPic(picNo); SetOption; constant := 2; constant := getNumber('Enter multiplication factor',constant); IF ( nSlices < 2) THEN BEGIN MultiplyByConstant(constant); END; IF ( nSlices > 1) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); MultiplyByConstant(constant); END; selectSlice(1); END; END; macro '[O] Oblique Angulation'; VAR i,N,OldStack,NewStack: integer; RoiLeft,RoiTop,RoiWidth,RoiHeight: integer; angle: real; BEGIN SaveState; OldStack:=PicNumber; angle := -30; angle := getNumber('Enter angle to rotate',angle); selectAll; getRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); killRoi; N:=nSlices; SetNewSize(RoiWidth,RoiHeight); SetScaling('Bilinear; Create New Window'); IF (N < 2) THEN BEGIN ScaleAndRotate(1,1,angle); killRoi; END; IF (N > 1) THEN BEGIN MakeNewStack('Stack'); NewStack:=PicNumber; FOR i:= 1 to N DO BEGIN choosePic(OldStack); chooseSlice(i); makeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); ScaleAndRotate(1,1,angle); SelectAll; Copy; dispose; choosePic(OldStack); killRoi; choosePic(NewStack); Paste; killRoi; IF (i < N) THEN addSlice; END; SelectPic(nPics); ChooseSlice(1); END; RestoreState; END; macro '[P] Translate Pegasys Images'; {Imports Pegasys images into a stack.} VAR i,width,height,,depth,nImages,offset: integer; patientName,buffer: String; BEGIN RequiresVersion(1.50); patientName := ''; SetImport('8-bit'); SetCustom(512,1,512); Import(''); FOR i := 1 to 10 do BEGIN If (GetPixel(25 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(25 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); FOR i := 1 to 9 do BEGIN If (GetPixel(46 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(46 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); FOR i := 1 to 7 do BEGIN If (GetPixel(112 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(112 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); FOR i := 1 to 5 do BEGIN If (GetPixel(265 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(265 + i,0) ); patientName := concat(patientName,buffer ); END; END; width := GetPixel(305,0); width:=width + (GetPixel(304,0) * 256); height := GetPixel(307,0); height:=height + (GetPixel(306,0) * 256); nImages:=GetPixel(309,0); nImages:=nImages + (GetPixel(308,0) * 256); depth := GetPixel(333,0); Dispose; IF depth = 8 THEN SetImport('8-bit, Fixed Scale'); IF depth = 16 THEN SetImport('16-bit Unsigned, Fixed Scale'); offset:= 2048; SetCustom(width,height,offset,nImages); Import(''); IF ((depth = 16) AND (nSlices > 1)) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); Invert; END; END; IF ((nSlices < 2) AND (depth = 16)) THEN Invert; Beep; Beep; SetPicName(patientName); Save; END; macro '[R] Rotate Images'; VAR direction: string; BEGIN direction := 'undefined'; WHILE ((direction <> 'R') AND (direction <> 'L')) DO BEGIN direction := getString('R - right L - left',direction); END; DoRotate(direction); END; macro '[S] Shuffle images'; VAR i, j, heads, projections, picNo, width, height, newPicNo: integer; BEGIN picNo := PicNumber; SelectPic(picNo); if (nSlices > 1) THEN BEGIN heads := Getnumber('Enter increment to shuffle',2); projections := nSlices/heads; SelectAll; GetPicSize(width,height); killRoi; SetNewSize(width,height); SetOption; MakeNewStack('Shuffled'); newPicNo:=PicNumber; for i := 1 to heads do BEGIN for j := 1 to projections do BEGIN SelectPic(picNo); ChooseSlice((heads-i)*(j-1) + 1); SelectAll; Copy; if nSlices > 1 then DeleteSlice; ChoosePic(newPicNo); addSlice; paste; END; END; ChooseSlice(1); DeleteSlice; SelectPic(picNo); Dispose; SelectSlice(1); killRoi; END; END; macro '[T] Translate MicroDELTA Images'; {Imports a microDELTA image into a stack.} VAR i,type,format,width,height,depth,nImages,hdrsize, maxPixel:integer; patientName,buffer, isTrue: String; BEGIN RequiresVersion(1.50); SetImport('8-bit'); SetCustom(512,1,0); Import(''); {Read in header as an image, prompting for file name.} hdrSize := GetPixel(36,0); hdrSize := hdrSize + (GetPixel(37,0) * 256); hdrSize := (hdrSize - 1) * 512; nImages := GetPixel(38,0); nImages := nImages + (GetPixel(39,0) * 256); depth := GetPixel(502,0); depth := depth + (GetPixel(503,0) * 256); height := GetPixel(504,0); height := height + (GetPixel(505,0) * 256); width := GetPixel(506,0); width := width + (GetPixel(507,0) * 256); maxPixel := GetPixel(510,0); maxPixel := maxPixel + (GetPixel(511,0) * 256); format := GetPixel(232,0); type := GetPixel(238,0) - 48; if (type > 9) then begin type := type - 7; end; patientName := ''; if ((depth = 0) OR (height = 0) OR (width = 0)) THEN BEGIN If type = 1 then Begin width := 32; height := 32; depth := 1; End; If type = 2 then Begin width := 32; height := 32; depth := 2; End; If type = 3 then Begin width := 64; height := 64; depth := 1; End; If type = 4 then Begin width := 64; height := 64; depth := 2; End; If type = 5 then Begin width := 128; height := 128; depth := 1; End; If type = 6 then Begin width := 128; height := 128; depth := 2; End; If type = 7 then Begin width := 256; height := 256; depth := 1; End; If type = 8 then Begin width := 256; height := 256; depth := 2; End; If type = 9 then Begin width := 192; height := 512; depth := 1; End; If type = 10 then Begin width := 192; height := 512; depth := 2; End; If type = 11 then Begin width := 384; height := 1024; depth := 1; End; If type = 12 then Begin width := 384; height := 1024; depth := 2; End; END; For i := 1 to 8 do BEGIN If (GetPixel(175 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(175 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); For i := 1 to 6 do BEGIN If (GetPixel(193 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(193 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); For i := 1 to 10 do BEGIN If (GetPixel(209 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(209 + i,0) ); patientName := concat(patientName,buffer ); END; END; buffer := ' '; patientName := concat(patientName,buffer); For i := 1 to 6 do BEGIN If (GetPixel(221 + i,0) > 32) Then BEGIN buffer := chr( GetPixel(221 + i,0) ); patientName := concat(patientName,buffer ); END; END; Dispose; isTrue := 'undefined'; IF (depth = 2) THEN BEGIN WHILE ((isTrue <> 'N') AND (isTrue <> 'Y')) DO BEGIN isTrue := getString('Image-by-image scaling? (Y or N)','N'); END; END; If depth = 2 THEN BEGIN IF ((maxPixel = 0) OR (isTrue = 'Y')) THEN SetImport('16-bit Unsigned, Swap Bytes'); IF ((maxPixel > 0) AND (isTrue = 'N')) THEN BEGIN SetImportMinMax(0,maxPixel); SetImport('16-bit Unsigned, Swap Bytes, Fixed Scale'); END; END; If depth = 1 THEN BEGIN IF (maxPixel = 0) THEN SetImportMinMax(0,255); IF (maxPixel > 0) THEN SetImportMinMax(0,maxPixel); SetImport('8-bit, Fixed Scale'); END; SetCustom(width, height, HdrSize, nImages); Import(''); if (nImages > 1) then ChooseSlice(1); if (depth = 2) then BEGIN FOR i:= 1 to nSlices DO BEGIN ChooseSlice(i); invert; END; END; Beep; Beep; SetPicName(patientName); Save; END; macro '[V] Flip Vertical'; VAR i, picNo: integer; BEGIN picNo := PicNumber; SelectPic(picNo); SetOption; IF ( nSlices < 2) THEN BEGIN FlipVertical; END; IF ( nSlices > 1) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); FlipVertical; END; selectSlice(1); END; END; macro '[Z] Zoom Images'; VAR i,N,OldStack,NewStack:integer; Width,Height:integer; zoomFactor: real; BEGIN SaveState; OldStack:=PicNumber; ChoosePic(OldStack); GetPicSize(Width,Height); N:=nSlices; zoomFactor := 2; zoomFactor := GetNumber('Enter zoom factor',zoomFactor); SetNewSize(Width*zoomFactor,Height*zoomFactor); SetScaling('Bilinear; Create New Window'); IF (N < 2) THEN BEGIN ScaleAndRotate(zoomFactor,zoomFactor,0); SelectPic(oldStack); dispose; SelectPic(nPics); END; IF (N > 1) THEN BEGIN chooseSlice(1); MakeNewStack('Stack'); NewStack:=PicNumber; FOR i:= 1 to N DO BEGIN choosePic(OldStack); chooseSlice(1); ScaleAndRotate(zoomFactor,zoomFactor,0); SelectAll; Copy; dispose; choosePic(NewStack); Paste; killRoi; choosePic(OldStack); deleteSlice; choosePic(NewStack); IF (i < N) THEN addSlice; IF (i = N) THEN BEGIN choosePic(OldStack); dispose; SelectPic(nPics); chooseSlice(1); END; END; END; RestoreState; END; macro ' '; BEGIN END; macro 'Window for EF Calculation'; VAR i, picNo: integer; BEGIN ResetCounter; picNo := PicNumber; SelectPic(picNo); IF ( nSlices < 2) then BEGIN PutMessage('This macro requires a stack'); Exit; END; SelectSlice(1); MoveWindow(360,250); NewTextWindow('LVEF Results'); SelectWindow('LVEF Results'); Writeln( 'Draw Rectangular ROI on LV...' ); Writeln( 'Then proceed to "Identify ED and ES... "' ); SelectPic(picNo); END; macro 'Identify ED and ES'; VAR i, picNo, frameED, frameES: integer; LVEDV, LVESV: real; BEGIN picNo := PicNumber; Measure; LVEDV := rMean[rCount]*rArea[rCount]; LVESV := rMean[rCount]*rArea[rCount]; frameED := 1; FOR i:= 1 to nSlices do BEGIN ChoosePic(picNo); ChooseSlice(i); Measure; SelectWindow('LVEF Results'); WriteLn( i, ': ', rMean[rCount]*rArea[rCount], ' counts'); if (LVEDV < ( rMean[rCount]*rArea[rCount] ) ) then BEGIN LVEDV := rMean[rCount]*rArea[rCount]; frameED := i; END; if (LVESV > ( rMean[rCount]*rArea[rCount] ) ) then BEGIN LVESV := rMean[rCount]*rArea[rCount]; frameES := i; END; END; SelectWindow('LVEF Results'); Writeln( ' ' ); Writeln( 'End-diastole = Frame ', frameED ); Writeln( 'End-systole = frame ', frameES ); Writeln( ' ' ); Writeln( 'Draw End-diastole ( ED )' ); Writeln( 'Draw End-systole ( ES )' ); Writeln( 'Draw Background ( BKG )' ); Writeln( ' ' ); Writeln( ' ' ); Writeln( 'Then proceed to "Calculate LVEF..."' ); SelectPic(picNo); SelectSlice(frameED); SelectAll; Copy; MoveWindow(100,40); SetNewSize(128,128); MakeNewWindow('ED'); SelectWindow('ED'); Paste; MoveWindow(360,40); ScaleSelection(2.00, 2.00); SelectPic(picNo); SelectSlice(frameES); SelectAll; Copy; MakeNewWindow('ES'); SelectWindow('ES'); Paste; MoveWindow(360,190); ScaleSelection(2.00, 2.00); MakeNewWindow('BKG'); SelectWindow('BKG'); Paste; MoveWindow(360,340); ScaleSelection(2.00, 2.00); SelectWindow('ED'); ResetCounter; END; macro 'Calculate LVEF'; VAR LVEDV, LVESV, BKG, LVEF: real; pixelsED, pixelsES, ED: integer; BEGIN SelectWindow('ED'); Measure; pixelsED := 0.25 * rArea[rCount]; LVEDV := rMean[rCount]; SelectWindow('ES'); Measure; pixelsES := 0.25 * rArea[rCount]; LVESV := rMean[rCount]; SelectWindow('BKG'); Measure; BKG := rMean[rCount]; SelectWindow('LVEF Results'); Writeln( ' ' ); Writeln( 'ED pixels = ', pixelsED); Writeln( 'ED mean Counts = ', LVEDV); Writeln( 'ES pixels = ', pixelsES); Writeln( 'ES mean Counts = ', LVESV); Writeln( 'BKG mean Counts = ', BKG); LVEDV := (LVEDV - BKG) * pixelsED; LVESV := (LVESV - BKG) * pixelsES; LVEF := 100 * (LVEDV - LVESV) / LVEDV; Writeln( ' ' ); Writeln('LVEDV = ', LVEDV ' counts'); Writeln('LVESV = ', LVESV ' counts'); Writeln( ' ' ); Writeln('LVEF = ', LVEF ' %'); SelectWindow('BKG'); SelectWindow('ES'); SelectWindow('ED'); END; macro ' '; BEGIN END; macro 'Transaxial to Coronal...'; VAR stack1,stack2,width,height:integer; RoiLeft,RoiTop,RoiWidth,RoiHeight,max:integer; loc,PixelSpacing:real; InputSpacing,OutputSpacing:real; {mm} scale:real; {pixels/mm} FirstTime:boolean; BEGIN RequiresVersion(1.45); SaveState; IF (nslices < 2) THEN BEGIN PutMessage('This window is not a stack.'); EXIT; END; scale:=1.0; scale := GetNumber('Enter slice thickness (pixels)', scale); SetScale(scale,'pixels'); SetBackground(0); SetBackground(255); stack1:=PicNumber; InputSpacing:=scale; IF InputSpacing<=0 THEN InputSpacing:=1; SetSliceSpacing(scale); OutputSpacing:=1; PixelSpacing:=OutputSpacing*scale; FirstTime:=true; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); IF (RoiWidth = 0) THEN BEGIN selectAll; GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight); END; killRoi; loc:=RoiTop+PixelSpacing; max:=RoiTop+RoiHeight; WHILE loc 1) THEN BEGIN FOR i := 1 TO nSlices DO BEGIN ChooseSlice(i); Invert; END; selectSlice(1); END; END; macro ' '; BEGIN END; macro 'Dispose all...'; VAR i: integer; BEGIN FOR i := 1 to nPics DO BEGIN choosePic(1); dispose; END; END;