macro 'Save using Time as NameÉ'; {Note: Colons are not allowed in file names.} var year,month,day,hour,minute,second,DayOfWeek:integer; begin GetTime(year,month,day,hour,minute,second,DayOfWeek); SaveAs(year-1900:2,'-',month:2,'-',day:2, '/',hour:2,'-'minute:2,'-',second:2); end; macro 'Open with selectionÉ [O]'; begin if nPics>0 then KillRoi; {Save Selection} Open(''); {Prompt for file name} RestoreROI; {Transfer selection to new window} end; macro 'Save AllÉ'; { Saves all currently open images in a folder using '001', '002', etc. as the file names. The save file dialog box will be displayed once (and only once) so that you can specify the folder to save the files in. Leave the file name blank(e.g. SaveAs('')) to get a dialog box for each file. } var n:integer; begin RequiresVersion(1.45); for n:=1 to nPics do begin SelectPic(n); SaveAs(n:3); {Export(n:3);} end; end; macro 'Import FITSÉ'; { This is an example of how to decode an image file header. In this case, the header is 2880 bytes long and bytes 266-269 contain the width(ASCII) and bytes 246-249 cantain the height. Refer to "FITS:A Flexible Image Transport System", Astronomy and Astrophysics Supplement Series 44, 1981, 363-370. } var width,height,offset,i,d,m:integer; begin width:=512; height:=1; offset:=0; SetImport('8-bit'); SetCustom(width,height,offset); Import(''); {Read in header as an image, prompting for the file name.} if not ((GetPixel(108,0)=49) and (GetPixel(109,0)=54)) then begin {BITPIX<>16} PutMessage('This macro only reads 16-bit FITS files'); SelectPic(nPics); Dispose; exit; end; m:=1000; width:=0; for i:=266 to 269 do begin d:=GetPixel(i,0); if d=32 then d:=48; d:=d-48; width:=width+d*m; m:=m/10; end; m:=1000; height:=0; for i:=346 to 349 do begin d:=GetPixel(i,0); if d=32 then d:=48; d:=d-48; height:=height+d*m; m:=m/10; end; SelectPic(nPics); {The ID of the last window opened is equal to nPics.} Dispose; offset:=2880; SetImport('16-bit Signed; Calibrate; Autoscale'); SetCustom(width,height,offset); Import(''); {No prompt this time; Import remembers the name.} FlipVertical; end; macro 'Import Image TIFF FileÉ'; { As an example of how to import a foreign file format, this macro reads the TIFF files created by Image. The format of an Image TIFF file is described in Appendix E of the Image manual. } var width,height,offset:integer; begin width:=768; height:=1; offset:=0; SetImport('8-bit'); SetCustom(width,height,offset); Import(''); {Read in header as an image, prompting for the file name.} if not ((GetPixel(0,0)=77) and (GetPixel(0,0)=77)) then begin {'MM'} PutMessage('This is not a TIFF file.'); SelectPic(nPics); Dispose; exit; end; width := (GetPixel(30,0)*256) + GetPixel(31,0); height := (GetPixel(42,0)*256) + GetPixel(43,0); SelectPic(nPics); {The ID of the last window opened is equal to nPics.} Dispose; offset:=768; SetCustom(width,height,offset); Import(''); {No prompt this time; Import remembers the name.} end; macro 'Import Multiple Images per FileÉ'; { Imports a series of 256x256 images contained in a single file, in this case an NIH Image stack with an arbitrary number of 256x256 slices. } var offset,i,PicSize,HdrSize,width,height:integer; begin HdrSize:= 768; width:= 256; height:=256; PicSize:=width*height; offset:=HdrSize; SetImport('8-bit'); for I:=1 to 100 do begin {Macro will terminate at eof} SetCustom(width,height,offset); Import(''); offset:=offset+PicSize; end; end; macro 'Import PETÉ'; var offset,i,PicSize,HdrSize,width,height:integer; begin HdrSize:= 0; width:= 128; height:=128; PicSize:=width*height; offset:=HdrSize; SetImport('8-bit'); for I:=1 to 100 do begin {Macro will terminate at eof} SetCustom(width,height,offset); Import(''); offset:=offset+PicSize; end; end; macro 'Convert FilesÉ'; { Converts a set of raw data files(all in the same folder) with names in the form raw.001, raw.002, etc to TIFF or PICT. As long as the converted files are saved in the same folder, you should only see two file dialog boxes(one for the first Import and one for the first SaveAs). } Var i,nFiles:integer; begin nFiles:=GetNumber('Number of files:',5); for i:=1 to nFiles do begin Import('raw.',i:3); SetPicName('file',i:3); SaveAs; Dispose; end; end; macro 'Import IPLab File'; var width,height,offset:integer; begin width:=100; height:=1; offset:=0; SetImport('8-bit'); SetCustom(width,height,offset); Import(''); {Read in header as an image, prompting for file name.} width := (GetPixel(8,0)*256) + GetPixel(9,0); height := (GetPixel(12,0)*256) + GetPixel(13,0); Dispose; offset:=2120; {The IPLab offset} SetImport('16-bit Signed; Calibrate; Autoscale'); SetCustom(width,height,offset); Import(''); {No prompt this time; Import remembers the name.} end; procedure ShowBioRadInfo; {Displays the contents of the 480(?) byte header at} {the end of Biorad MRC 600 Z Series files.} var MaxInfoSize,offset:integer; ch:string; begin MaxInfoSize:=480; SetCustom(MaxInfoSize,1,HdrSize+Width*Height); SetImport('8-bit'); {Don't invert} Import(''); GetRow(0,0,MaxInfoSize); Dispose; SetNewSize(460,100); SetForeground(255); SetBackground(0); MakeNewWindow('Info'); SetCursor('Watch'); SetFont('Monaco'); SetText('With background; Left Justified'); SetFontSize(12); MoveTo(8,10); for i:=0 to MaxInfoSize-1 do begin offset:=i mod 96; if offset=0 then writeln; ch:=chr(LineBuffer[i]); if (offset=2) and (ord(ch)=0) then exit; if (offset>=16) and (offset<=95) and (ord(ch)>=32) and (ord(ch)<=126) then write(ch); end; end; macro 'Import Biorad MRC 600 Z SeriesÉ'; { Imports a Z series(multiple images per file) from a Biorad MRC 600 confocal microscope. The width, height and number of images are extracted from the first 3 16-bit word in the 76 byte header and the file name is extracted from bytes 18-23 of the header. Note that the Undo and Clipboard buffers must be set to 384K to work with the typical 768x512 Biorad images. } var width,height,nImages,offset,hdrsize,i,start,picsize:integer; begin RequiresVersion(1.50); width:=512; height:=1; offset:=0; SetImport('8-bit'); SetCustom(width,height,offset); Import(''); {Read header} width:=GetPixel(0,0)+GetPixel(1,0)*256; height:=GetPixel(2,0)+GetPixel(3,0)*256; nImages:=GetPixel(4,0)+GetPixel(5,0)*256; Dispose; hdrsize:= 76; picsize:=width*height; if (width<128) or (width>2048) or (height<128) or (height>2048) or (nImages<1) or (nImages>256) then begin PutMessage('This does not seem to be a Biorad MRC 600 Z Series file.'); exit; end; start:=GetNumber('Starting image:',1); offset:=HdrSize+(start-1)*PicSize; SetImport('8-bit; Invert'); SetCustom(width,height,offset,nimages); Import(''); for i:=1 to nSlices do begin SelectSlice(i); Invert; ChangeValues(0,0,1); ChangeValues(255,255,254); end; ShowBioRadInfo; end; macro 'Import from IBAS'; var width,height,offset:integer; begin width:=128; height:=1; offset:=0; SetImport('8-bit'); SetCustom(width,height,offset); Import(''); {Read in header as an image, prompting for file name.} width := (GetPixel(7,0)*256) + GetPixel(6,0); height := (GetPixel(9,0)*256) + GetPixel(8,0); Dispose(nPics); {The ID of the last window opened = nPics.} offset:=128; {The IBAS offset} SetImport('8-bit; Calibrate; Autoscale'); SetCustom(width,height,offset); Import(''); {No prompt this time; Import remembers the name.} Invert SetScaling ('Bilinear'); SetScaling ('New Window'); ScaleAndRotate (0.80, 1.0, 0); end; macro 'Import 64x64x64x16-bit SPECT ImageÉ'; {Imports a 64x64x64x16-bit headerless SPECT image into a stack.} var width,height,nImages,hdrsize:integer; begin RequiresVersion(1.50); width:=64; height:=64; nImages:=64; HdrSize:= 0; SetImport('16-bit Unsigned, Swap Bytes'); {SetImportMinMax(0,2500);} {Uncomment to fix scale} SetCustom(width,height,HdrSize,nImages); Import(''); end; macro 'Import 8-bit 3D ImageÉ'; var width,height,offset,nImages:integer; begin RequiresVersion(1.50); width:=GetNumber('Width:',256); height:=GetNumber('Height:',256); nImages:=GetNumber('Depth(number of slices):',128); offset:=GetNumber('Offset(header size):',0); SetImport('8-bit'); SetCustom(width,height,offset,nImages); Import(''); end; macro 'Open with scale set to 100 pixels/mm [S]'; {Example of a way to open images and have the} {spatial scale always set the same way.} begin Open(''); {or Import('')} SetScale(100,'mm'); {Change as needed} end; macro 'Load Synergy Image'; begin SetImport('8-bit'); SetCustom(512,480,16384); Import(''); ChangeValues(0,0,1); ChangeValues(255,255,254); SetPalette('Rainbow'); end; macro 'Import Siemens 3D MRIÉ'; begin RequiresVersion(1.50); SetImport('16-bit Signed, Swap Bytes'); {SetImportMinMax(0,3000);} {Remove comments to fix scale} SetCustom(256,256,0,127); Import(''); end;