{ BIO-RAD CONVERSION MACROS written by Charles Thomas, Pete DeVries and Pete Smith for the Integrated Microscopy Resource, University of Wisconsin-Madison, 1675 Observatory Drive, Madison, WI 53706. Please send reports of any bugs to Charlest@macc.wisc.edu. } var NumStr: string; procedure NumToString (number); {Converts a number to a string with that number as a character. If the number is less than 10 a '00' is added to it first} var OriginalNumber: integer; begin OriginalNumber := number; NumStr:=''; {Initialize the string which will hold the characters} if number<10 then begin NumStr:= concat('0','0', chr(number+48):1) end else if (number >=10) then begin while number>=10 do begin NumStr:= concat(chr((number mod 10)+48),NumStr); number:=number div 10; end; NumStr:= concat (chr((number+48)), NumStr); if (OriginalNumber >=10) and (OriginalNumber < 100) then NumStr := concat('0', NumStr); end; end; {NumToString} macro 'Convert BioRad PIC File to NIH Image Files'; { Written by Pete Smith, Pete DeVries, Charles Thomas 1-4-94 Converts a BioRad z-series to NIH-Tiff files with names 01, 02, ... 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize: integer; begin SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file.} width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PutMessage('The X,Y dimensions of these images are: ',width:1,' x ',height:1); PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } PutMessage('The number of slices is: ',nPic:1); Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); SetPicName(pic:2); { Renames each picture 01, 02, ... } SaveAs; { Creates file using Tiff. } Dispose; { Closes window. } end; {for pic} end; {Convert Biorad PIC File to NIH Image Files} ----------------------------------------------------------------------------- macro 'Convert BioRad PIC File to NIH Image Files & Invert'; { Written by Pete Smith, Pete DeVries, Charles Thomas 1-4-94 Converts a BioRad z-series to NIH-Tiff files with names Filename01, Filename02, ... 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize: integer; filename: string; UseLongName: boolean; begin UseLongName := (GetString('Use filenames instead of numbers?', 'Y') = 'Y'); if (UseLongName) then filename := GetString('Enter base file name: ', 'Picture'); SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file.} width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PutMessage('The X,Y dimensions of these images are: ',width:1,' x ',height:1); PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } PutMessage('The number of slices is: ',nPic:1); Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); if (UseLongName) then begin NumToString(pic); SetPicName(concat(Filename,'.', NumStr)); end else SetPicName(pic:2); Invert; SaveAs; { Creates file using Tiff. } Dispose; { Closes window. } end; {for pic} end; {Convert Biorad PIC File to NIH Image Files & Invert} {----------------------------------------------------------------------} macro 'Convert BioRad Z-Series File to VoxelView Slices'; { Written by Pete Smith, Pete DeVries, Charles Thomas 3-1-93 Converts a set of BioRad data files(all in the same folder) with names to raw binary (1, 2, ...). 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize: integer; begin SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file. } width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PutMessage('The X,Y dimensions of these images are: ',width:1,' x ',height:1); PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } PutMessage('The number of slices is: ',nPic:1); Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); SetPicName(pic:1); { Renames each picture1, 2, ... } Export; { Creates file using binary (raw data). } Dispose; { Closes window. } end; {for pic} end; {Convert Biorad PIC File to VoxelView Slices} {---------------------------------------------------------------------------} macro 'Convert BioRad Z-Series File to Stack'; { Written by Charles Thomas, Pete Devries and Pete Smith 4-22-94 Converts a BioRad data file with multiple images into a stack that can be read by VoxelView } Var pic, NumSlices, width, height, offset, PicSize, numberbin, NewStack: integer; begin numberbin:=0; SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file. } width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PicSize:=width*height; NumSlices := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } Dispose; { Closes window without save. } if NumSlices<=1 then begin PutMessage('This macro requires a file containing at least two images.'); exit; end; {if odd(Width) then Width:=Width-1;} SaveState; SetNewSize(Width,Height); MakeNewStack(''); NewStack:=PidNumber; for pic:= 1 to NumSlices do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); MakeRoi(0,0,Width,Height); copy; dispose; ChoosePic(NewStack); paste; if pic < NumSlices then Addslice; end; {for pic} SaveAs; KillROI; end; {'Convert BioRad PIC Files to Stack'} {---------------------------------------------------------------------------} macro 'Convert BioRad Files to TIF'; { Written by Charles Thomas, Pete Smith and Pete DeVries 4-22-94 Converts a BioRad z-series toTiff files with names 01, 02, ... 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize: integer; begin SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file.} width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); SetPicName(pic:2); { Renames each picture 01, 02, ... } SaveAs; { Creates file using Tiff. } Dispose; { Closes window. } end; {for pic} end; {Convert Biorad Pic Files to TIF} {---------------------------------------------------------------------------} macro 'Convert BioRad PIC Files to binary'; { Written by Pete Smith and Pete DeVries 7-1-92 Converts a set of BioRad data files to raw binary files numbered 01, 02, etc. 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize: integer; begin SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file. } width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+76; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); SetPicName(pic:2); { Renames each picture 01, 02, ... } Export; { Creates file using binary (raw data). } Dispose; { Closes window. } end; {for pic} end; {Convert Biorad PIC Files to binary} {---------------------------------------------------------------------------} macro 'Comos Files to VoxelView Slices'; { Written by Pete Smith, Pete DeVries, Charles Thomas 2-4-93 Modified several times in January and February, 1993 Converts a set of BioRad data files(all in the same folder) with names to binary (1, 2, ...). 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 Export). } Var file, pic, nFiles, nPic, width, height, offset, PicSize, numberbin: integer; begin numberbin:=0; SetImport('8-bits'); { Sets import default } SetCustom(6,6,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file. } width := (GetPixel(1,0)*256) + GetPixel(0,0); { 1 & 0, 3 &2, and 5 & 4 are three} height := (GetPixel(3,0)*256) + GetPixel(2,0); { 16-bit numbers expressing the } PicSize:=width*height; nPic := (GetPixel(5,0)*256) + GetPixel(4,0); { width, height, and number. } Dispose; { Closes window without save. } for pic:= 1 to nPic do { Does each picture, one by one } begin offset:=(pic-1)*PicSize+172; { Offset increments by the size of the picture } SetCustom(width,height,offset); Import(''); numberbin:= numberbin+1; { Will be a 'numberbin' for each file made. } SetPicName(numberbin:1); { Renames each picture1, 2, ... } Export; { Creates file using binary (raw data). } Dispose; { Closes window. } end; {for pic} end; {Comos Files to VoxelView Slices} {---------------------------------------------------------------------------} macro 'Read First Numbers in COMOS file'; { Written by Pete DeVries 2-11-93 Reads the first 7 words in a BioRad file. This Macro is useful in determining file info and format. } Var file, pic, nFiles, nPic, offset, PicSize: integer; Wrd1, Wrd2, Wrd3, Wrd4, Wrd5, Wrd6, Wrd7 : integer; begin SetImport('8-bits'); { Sets import default } SetCustom(76,1,0); { Imports first 6 bytes, which contain the width, height, } Import(''); { and number of pictures in the file.} Wrd1 := (GetPixel(1,0)*256) + GetPixel(0,0); Wrd2 := (GetPixel(3,0)*256) + GetPixel(2,0); Wrd3 := (GetPixel(5,0)*256) + GetPixel(4,0); Wrd4 := (GetPixel(7,0)*256) + GetPixel(6,0); Wrd5 := (GetPixel(9,0)*256) + GetPixel(8,0); Wrd6 := (GetPixel(11,0)*256) + GetPixel(10,0); Wrd7 := (GetPixel(13,0)*256) + GetPixel(12,0); PutMessage('The value of Word1 is ',Wrd1:3:0); PutMessage('The value of Word2 is ',Wrd2:3:0); PutMessage('The value of Word3 is ',Wrd3:3:0); PutMessage('The value of Word4 is ',Wrd4:3:0); PutMessage('The value of Word5 is ',Wrd5:3:0); PutMessage('The value of Word6 is ',Wrd6:3:0); PutMessage('The value of Word7 is ',Wrd7:3:0); Dispose; { Closes window without save. } end; {Read COMOS File Format} -----------------------------------------------------------------------------