macro 'Import FluoviewTIFF [F12]'; {This macro can be used to open Olympus FluoviewTiff 12-bit stacks and to convert them into 8-bit tiff stacks that can be manipulated by NIH Image software. May be distributed freely, but without modification. created on 2/28/01 updated 1/9/03 Edward S. Ruthazer, PhD (email: ruthazer@cshl.org) Cold Spring Harbor Laboratory} var width,height,offset1,offset2,kount,i,ch1stack,ch2stack,xval,yval,zval,chval, uplim,lolim:integer; begin lolim:=GetNumber('lower limit: ',0,0); uplim:=GetNumber('upper limit: (enter 0 for auto-scaling)', 255,0); {open in image format a subset of the file containing the TIFF tags with useful info} width:=512; height:=1; offset2:=10; SetImport('8-bit'); SetCustom(width,height,offset2); Import(''); {search for FLUOVIEW private tag containing pointer to useful info} i:=-1; repeat; i:=i+1; until ((getpixel(i+1,0) = 134) and (getpixel(i+2,0)=1)); offset1:=getpixel(i+8,0)+getpixel(i+9,0)*256+284; dispose; {open new subset of file containing useful info and extract and display: X width, Y height, Z depth, and # of channels.} SetCustom(width,height,offset1); import(''); xval:=getpixel(16,0)+getpixel(17,0)*256; yval:=getpixel(116,0)+getpixel(117,0)*256; zval:=getpixel(216,0)+getpixel(217,0)*256; chval:=getpixel(316,0)+getpixel(317,0)*256; showmessage(concat(chr(getpixel(0,0)),':',xval),' , ',chr(getpixel(100,0)),': ',yval,' , ',& chr(getpixel(200,0)),': ',zval,chr(13),'Channels: ', chval); dispose; {create new 8-bit version of stacks} width:=xval; height:=yval; SetNewSize(width,height); MakeNewStack('Ch1'); ch1stack:=pidNumber; if chval = 2 then begin; MakeNewStack('Ch2'); ch2stack:=pidNumber; end;{if} {settings for first header info -- will be reduced later to save processing time} offset2:=10; width:=16000; for kount:=1 to zval*chval do begin; {open subset of file containing pointer to image #kount} SetCustom(width,1,offset2); setimport('8-bits'); width:=xval; Import(''); {look for tag that points to image data} i:=-1; repeat; i:=i+1; until ((getpixel(i,0) = 17) and (getpixel(i+1,0)=1)); {get offset value to pointer to image data for slice # kount} offset2:=(getpixel(i+8,0)+& 256*(getpixel(i+9,0)+& 256*(getpixel(i+10,0)+& 256*getpixel(i+11,0))))-offset2; {get offset value to actual image data for slice # kount} offset1:=getpixel(offset2+0,0)+& 256*(getpixel(offset2+1,0)+& 256*(getpixel(offset2+2,0)+& 256*getpixel(offset2+3,0))); dispose; {open image data in new window and copy into new stack} SetCustom(width,height,offset1); SetImport('16-bits Unsigned Swap Bytes'); if uplim>0 then setimportMinMax(lolim,uplim); import(''); SelectAll; Copy; Dispose; if kount>zval then ChoosePic(ch2stack) else ChoosePic(ch1stack); Paste; AddSlice; {move pointer to next slice's tags} offset2:=offset1+xval*2*yval+2; if kount =1 then offset2:=offset2+1;{hack to handle first image tag offset} end {for kount}; {clean up stacks} ChoosePic(ch1stack); DeleteSlice; if ch2stack <>0 then begin ChoosePic(ch2stack); DeleteSlice; end;{if} end;