{Darin Nelson, Duke University Dept. of Neurobiology (dnelson@neuro.duke.edu)} {July, 1994} {these macros were written for use in taking images of neurons in sections which are too thick for single-shot acquisition. The trick is well known: take images at several different focal planes, then combine them so that only the lightest (or darkest) value at each pixel location is retained. There is a macro for both of these possibilities; also three macros that split the aquisition and combining process in case there is a need to tweak the files before combining them.} Procedure AQUIRESERIES; { Captures a specified number of images and puts 'em in a stack. Select an area of interest within the Camera window before starting. Can be aborted with cmd-period. } var n,Left,Top,Width,Height, stackPicNum :integer; dummy : boolean; begin RequiresVersion(1.49); Capture; SelectWindow('Camera'); GetPicSize(Width,Height); SetNewSize(Width,Height); MakeNewStack('Stack'); stackPicNum:= PicNumber; for n:=1 to nFrames do begin beep; WaitForTrigger; dummy := Button; beep; Capture; SelectWindow('Camera'); SelectAll; Copy; ChoosePic(stackPicNum); ChooseSlice(n); Paste; if n < nFrames then AddSlice; SelectWindow('Camera'); end; Dispose; end; Procedure OVERLAYSERIES; Var i,j, width, height: integer; n: integer; sPN, tPN, cPN: integer; Begin scaleMath(0); SelectWindow('Stack'); sPN := PicNumber; n:= nslices; selectslice(1); selectall; copy; GetPicSize(width,height); SetNewSize(width,height); MakeNewWindow('Temp'); tPN := PicNumber; MakeNewWindow('Combination'); cPN := PicNumber; paste; for i:=2 to n do begin ChoosePic(sPN); ChooseSlice(i); selectall; copy; ChoosePic(tPN); paste; ChoosePic(cPN); selectall; copy; ChoosePic(tPN); paste; subtract; SetThreshold(1); ApplyLUT; ChoosePic(sPN); Chooseslice(i); selectall; copy; ChoosePic(tPN); paste; doAnd; selectall; copy; ChoosePic(cPN); paste; doReplace; end; SelectWindow('Combination'); SubtractBackground('2D Rolling Ball(faster)',50); EnhanceContrast; ApplyLUT; Sharpen; SelectWindow('Temp'); dispose; SelectWindow('Stack'); Dispose; end; Procedure LTOVERLAYSERIES; Var i,j, width, height: integer; n: integer; sPN, tPN, cPN: integer; Begin scaleMath(0); SelectWindow('Stack'); sPN := PicNumber; n:= nslices; selectslice(1); selectall; InvertLUT; ApplyLUT; copy; GetPicSize(width,height); SetNewSize(width,height); MakeNewWindow('Temp'); tPN := PicNumber; MakeNewWindow('Combination'); cPN := PicNumber; paste; for i:=2 to n do begin ChoosePic(sPN); ChooseSlice(i); selectall; InvertLUT; ApplyLUT; copy; ChoosePic(tPN); paste; ChoosePic(cPN); selectall; copy; ChoosePic(tPN); paste; subtract; SetThreshold(1); ApplyLUT; ChoosePic(sPN); Chooseslice(i); selectall; copy; ChoosePic(tPN); paste; doAnd; selectall; copy; ChoosePic(cPN); paste; doReplace; end; SelectWindow('Combination'); SubtractBackground('2D Rolling Ball(faster)',50); EnhanceContrast; ApplyLUT; Sharpen; SelectWindow('Temp'); dispose; SelectWindow('Stack'); Dispose; end; Macro 'Dark Neuron Mass Aquire & Combine [F5]' {this lets you acquire a bunch of images in a row. Requires user input of a base file name (from which sequentially numbered file names will be generated), a base number to start the file names from, and the number of focal planes to be aquired per cell. The macro has been written to organize various fields of view of the same cell in similarly named files which can be montaged together later on. } Var baseName,periodStr: string; nFrames, cellNum, viewNum : integer; weKeepAddingCells, weKeepAddingViews : boolean; Begin baseName := GetString('Enter the base file name:','Control2-3.01.2'); periodStr := '.'; baseName := concat (baseName,periodStr); cellNum := GetNumber ('Starting Cell Number:',1) - 1; nFrames:=GetNumber('Number of Focal Planes/Image:',4); { Now we enter a series of nested loops. The counter for the outer loop gives us the cell number. The counter for the middle loop gives us the field of view number for this particular cell. Finally, the innermost loop counts the number of frames which have been taken. This loop is inside of OVERLAYSERIES, and so doesn't show up in the source code outlined below. } weKeepAddingCells := TRUE; While weKeepAddingCells do begin cellNum := cellNum + 1; viewNum := 0; weKeepAddingViews := TRUE; While weKeepAddingViews do begin viewNum := viewNum + 1; AQUIRESERIES; OVERLAYSERIES; SelectWindow('Combination'); SetPicName(baseName,cellNum:3,periodStr,viewNum:1); Save; weKeepAddingViews:= GetNumber ('1: Another view; 0: Next cell',1); if weKeepAddingViews <> FALSE then weKeepAddingViews := TRUE; Dispose; end; weKeepAddingCells := GetNumber ('1: Another cell; 0: Stop',1); if weKeepAddingCells <> FALSE then weKeepAddingCells := TRUE; end; END; Macro 'Bright Neuron Mass Aquire & Combine [F6]' Var baseName,periodStr: string; nFrames, cellNum, viewNum : integer; weKeepAddingCells, weKeepAddingViews : boolean; Begin baseName := GetString('Enter the base file name:','Control2-3.01.2'); periodStr := '.'; baseName := concat (baseName,periodStr); cellNum := GetNumber ('Starting Cell Number:',1) - 1; nFrames:=GetNumber('Number of Focal Planes/Image:',4); weKeepAddingCells := TRUE; While weKeepAddingCells do begin cellNum := cellNum + 1; viewNum := 0; weKeepAddingViews := TRUE; While weKeepAddingViews do begin viewNum := viewNum + 1; AQUIRESERIES; LTOVERLAYSERIES; SelectWindow('Combination'); SetPicName(baseName,cellNum:3,periodStr,viewNum:1); Save; weKeepAddingViews:= GetNumber ('1: Another view; 0: Next cell',1); if weKeepAddingViews <> FALSE then weKeepAddingViews := TRUE; Dispose; end; weKeepAddingCells := GetNumber ('1: Another cell; 0: Stop',1); if weKeepAddingCells <> FALSE then weKeepAddingCells := TRUE; end; END; begin end; Macro 'Acquire image series [F7]' { Captures a specified number of images and puts 'em in a stack. Select an area of interest within the Camera window before starting. Can be aborted with cmd-period. } var nFrames : integer begin nFrames:=GetNumber('Number of Frames?',4); AQUIRESERIES; end; Macro 'Paste darkest only [F8]' Begin OVERLAYSERIES; end; Macro 'Paste lightest only [F9]' Begin LTOVERLAYSERIES; end;