{ Date: Tue, 26 Apr 94 08:21:34 CDT From: "John Mansfield" North Campus Electron Microbeam Analysis Lab University of Michigan Ann Arbor MI 48109-2143 Phone: (313)936-3352 FAX (313)936-3352 Subject: Digital Instrument AFM Images I dont know if this is any use to anyone! But here is a short macro that will read Digital Instrument Nanoscope III AFM images into NIH-Image. It is not very elegant but seems to do the trick. It should read any size image but true to form I have only used it for 512 squared images. Feel free to fix it if it breaks! } Macro 'Read AFM File'; {reads header in and searches for the number of Samps/line, uses this value} {as the width and heigth for the image import (therefore supports 128,256 and} {512 squared images} var size, width, height, offset, slices, first, second, third, fourth: integer; icount: integer; temp, one, two, three, four: string; done: boolean; begin; done:= 'false'; width:=8192; height:=1; Offset:=0; slices:=1; SetImport('8-bit'); SetCustom(width, height, offset,slices); Import(''); icount:=1; repeat temp:=chr(getpixel(icount, 0)); if ((temp='S') and (one<>'S')) then one:=temp; if ( (temp='a') and (one='S') and (two<>'a')) then two:=temp; if( (temp='m') and (one='S') and (two='a')) then three:=temp; if( (temp='p') and (one='S') and (two='a') and (three='m')) then four:=temp; if (four='p') then done:='true'; icount:=icount+1; until done='true'; first:=(getpixel((icount+8), 0))-48; second:=(getpixel((icount+9), 0))-48; third:=(getpixel((icount+10), 0))-48; fourth:=(getpixel((icount+11), 0))-48; if (first<>1) then size:=(first*100)+(second*10)+third; if (first=1) then size:=(first*1000)+(second*100)+(third*100)+fourth; Dispose; width:=size; height:=size; offset:=8192; SetImport('16-bit signed,swap bytes'); SetCustom(width, height, Offset); Import(''); end; { Date: Tue, 26 Apr 94 17:35:32 CDT From: as_lea@gate.pnl.gov Subject: Modified DI AFM Image Macro I would like to take the opportunity to thank John Mansfield to get me over the activation energy barrier for writing an NIH macro to extract data (such as scan size, time, and height calibrations) from the Digital Instruments AFM files. I have tried his macro and found that it works as long as you don't collect data in April or September. As written, his macro searches for the first occurrence of the letters S, a, m, and p - but not necessarily in series. When data has been collected in SeP and APr, the macro never get past the second line. I have modified his macro, so that it should work for all months.... ++++++++++++++++++++++++++++++++++++ Scott Lea Molecular Science Research Center Battelle Pacific Northwest Laboratory e-mail: as_lea@pnl.gov ++++++++++++++++++++++++++++++++++++ } Macro 'Read AFM File-2'; {reads header in and searches for the number of Samps/line, uses this value} {as the width and heigth for the image import (therefore supports 128,256 and} {512 squared images} var size, width, height, offset, slices, first, second, third, fourth: integer; icount: integer; temp, one, two, three, four: string; done: boolean; begin; done:= 'false'; width:=8192; height:=1; Offset:=0; slices:=1; SetImport('8-bit'); SetCustom(width, height, offset,slices); Import(''); icount:=1; repeat temp:=chr(getpixel(icount, 0)); if ((chr(getpixel(icount, 0))='S') and (chr(getpixel(icount+1, 0))='a') and (chr(getpixel(icount+2, 0))='m') and (chr(getpixel(icount+3, 0))='p')) then begin first:=(getpixel((icount+12), 0))-48; second:=(getpixel((icount+13), 0))-48; third:=(getpixel((icount+14), 0))-48; done:='true'; end; icount:=icount+1; until done='true'; size:=(first*100)+(second*10)+third; Dispose; width:=size; height:=size; offset:=8192; SetImport('16-bit signed,swap bytes'); SetCustom(width, height, Offset); Import(''); FlipVertical; end;