// LAG SIM tools // // This is a handy set of tools to help with reconstruction of SIM data. It is // specifically set up to work with the LAG SIM developed by the Laser Analytics // Group at the University of Cambridge. // // For suggestions or bugs please contact Marcus, at mjf74@cam.ac.uk // Marcus Fantham, 2018 // Set up SIM menu var simCmds = newMenu("LAG SIM Menu Tool", newArray("Fast fairSIM", "Fast widefield", "Fast fairSIM with registration", "Fast widefield with registration", "Dialog fairSIM", //"Channel split", " ", "Legacy Functions:", "-----------", "1-channel widefield", "2-channel widefield", "3-channel widefield", "2-channel split", "3-channel split", "Full fairSIM", "Help!")); // Tool menu with symbol macro "LAG SIM Menu Tool - Ce90T0710LC282T4710AC728Tb710GC059T0f10STbf10MC933T8f10I"{ cmd = getArgument(); if (cmd == "Full fairSIM"){ // Run LAG fairSIM plugin run("LAG fairSIM"); } else if (cmd == "Fast fairSIM"){ Dialog.create("Choose slice for calculating parameters"); Dialog.addNumber("Parameter slice (1-indexed, 0 for all)", 0); Dialog.show(); s = Dialog.getNumber(); run("LAG fairSIM-dialog", "lens=[60X Water] sim=true paramslice=" + s + " filter=[Wiener out] wienerparameter=0.05 rlsteps=5 otfattenuation=true attenstrength=0.995 attenfwhm=1.2 apocutoff=1.8 apobend=0.8 clip=[Clip zeros] widefield=false register=false optosplit=false batch=false moreoptions=false"); } else if (cmd == "Fast fairSIM with registration"){ x1 = call("ij.Prefs.get", "lagsim.regx1", "0"); y1 = call("ij.Prefs.get", "lagsim.regy1", "0"); x2 = call("ij.Prefs.get", "lagsim.regx2", "0"); y2 = call("ij.Prefs.get", "lagsim.regy2", "0"); Dialog.create("Choose parameter slice and registration parameters"); Dialog.addNumber("Parameter slice (1-indexed, 0 for all)", 0); Dialog.addNumber("Channel 1 -> Channel 0 x (widefield shift)", x1); Dialog.addNumber("Channel 1 -> Channel 0 y (widefield shift)", y1); Dialog.addNumber("Channel 2 -> Channel 0 x (widefield shift)", x2); Dialog.addNumber("Channel 2 -> Channel 0 y (widefield shift)", y2); Dialog.show(); s = Dialog.getNumber(); x1 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regx1", x1); y1 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regy1", y1); x2 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regx2", x2); y2 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regy2", y2); run("LAG fairSIM-dialog", "channel=" + x1 + " channel_0=" + y1 + " channel_1=" + x2 + " channel_2=" + y2 + " lens=[60X Water] sim=true paramslice=" + s + " filter=[Wiener out] wienerparameter=0.05 rlsteps=5 otfattenuation=true attenstrength=0.995 attenfwhm=1.2 apocutoff=1.8 apobend=0.8 clip=[Clip zeros] widefield=false register=true optosplit=false batch=false moreoptions=false"); } else if (cmd == "Dialog fairSIM"){ run("LAG fairSIM-dialog"); } else if (cmd == "Fast widefield"){ run("LAG fairSIM-dialog", "lens=[60X Water] sim=false paramslice=0 filter=[Wiener out] wienerparameter=0.05 rlsteps=5 otfattenuation=true attenstrength=0.995 attenfwhm=1.2 apocutoff=2.9 apobend=0.8 clip=[Clip zeros] widefield=true register=false optosplit=false batch=false moreoptions=false"); } else if (cmd == "Fast widefield with registration"){ x1 = call("ij.Prefs.get", "lagsim.regx1", "0"); y1 = call("ij.Prefs.get", "lagsim.regy1", "0"); x2 = call("ij.Prefs.get", "lagsim.regx2", "0"); y2 = call("ij.Prefs.get", "lagsim.regy2", "0"); Dialog.create("Set registration parameters"); Dialog.addNumber("Channel 1 -> Channel 0 x (widefield shift)", x1); Dialog.addNumber("Channel 1 -> Channel 0 y (widefield shift)", y1); Dialog.addNumber("Channel 2 -> Channel 0 x (widefield shift)", x2); Dialog.addNumber("Channel 2 -> Channel 0 y (widefield shift)", y2); Dialog.show(); x1 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regx1", x1); y1 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regy1", y1); x2 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regx2", x2); y2 = Dialog.getNumber(); call("ij.Prefs.set", "lagsim.regy2", y2); run("LAG fairSIM-dialog", "channel=" + x1 + " channel_0=" + y1 + " channel_1=" + x2 + " channel_2=" + y2 + " lens=[60X Water] sim=false paramslice=0 filter=[Wiener out] wienerparameter=0.05 rlsteps=5 otfattenuation=true attenstrength=0.995 attenfwhm=1.2 apocutoff=2.9 apobend=0.8 clip=[Clip zeros] widefield=true register=true optosplit=false batch=false moreoptions=false"); } else if (cmd == "Channel split"){ run("channel-split"); } else if (cmd == "Help!"){ // Show help dialog box dlgStr = "LAG SIM Help\n" + "-------------------\n \n" + "#-channel widefield: produces a widefield preview of the active SIM image. \n" + "#-channel split: splits the active SIM image into separate colour channels, \nready for " + "reconsturction with fairSIM. \n" + "LAG fairSIM: runs fairSIM automatically setting the correct beam/phase/angle \n" + "parameters for the LAG SIM. Note that you should run #-channel split first, since \n" + "fairSIM does not support multiple colour channels. \n \n" + "Marcus Fantham, 2018"; Dialog.create("LAG SIM Help"); Dialog.addMessage(dlgStr); Dialog.show(); } else if (!isNaN(parseInt(substring(cmd,0,1)))) { // Calculate number of channels and slices in image var channels = parseInt(substring(cmd,0,1)); slices = nSlices / 9.0 / channels; run("Stack to Hyperstack...", "order=xytcz channels="+ channels +" slices=" + slices + " frames=9 display=Color"); run("Re-order Hyperstack ...", "channels=[Channels (c)] slices=[Frames (t)] frames=[Slices (z)]"); if (substring(cmd, 10, 15) == "widef"){ // Use z-projection to create widefield preview run("Z Project...", "projection=[Average Intensity] all"); if (channels != 1){ run("Make Composite"); } } if (substring(cmd, 10, 15) == "split"){ // Use split-channels for use with fairSIM run("Split Channels"); } } }