// "StartupMacros" // The macros and macro tools in this file ("StartupMacros.txt") are // automatically installed in the Plugins>Macros submenu and // in the tool bar when ImageJ starts up. // About the drawing tools. // // This is a set of drawing tools similar to the pencil, paintbrush, // eraser and flood fill (paint bucket) tools in NIH Image. The // pencil and paintbrush draw in the current foreground color // and the eraser draws in the current background color. The // flood fill tool fills the selected area using the foreground color. // Hold down the alt key to have the pencil and paintbrush draw // using the background color or to have the flood fill tool fill // using the background color. Set the foreground and background // colors by double-clicking on the flood fill tool or on the eye // dropper tool. Double-click on the pencil, paintbrush or eraser // tool to set the drawing width for that tool. // // Icons contributed by Tony Collins. // Global variables var pencilWidth=1, eraserWidth=10, leftClick=16, alt=8; var brushWidth = 10; //call("ij.Prefs.get", "startup.brush", "10"); var floodType = "8-connected"; //call("ij.Prefs.get", "startup.flood", "8-connected"); // The macro named "AutoRunAndHide" runs when ImageJ starts // and the file containing it is not displayed when ImageJ opens it. // macro "AutoRunAndHide" {} function UseHEFT { requires("1.38f"); state = call("ij.io.Opener.getOpenUsingPlugins"); if (state=="false") { setOption("OpenUsingPlugins", true); showStatus("TRUE (images opened by HandleExtraFileTypes)"); } else { setOption("OpenUsingPlugins", false); showStatus("FALSE (images opened by ImageJ)"); } } UseHEFT(); // The macro named "AutoRun" runs when ImageJ starts. macro "AutoRun" { // run all the .ijm scripts provided in macros/AutoRun/ autoRunDirectory = getDirectory("imagej") + "/macros/AutoRun/"; if (File.isDirectory(autoRunDirectory)) { list = getFileList(autoRunDirectory); // make sure startup order is consistent Array.sort(list); for (i = 0; i < list.length; i++) { if (endsWith(list[i], ".ijm")) { runMacro(autoRunDirectory + list[i]); } } } } var pmCmds = newMenu("Popup Menu", newArray("Help...", "Rename...", "Duplicate...", "Original Scale", "Paste Control...", "-", "Record...", "Capture Screen ", "Monitor Memory...", "Find Commands...", "Control Panel...", "Startup Macros...", "Search...")); macro "Popup Menu" { cmd = getArgument(); if (cmd=="Help...") showMessage("About Popup Menu", "To customize this menu, edit the line that starts with\n\"var pmCmds\" in ImageJ/macros/StartupMacros.txt."); else run(cmd); } macro "Abort Macro or Plugin (or press Esc key) Action Tool - CbooP51b1f5fbbf5f1b15510T5c10X" { setKeyDown("Esc"); } var xx = requires138b(); // check version at install function requires138b() {requires("1.38b"); return 0; } var dCmds = newMenu("Developer Menu Tool", newArray("ImageJ Website","News", "Documentation", "ImageJ Wiki", "Resources", "Macro Language", "Macros", "Macro Functions", "Startup Macros...", "Plugins", "Source Code", "Mailing List Archives", "-", "Record...", "Capture Screen ", "Monitor Memory...", "List Commands...", "Control Panel...", "Search...", "Debug Mode")); macro "Developer Menu Tool - C037T0b11DT7b09eTcb09v" { cmd = getArgument(); if (cmd=="ImageJ Website") run("URL...", "url=http://rsbweb.nih.gov/ij/"); else if (cmd=="News") run("URL...", "url=http://rsbweb.nih.gov/ij/notes.html"); else if (cmd=="Documentation") run("URL...", "url=http://rsbweb.nih.gov/ij/docs/"); else if (cmd=="ImageJ Wiki") run("URL...", "url=http://imagejdocu.tudor.lu/imagej-documentation-wiki/"); else if (cmd=="Resources") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/"); else if (cmd=="Macro Language") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/macros.html"); else if (cmd=="Macros") run("URL...", "url=http://rsbweb.nih.gov/ij/macros/"); else if (cmd=="Macro Functions") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/functions.html"); else if (cmd=="Plugins") run("URL...", "url=http://rsbweb.nih.gov/ij/plugins/"); else if (cmd=="Source Code") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/source/"); else if (cmd=="Mailing List Archives") run("URL...", "url=https://list.nih.gov/archives/imagej.html"); else if (cmd=="Debug Mode") setOption("DebugMode", true); else if (cmd!="-") run(cmd); } var sCmds = newMenu("Stacks Menu Tool", newArray("Add Slice", "Delete Slice", "Next Slice [>]", "Previous Slice [<]", "Set Slice...", "-", "Convert Images to Stack", "Convert Stack to Images", "Make Montage...", "Reslice [/]...", "Z Project...", "3D Project...", "Plot Z-axis Profile", "-", "Start Animation", "Stop Animation", "Animation Options...", "-", "MRI Stack (528K)")); macro "Stacks Menu Tool - C037T0b11ST8b09tTcb09k" { cmd = getArgument(); if (cmd!="-") run(cmd); } var luts = getLutMenu(); var lCmds = newMenu("LUT Menu Tool", luts); macro "LUT Menu Tool - C037T0b11LT6b09UTcb09T" { cmd = getArgument(); if (cmd!="-") run(cmd); } function getLutMenu() { list = getLutList(); menu = newArray(16+list.length); menu[0] = "Invert LUT"; menu[1] = "Apply LUT"; menu[2] = "-"; menu[3] = "Fire"; menu[4] = "Grays"; menu[5] = "Ice"; menu[6] = "Spectrum"; menu[7] = "3-3-2 RGB"; menu[8] = "Red"; menu[9] = "Green"; menu[10] = "Blue"; menu[11] = "Cyan"; menu[12] = "Magenta"; menu[13] = "Yellow"; menu[14] = "Red/Green"; menu[15] = "-"; for (i=0; iMacros\n" + "menu when Fiji starts.\n" + "\n" + "More information is available at:\n" + ""; dummy = call("fiji.FijiTools.openEditor", title, text); } macro "Save As JPEG... [j]" { quality = call("ij.plugin.JpegWriter.getQuality"); quality = getNumber("JPEG quality (0-100):", quality); run("Input/Output...", "jpeg="+quality); saveAs("Jpeg"); } macro "Save Inverted FITS" { run("Flip Vertically"); run("FITS...", ""); run("Flip Vertically"); } // Add below text to the end of \fiji-win64\Fiji.app\macros\StartupMacros.fiji.ijm // Then restart ImageJ // Use the shortcut 'p' to run 'FEI_SEM_metadata marco' // Use the shortcut 'n' to run 'Annotated Measurements' // Use the shortcut 'q' to run 'JEOL_auto_scale macro' macro "Annotated Measurements [n]" { // Annotate the measured length of a line tool in ImageJ // Author: Nick McDougall and Zhou XU // @ Monash Centre for Electron Microscopy // created on 2018 Aug 30 fontSize = 24; run("Measure"); label = getResult("Length", nResults-1); getVoxelSize(width, height, depth, unit); if (label>10) label = d2s(label,1); else label = d2s(label,2); label = label + " " + unit; setJustification("left"); setFont("SansSerif", fontSize); getLine(x1, y1, x2, y2, lineWidth); v = getPixel((x1+x2)*0.5,(y1+y2)*0.5); if (bitDepth==24) { red = (v>>16)&0xff; // extract red byte (bits 23-17) green = (v>>8)&0xff; // extract green byte (bits 15-8) blue = v&0xff; // extract blue byte (bits 7-0) Luminance = 0.2126 * red + 0.7152 * green + 0.0722 * blue; } else { Luminance = v; } if (Luminance <90) { setColor("white"); } else { setColor("black"); } run("Draw", "slice"); if (label>10) drawString(label, (x1+x2)*0.5+fontSize*0.5, (y1+y2)*0.5+fontSize*0.5); else drawString(label, (x1+x2)*0.5+fontSize*0.5, (y1+y2)*0.5+fontSize*0.5); } macro "FEI_SEM_metadata [p]" { // Set FEI SEM(FIB) scale and display acquisition metadata using Tiff tags Metadata // Author: Zhou XU // @ Monash Centre for Electron Microscopy // created on 2018 Aug 28 // Last updated on 2018 Aug 30 // Pre-requisition of Bio-Formats library to import the chosen file's basic metadata to set the calibration. // Pre-requisition of Bio-Formats library to import the chosen file's basic metadata to set the calibration. run("Bio-Formats Macro Extensions"); path = getDirectory("image"); if (path=="") exit ("path not available"); name = getInfo("image.filename"); if (name=="") exit ("name not available"); id = path + name; Ext.setId(id); Ext.getSeriesCount(seriesCount); // Determine which beam source is used, can be further expanded to accommondate ion beam images Ext.getMetadataValue("[System] SystemType", SystemType); Ext.getMetadataValue("[Beam] Beam", BeamType); Ext.getMetadataValue("[Vacuum] ChPressure", ChPressure); // if the image is acquired by electron beam, then if (BeamType == "EBeam") { Ext.getMetadataValue("[EScan] PixelWidth", value1); Ext.getMetadataValue("[Beam] HV", HV); Ext.getMetadataValue("[Beam] ImageMode", ImageMode); Ext.getMetadataValue("[EBeam] EmissionCurrent", EmissionCurrent); Ext.getMetadataValue("[EBeamDeceleration] ModeOn", EBeamDecelerationMode); Ext.getMetadataValue("[EBeamDeceleration] LandingEnergy", LandingEnergy); Ext.getMetadataValue("[EBeamDeceleration] StageBias", StageBias); Ext.getMetadataValue("[EBeam] BeamMode", BeamMode); Ext.getMetadataValue("[EBeam] BeamCurrent", BeamCurrent); Ext.getMetadataValue("[EBeam] ApertureDiameter", AptDia); Ext.getMetadataValue("[EBeam] LensMode", LensMode); Ext.getMetadataValue("[EBeam] WD", WD); Ext.getMetadataValue("[Scan] Dwelltime", Dwell); Ext.getMetadataValue("[Scan] HorFieldsize", HFW); Ext.getMetadataValue("[EScan] LineIntegration", LineIntegration); Ext.getMetadataValue("[EScan] LineTime", LineTime); Ext.getMetadataValue("[EScan] ScanInterlacing", ScanInterlacing); Ext.getMetadataValue("[EScan] FrameTime", FrameTime); Ext.getMetadataValue("[Image] Integrate", IntegrationNum); Ext.getMetadataValue("[Image] DriftCorrected", DriftCorr); print("Image File : " + id); print("[System] SystemType : " + SystemType); print("[Beam] HV : " + HV + " V"); ChPressure = d2s(parseFloat(ChPressure), -1); print("[Vacuum] Chamber Pressure : " + ChPressure + " Pa"); print("[Beam] ImageMode : " + ImageMode); BeamCurrent = parseFloat(BeamCurrent)*1E9; // in nA AptDia = parseFloat(AptDia)*1E6; // in um WD = parseFloat(WD)*1E3; // in mm Dwell = parseFloat(Dwell)*1E6; // in us EmissionCurrent = parseFloat(EmissionCurrent)*1E6; // in nA print("[EBeam] Emission Current : " + EmissionCurrent + " nA"); print("[EBeam] UC Mode : " + BeamMode); print("[EBeam] Beam Current : " + BeamCurrent + " uA"); print("[EBeam] Aperture Diameter : " + AptDia + " um"); print("[EBeam] Lens Mode : " + LensMode + " mode"); print("[EBeam] Working Distance : " + WD + " mm"); print("[EScan] Dwell Time : " + Dwell + " us"); print("[EScan] Line Integration : " + LineIntegration); print("[EScan] Line Time : ", LineTime); print("[EScan] Scan Interlacing : " + ScanInterlacing); print("[EScan] Frame Time : " + FrameTime); print("[Image] Frame Integration : " + IntegrationNum); print("[Image] Drift Corrected : " + DriftCorr); print("[EBeam Deceleration] Mode On : " + EBeamDecelerationMode); print("[EBeam Deceleration] Landing Energy : " + LandingEnergy + " V"); print("[EBeam Deceleration] Stage Bias : " + StageBias + " V"); print("\n"); if(parseFloat(HFW) > 0.00001) { var ScaleUnit = "um"; setVoxelSize(1E6*value1, 1E6*value1, 1, ScaleUnit); } else { var ScaleUnit = "nm"; setVoxelSize(1E9*value1, 1E9*value1, 1, ScaleUnit); } } // if the image is acquired by ion beam, then... if (BeamType == "IBeam") { Ext.getMetadataValue("[IScan] PixelWidth", value1); Ext.getMetadataValue("[IBeam] HV", HV); Ext.getMetadataValue("[Beam] ImageMode", ImageMode); // have not use this parameter Ext.getMetadataValue("[IBeam] EmissionCurrent", EmissionCurrent); Ext.getMetadataValue("[IBeam] BeamCurrent", BeamCurrent); Ext.getMetadataValue("[IBeam] ApertureDiameter", AptDia); Ext.getMetadataValue("[IBeam] WD", WD); Ext.getMetadataValue("[Scan] Dwelltime", Dwell); Ext.getMetadataValue("[Scan] HorFieldsize", HFW); print("Image File : " + id); print("[System] SystemType : " + SystemType); print("[Beam] HV : " + HV + " V"); ChPressure = d2s(parseFloat(ChPressure), -1); print("[Vacuum] Chamber Pressure : " + ChPressure + " Pa"); print("[Beam] ImageMode : " + ImageMode); BeamCurrent = parseFloat(BeamCurrent)*1E9; // in nA AptDia = parseFloat(AptDia)*1E6; // in um WD = parseFloat(WD)*1E3; // in mm Dwell = parseFloat(Dwell)*1E6; // in us print("[IBeam] Beam Current : " + BeamCurrent + " uA"); // print("[IBeam] Aperture Diameter : " + AptDia + " um"); print("[IBeam] Working Distance : " + WD + " mm"); print("[IScan] Dwell Time : " + Dwell + " us"); print("\n"); if(parseFloat(HFW) > 0.00001) { var ScaleUnit = "um"; setVoxelSize(1E6*value1, 1E6*value1, 1, ScaleUnit); } else { var ScaleUnit = "nm"; setVoxelSize(1E9*value1, 1E9*value1, 1, ScaleUnit); } Ext.close(); } macro "JEOL_auto_scale [q]" { // Set JOEL SEM scale and display acquisition metadata using txt Metadata // Author: Zhou XU // at Monash Centre for Electron Microscopy // Windows 10 Enterprise Ver. 1803 // ImageJ ver. 1.52g // Created on 2018 Sep 07 // Modified on 2018 Oct 01 path = getDirectory("image"); if (path=="") exit ("path not available"); name = getInfo("image.filename"); if (name=="") exit ("name not available"); id = path + name; txtID = replace(id, ".tif", ".txt"); txtID = replace(txtID, ".jpg", ".txt"); if (File.exists(txtID)==1) { lineseparator = ",\n\t"; cellseparator = " "; lines=split(File.openAsString(txtID), lineseparator); for (i=0; i