/* This is a RunAtStartup file for use in a shared ImageJ/Fiji workspace at the Applied Superconductivity Center at NHMFL.
It loads some preferred settings and tools for ASC use, so as to provide a more consistent environment.
Obviously non-FSU users would benefit from changing much of this script but hopefully it contains some useful ideas for multi-user environments.
For instance, some hyper-link references are to specific resources at NHMFL so this would have to be edited for use elsewhere.
All testing has been on Windows PCs, YMMV on other platforms.
PJL v201117: modified for use with preferred Azul Zulu Builds of OpenJDK. v210316 added one word of text ("stable"). v210716 replaced Nabble with NIH references v210819 reduced max dialog width
v210907 Adds IJ window always on top by default option and forces 16-bit white to 65535.
v210930 The official News page does not seem to be updated as frequently as the github site so the version info is now prioritized for this location. Some more format tweaking using the new message options.
v211001 User macro folder no longer opens automatically for all non-admin, only the admin seems much interested in writing macros.
v211018 Reports Gifsicle and ImageMagick installations.
v211022 Added IO default options.
v211102 Removed duplicate and corrupted IO options, added option to open the latest release notes.
v211104 Added Misc options.
v211213-4 Updated findApp function v220121 Added GnuWin32 path.
v220208 Moved most of the system information to an option function to speed things up for regular users.
v220506 Added low-assigned memory alert.
v220510 Option to replace default smooth shortcut with save-as-PNG
v220603 Added OS message. v220606 Minor dialog tweaks.
v220609 Quits if run from repository. v220628 Updated convert to magick.exe for IM7.
v220710 Reworked killOnZ poison pill so that it did not slow startup so much...and should actually work now.
v220808: Only checks for Versatile Wand and Olympus viewer plugins once
v220913: Updated notes link
v221213: Fixed error caused when no internet connection v221220 Added logo to dialog but does not work yet. Adds startup version.
v230227: Added require ctrl-key for shortcuts to reduce accidental selection. Also added non-blocking filters to defaults. Moved Debug option to group checkbox.
v230410: Moved more options to checkboxGroup to reduce dialog size. Changed way multiple checkbox prefs are saved. Checks for user macro directory.
v230505 and 070723: Updated links.
v230720: Added a link to the manuals on Z and a warning if the user macro directory was not found.
v230803: Replaced getDir for 1.54g9.
v230904: Adds a 'record' (macro) option. v230913: Cosmetic changes.
v231004: URLs are opened by default URL browser regardless of OS. b: removed unmatched parenthesis line 153.
v240119: Added link to ImageMagick downloads for admin users.
v240308: Added option to open the prefs file for editing (mine corrupted the toolbar for instance, so I deleted the toolbar prefs). Made dialog 1 line shorter.
v240311: Added resetting of numbered toolbar prefs to ASC settings.
v240326: Minor fixes in attempt to fix machine-specific failure.
v240331: Missing setup line finally fixed for users without z-drive access.
v240416: Cosmetic changes.
v240618: Tried to make faster if not connected to MagLab Z drive.
v240624: Link to java download now specific to installed java version.
v240709: Switched macro functions page to https://wsr.imagej.net//developer/macro/functions.html .
v240725: Added "Email Peter" checkbox.
v240812: Checks for ImageMagick version. v250311: IM version checked tweaked Azul versions changed to jdk (no fx). v250617: Added user hello.
v250814: Another tweak to IM version discovery.
v251017: Contact email address change for future proofing.
v260409-10: Replaced nih.gov references.
*/
macroL = "ASC RunAtStartup_v260410";
startTime = getTime();
admin = "lee"; /* Change this to your user name if you want to see the extended admin menu and checks */
username = getInfo("user.name");
os = getInfo("os.name");
win = startsWith(os, "Windows");
startDir = getDirectory("startup");
imageJDir = getDirectory("imagej");
onZ = false;
setOption("WaitForCompletion", false);
if (File.isDirectory("Z:")) {
onZ = true;
if (startsWith(imageJDir, "Z:")) killOnZ(); /* shuts ImageJ/Fiji down if run from the ASC distribution directory */
}
installedVersionFull = IJ.getFullVersion();
installedVersion = substring(installedVersionFull, 0, 5);
versionsText = "Installed ImageJ Version: " + installedVersionFull + " \(" + getVersion() + "\)";
screenH = screenHeight;
if (screenH >= 1060) loResScreen = false;
else loResScreen = true;
if (screenH < 900) loLoResScreen = true;
else loLoResScreen = false;
mWidthLimit = minOf(62, 0.5 * screenWidth / 12);
/* assume font size of 12 as getValue("font.size") requires open image */
memMax = IJ.maxMemory();
memMax /= 1000000;
if (memMax < 2000) memAlert = true;
else memAlert = false;
replaceSmthSC = checkForPluginNameContains("Remove_Smooth_Shortcut");
dTxtWMax = 92;
localInfoTime = getTime();
vWand = checkForPluginNameContains("Versatile_Wand_Tool");
olyViewer = checkForPluginNameContains("Olympus_Viewer");
fS = File.separator;
/* ASC message theme */
infoColor = "#006db0"; /* Honolulu blue */
instructionColor = "#798541"; /* green_dark_modern (121,133,65) AKA Wasabi */
infoWarningColor = "#ff69b4"; /* pink_modern AKA hot pink */
infoFontSize = 11.6;
Dialog.createNonBlocking("Hello " + toUpperCase(substring(username, 0, 1)) + substring(username, 1) + ", welcome to the ASC-tweaked ImageJ/Fiji configuration: " + macroL);
dialogStartTime = getTime();
if (loResScreen) {
Dialog.setInsets(-3, 25, 0);
Dialog.addMessage("Screen height is only " + screenH + ", some menus may be truncated or will not fit on screen", infoFontSize, infoWarningColor);
Dialog.addCheckbox("Open GUI settings options to reduce font size or GUI scaling?", false);
}
if (memAlert)
Dialog.addCheckbox("Assigned memory is low \(" + memMax + "MB\), open memory options?", false);
newRelease = "";
nVT = "";
if (username == admin) {
localDelay = (localInfoTime - startTime) / 1000;
dialogDelay = (dialogStartTime - localInfoTime) / 1000;
if (localDelay > 0.1 || dialogDelay > 0.1) {
Dialog.setInsets(-3, 25, -3);
Dialog.addMessage("Local info delay:" + localDelay + " s" + ", dialog creation time:" + (dialogStartTime - localInfoTime) / 1000 + " s", infoFontSize, infoWarningColor);
if (!onZ && localDelay > 30) Dialog.addMessage("Excessive local delay caused by not having access to MagLab Z drive either directly or via VPN", infoFontSize, infoWarningColor);
}
javaVendor = getInfo("java.vendor");
javaV = "" + getInfo("java.runtime.version");
/* Check to see if running latest imageJ version */
versionNotes = File.openUrlAsString("https://raw.githubusercontent.com/imagej/imagej1/master/release-notes.html");
if (indexOf(versionNotes, "Release Notes<\/title>") > 0) {
if (indexOf(versionNotes, "
Version ") > 0) {
nVP = indexOf(versionNotes, "Version "); /* 091720 ">" was added to notes page an then later removed ¯\_(ツ)_/¯ for Version 1.53e*/
newVersion = substring(versionNotes, nVP + 12, nVP + 17);
nVT = "latest stable version: " + newVersion;
} else {
iJNewsTxt = "Unable to find ImageJ version in \"News\" \(https://imagej.net/news/\)";
Dialog.setInsets(-3, 25, 0);
Dialog.addMessage(iJNewsTxt, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(iJNewsTxt)), infoColor);
newVersion = "";
}
} else {
iJNewsTxt = "Unable to open ImageJ \"News\" \(raw.githubusercontent.com/imagej/imagej1/master/release-notes.html\)";
Dialog.setInsets(-3, 25, 0);
Dialog.addMessage(iJNewsTxt, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(iJNewsTxt)), infoColor);
newVersion = "";
}
releaseNotes = File.openUrlAsString("https://raw.githubusercontent.com/imagej/imagej1/master/release-notes.html");
if (indexOf(releaseNotes, "
") > 0) {
nVP = indexOf(releaseNotes, " ");
nVPe = indexOf(releaseNotes, "");
newReleaseFull = substring(releaseNotes, nVP + 8, nVPe);
newReleaseVersion = substring(newReleaseFull, 0, indexOf(newReleaseFull, " "));
if (lastIndexOf(newRelease, " ") > 0) {
if (newReleaseVersion != newVersion && newVersion != "") nVT = "latest stable version: " + newVersion + ", latest released: " + newReleaseVersion;
else nVT = "latest version: " + newVersion + ", latest release: " + newRelease;
} else if (newVersion != "") nVT = "latest stable version: " + newVersion + ", latest release notes: " + newReleaseVersion;
else if (newReleaseVersion != "") nVT = "latest release: " + newReleaseVersion;
else nVT = "";
} else {
iJRelNotes = "Unable to open latest ImageJ \"Release Notes\" \(raw.githubusercontent.com/imagej/imagej1/master/release-notes.html\)";
Dialog.setInsets(-3, 25, 0);
Dialog.addMessage(iJRelNotes, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(iJRelNotes)), infoColor);
newReleaseVersion = "";
}
if (newVersion != installedVersion) {
versionsText += ", " + nVT;
if (nVT != "") {
Dialog.setInsets(0, 25, -3);
Dialog.addMessage(versionsText, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(versionsText)), infoColor);
dTextV = "Visit ImageJ web site to learn about the latest stable version";
if (newVersion != "" && lengthOf(newVersion) < 7) dTextV += "\(" + newVersion + "\)";
Dialog.addCheckbox(dTextV + "?", false);
Dialog.addCheckbox("Browse release notes for version" + newReleaseVersion + "?", false);
}
} else {
Dialog.setInsets(0, 25, -3);
dTextV = "You are running the latest stable version of ImageJ1";
if (newVersion != "" && lengthOf(newVersion) < 7) dTextV += "\(" + newVersion + "\)";
Dialog.addMessage(dTextV, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(dTextV)), infoColor);
}
Dialog.addCheckbox("Visit " + javaVendor + " for updates to Java version JDK " + javaV, false);
if (endsWith(imageJDir, fS)) iMNoticePath = imageJDir + "Apps" + fS + "ImageMagick" + fS + "NOTICE.txt";
else iMNoticePath = imageJDir + fS + "Apps" + fS + "ImageMagick" + fS + "NOTICE.txt";
iMLVersion = "version not found";
if (File.isFile(iMNoticePath)) {
iMNotice = File.openAsString(iMNoticePath);
iMLVStart = indexOf(iMNotice, "agick") + 6;
iMLVEnd = indexOf(iMNotice, "]", iMLVStart) - 14;
if (iMLVStart > 0 && iMLVEnd > iMLVStart && iMLVEnd - iMLVStart < 27) iMLVersion = substring(iMNotice, iMLVStart, iMLVEnd);
}
iMCV = "version not found";
iMHome = File.openUrlAsString("https://imagemagick.org");
iMVStart1 = indexOf(iMHome, "recent version available is");
if (iMVStart1 > 0) {
iMVStart = indexOf(iMHome, "ImageMagick ", iMVStart1);
iMVEnd = indexOf(iMHome, "<", iMVStart);
if (iMVStart > 0 && iMVEnd > iMVStart && iMVEnd - iMVStart < 22)
iMCV = substring(iMHome, iMVStart + 12, iMVEnd);
}
Dialog.addCheckbox("Visit imagemagick.org for updates to ImageMagick \(current: " + iMCV + ", installed: " + iMLVersion + "\)", false);
macroFunctions = File.openUrlAsString("https://wsr.imagej.net//developer/macro/functions.html");
if (macroFunctions != "") {
lMFP = indexOf(macroFunctions, "Last updated ");
if ((lMFP + 23) < lengthOf(macroFunctions)) {
lastMacroUpdate = substring(macroFunctions, lMFP + 13, lMFP + 23);
Dialog.setInsets(0, 35, -2);
builtInTxt = "The built-in ImageJ macro functions page was last updated: " + lastMacroUpdate + ", see link in ''Develop'' section";
Dialog.setInsets(-3, 25, 0);
Dialog.addMessage(builtInTxt, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(builtInTxt)), infoColor);
}
}
} else {
Dialog.setInsets(-3, 20, 0);
userMessage = "This version, including the macro and scripts directory, is mirrored at" +
"\n9 pm every Weekday from 'Peter's Current Version' on Z." +
"\n !!! Do NOT save new macros, scripts or settings to this installation !!!" +
"\n Save new macros etc. to 'Z:\\ASC\\Software and Drivers\\Fiji\\ASC_User_Macros\'" +
"\n User macros will eventually appear under Analyze..ASC_NHMFL_Macros" +
"\nPlease report bugs or suggest improvements to Peter Lee";
Dialog.addMessage(userMessage, infoFontSize, infoWarningColor);
}
zFijiDocsFound = false;
userMacrosDirFound = false;
miscOptions = newArray();
miscOptionsChecks = newArray();
if (onZ) {
/* Miscellaneous options - available option depends on the availability of the z drive */
zFijiPath = "Z:" + fS + "ASC" + fS + "Software and Drivers" + fS + "Fiji" + fS;
zUserMacroPath = zFijiPath + "ASC_User_Macros";
if (File.isDirectory(zUserMacroPath)) {
userMacrosDirFound = true;
if (win) {
miscOptions = Array.concat(miscOptions, "Open ASC User Macro Directory on Z?");
miscOptionsChecks = Array.concat(miscOptionsChecks, false);
}
} else
Dialog.addMessage("The User Macro Directory on Z was not found: Save your macros to a non-Fiji location", infoFontSize, infoWarningColor);
zFijiDocsPath = zFijiPath + "Docs and Tutorials";
if (File.isDirectory(zFijiDocsPath)) {
zFijiDocsFound = true;
if (win) {
miscOptions = Array.concat(miscOptions, "Open ASC Fiji Tutorials & Manuals on Z?");
miscOptionsChecks = Array.concat(miscOptionsChecks, false);
}
}
}
userPrefs = getInfo("user.home") + fS + ".imagej" + fS + "IJ_Prefs.txt";
if (win && File.isFile(userPrefs)) edPrefs = true;
else edPrefs = false;
if (edPrefs) {
miscOptions = Array.concat(miscOptions, "Edit prefs file \(this can get corrupted\)");
miscOptionsChecks = Array.concat(miscOptionsChecks, false);
}
miscOptions = Array.concat(miscOptions, "Apply settings typically used for ASC macros?");
miscOptionsChecks = Array.concat(miscOptionsChecks, true);
Dialog.setInsets(0, 20, 0);
if (miscOptions.length <= 2) Dialog.addCheckboxGroup(1, miscOptions.length, miscOptions, miscOptionsChecks);
else Dialog.addCheckboxGroup(2, Math.ceil(miscOptions.length / 2), miscOptions, miscOptionsChecks);
Dialog.setInsets(-2, 35, 0);
ASCSetTxt = "ASC settings: black objects on white, antialiased text, bicubic, csv, all measurements, 16-bit white=65535";
Dialog.addMessage(ASCSetTxt, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(ASCSetTxt)), infoColor);
/* Misc settings additional checkboxes */
miscSettings = newArray("Ctrl-key required for shortcuts",
"Non-blocking filter dialogs",
"Debug mode");
miscSettingsChecksPrefs = call("ij.Prefs.get", "asc.startup.settings.misc.prefs", "1|1|0");
miscSettingsDefaultChecks = split(miscSettingsChecksPrefs, "|");
Dialog.setInsets(0, 20, 0);
dCols = minOf(3, lengthOf(miscSettings));
dRows = Math.ceil(lengthOf(miscSettings) / dCols);
Dialog.addCheckboxGroup(dRows, dCols, miscSettings, miscSettingsDefaultChecks);
/* Additional settings checkboxes */
addSettings = newArray("Record", "Apply Input/Output defaults?");
addSettingsDefaultChecks = newArray(false, true);
if (vWand) {
addSettings = Array.concat(addSettings, "Versatile Wand on menu?");
addSettingsDefaultChecks = Array.concat(addSettingsDefaultChecks, true);
}
if (win) {
addSettings = Array.concat(addSettings, "Email Peter for help");
addSettingsDefaultChecks = Array.concat(addSettingsDefaultChecks, false);
}
addSettingsChecksPrefs = call("ij.Prefs.get", "asc.startup.settings.add.prefs", "not found");
if (addSettingsChecksPrefs != "not found") {
addSettingsChecks = split(addSettingsChecksPrefs, "|");
for (i = 0; i < lengthOf(addSettings); i++)
if (i < lengthOf(addSettingsChecks)) addSettingsDefaultChecks[i] = addSettingsChecks[i];
else addSettingsDefaultChecks[i] = false;
}
dCols = minOf(3, lengthOf(addSettings));
dRows = Math.ceil(lengthOf(addSettings) / dCols);
Dialog.setInsets(0, 20, 0);
Dialog.addCheckboxGroup(Math.ceil(lengthOf(addSettings) / dCols), dCols, addSettings, addSettingsDefaultChecks);
// Dialog.addCheckbox("Apply plot settings: 1024x768, grid, ticks, 14pt font size?",true);
Dialog.setInsets(-2, 35, 0);
iOTxt = "IO defaults: jpeg qual: 85, non-transp gif, results file: .csv, save: column header and row #";
Dialog.addMessage(iOTxt, minOf(infoFontSize, infoFontSize * dTxtWMax / lengthOf(iOTxt)), infoColor);
Dialog.addCheckbox("Set IJ windows always on top \(and no LUT perhaps\)", false);
Dialog.setInsets(-3, 20, 0);
if (replaceSmthSC)
Dialog.addCheckbox("Replace built-in ctrl-shift-s Smooth shortcut with save-as-png", true);
if (loLoResScreen)
Dialog.setInsets(-3, 20, 0);
Dialog.addCheckbox("Sub-pixel floating-point coordinates for line selections?", true);
// if(loLoResScreen) Dialog.setInsets(-3,20,0);
Dialog.addCheckbox("Output system and ImageJ/FIJI information to log window?", false);
if (olyViewer)
Dialog.addCheckbox("Open Olympus Drag'nDrop VSI Importer \(not needed for DSX images\)?", false); /* The Olympus viewer facilitates conversion of images created using the original Olympus Stream software */
Dialog.addMessage("Learn:______________Opens web pages in default browser");
learnChoices = newArray("User Guide \(HTML format\)", "Tutorial", "ImageJ/Fiji Getting Started", "ImageJ Documentation", "Fiji/ImageJ Links", "Fiji/ImageJ Introduction", "Auto-Threshold Description", "Trainable Segmentation", "ASC Macros described");
learnChoicesDefaults = newArray(lengthOf(learnChoices));
Dialog.setInsets(0, 20, 0);
Dialog.addCheckboxGroup((1 + lengthOf(learnChoices)) / 3, 3, learnChoices, learnChoicesDefaults);
if (!loLoResScreen) {
Dialog.addMessage("Develop:____________Opens web pages in default browser");
developChoices = newArray("Developer Resources", "Built-in Macro Functions", "image.sc Forum", "ImageJ Mailing List Archive", "ImageJ @ stackoverflow", "Fiji Plugins Update Sites");
developChoicesDefaults = newArray(lengthOf(developChoices));
Dialog.setInsets(0, 20, 0);
Dialog.addCheckboxGroup((1 + lengthOf(developChoices)) / 3, 3, developChoices, developChoicesDefaults);
}
if (!win)
Dialog.addMessage("ASC Macros have only been tested on the Windows platform\n Use the Dev menu button to find support documents", infoFontSize, infoWarningColor);
// ascLogo = imageJDir + fS + "asc" + fS +"ASCBannerLogo133x24.png";
// if (!loResScreen && getVersion()>"1.53v18" && File.exists(ascLogo)) Dialog.addImage(ascLogo);
Dialog.show;
if (loResScreen) openGuiOptions = Dialog.getCheckbox();
else openGuiOptions = false;
if (memAlert) {
if (Dialog.getCheckbox()) run("Memory & Threads...");
}
if (username == admin) {
if (newVersion != installedVersion) {
if (nVT != "") {
if (Dialog.getCheckbox()) run("URL...", "url=https://wsr.imagej.net/notes.html");
if (Dialog.getCheckbox()) run("URL...", "url=https://raw.githubusercontent.com/imagej/imagej1/master/release-notes.html");
}
}
if (Dialog.getCheckbox()) {
dot0 = indexOf(javaV, ".");
javaN = parseInt((substring(javaV, 0, dot0)));
if (javaN == 1) {
dot1 = indexOf(javaV, ".", dot0 + 1);
if (dot1 > (1 + dot0)) javaN = parseInt(substring(javaV, dot0 + 1, dot1));
else javaN = parseInt(substring(javaV, dot0 + 1, dot0 + 2));
}
if (!isNaN(javaN)) run("URL...", "url=https://www.azul.com/downloads/?version=java-" + javaN + "-lts&os=windows&architecture=x86-64-bit&package=jdk#zulu");
else run("URL...", "url=https://www.azul.com/downloads/?version=java-8-lts&os=windows&architecture=x86-64-bit&package=jdk#zulu");
}
if (Dialog.getCheckbox()) {
if (win) run("URL...", "url=https://imagemagick.org/script/download.php#windows");
else run("URL...", "url=https://imagemagick.org/script/download.php");
}
}
/* Misc options checkboxes */
if (onZ) {
if (win && userMacrosDirFound) {
if (Dialog.getCheckbox()) {
setOption("WaitForCompletion", false);
exec("cmd /c C:" + fS + "Windows" + fS + "explorer.exe \"" + zUserMacroPath + "\"");
}
}
if (win && zFijiDocsFound) {
if (Dialog.getCheckbox()) {
setOption("WaitForCompletion", false);
exec("cmd /c C:" + fS + "Windows" + fS + "explorer.exe \"" + zFijiDocsPath + "\"");
}
}
}
if (edPrefs) edPrefs = Dialog.getCheckbox();
defaultSettings = Dialog.getCheckbox();
/* Misc settings checkboxes */
miscSettings = "";
if (defaultSettings) miscSettings += "divide=Infinity move run enhanced ";
/* Misc settings checkbox group */
miscSettingsCtrl = Dialog.getCheckbox();
if (miscSettingsCtrl) miscSettings += "require ";
miscSettingsNB = Dialog.getCheckbox();
if (miscSettingsNB) miscSettings += "non-blocking ";
miscSettingsDebug = Dialog.getCheckbox();
if (miscSettingsDebug) miscSettings += "debug ";
if (miscSettings != "") run("Misc...", miscSettings); /* move single plugins to misc, run single open app monitor, enhanced line */
miscSettingsPrefs = d2s(miscSettingsCtrl, 0) + "|" + d2s(miscSettingsNB, 0) + "|" + d2s(miscSettingsDebug, 0);
call("ij.Prefs.set", "asc.startup.settings.misc.prefs", miscSettingsPrefs);
/* Add settings checkboxes */
record = Dialog.getCheckbox();
defaultIO = Dialog.getCheckbox();
if (defaultIO) {
run("Input/Output...", "jpeg=85 gif=-1 file=.csv copy_column copy_row save_column save_row");
saveSettings();
}
addSettingsPrefs = d2s(record, 0) + "|" + d2s(defaultIO, 0);
if (vWand) {
if (Dialog.getCheckbox()) {
run("Versatile Wand Tool"); /* Adds Versatile Wand to the toolbar */
setTool("rectangle"); /* After adding wand tool icon by running now set back to default selection tool */
addSettingsPrefs += "|" + "1";
} else addSettingsPrefs += "|" + "0";
}
if (win) {
if (Dialog.getCheckbox())
exec("cmd /c start mailto:pjlee@fsu.edu?subject=ASC_ImageJ-Fiji_Problem&body= ");
addSettingsPrefs += "|" + "0"; /* Should always default to unchecked */
}
call("ij.Prefs.set", "asc.startup.settings.add.prefs", addSettingsPrefs);
iJTop = Dialog.getCheckbox();
if (replaceSmthSC) replaceSmthSC = Dialog.getCheckbox();
if (defaultSettings) {
for (i = 0; i < 15; i++) call("ij.Prefs.set", "toolbar.tool" + IJ.pad(i, 2), ""); /* resets corrupted toolbar tools */
/* Set options for black objects on white background as this works better for publications */
run("Options...", "iterations=1 white count=1"); /* Resets all process/binary/options to single and the background to not-black */
// run("Options...", "iterations=1 white count=1"); /* Just set process/binary/option background to not-black */
run("Colors...", "foreground=black background=white selection=yellow"); /* Set the preferred colors for these macros https://imagej.net/doku.php?id=faq:technical:how_do_i_set_up_imagej_to_deal_with_white_particles_on_a_black_background_by_default */
setOption("BlackBackground", false); /* black particles on a white background friendlier for publication */
setOption("Bicubic", true); /* Forces commands like Edit>Selection>Straighten, that normally use bilinear interpolation, to use bicubic interpolation. */
setOption("AntialiasedText", true);
call("ij.ImagePlus.setDefault16bitRange", 16);
if (iJTop) run("Appearance...", "ij 16-bit=[16-bit (0-65535)]"); /* IJ bar always on top and force 16-bit to full range, no Invert LUT */
// run("Appearance...", " "); /* Do not use Inverting LUT - appears to have no effect �\_(?)_/� */
run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack nan redirect=None decimal=9");
setOption("Add to overlay", true); /* Set the Analyze option */
/* Store Default Preferences on Prefs file: C:\Users\username\.imagej\IJ_Prefs.txt these are reloaded in the StartupMacros */
call("ij.Prefs.set", "startup.brush", "10");
call("ij.Prefs.set", "startup.flood", "8-connected");
saveSettings();
} else if (iJTop) run("Appearance...", "ij"); /* IJ bar always on top and no LUT */
// if (Dialog.getCheckbox())run("Plots...", "width=1024 height=768 font=14 draw draw_ticks");
if (Dialog.getCheckbox()) run("Plots...", "sub-pixel");
if (Dialog.getCheckbox()) IJ.log(getSystemInfo());
if (olyViewer) {
if (Dialog.getCheckbox()) run("DragDrop");
}
/* 9 Learning links */
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/docs/guide/");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/Category:Tutorials");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/Getting_Started");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/docs/index.html");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/Links");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/Introduction");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/plugins/auto-threshold");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/Trainable_Weka_Segmentation");
if (Dialog.getCheckbox()) run("URL...", "url=https://fs.magnet.fsu.edu/~lee/asc/ImageJUtilities/ASC_ImageJ_Utils.html");
if (!loLoResScreen) {
/* 6 Developer links */
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.net/developer/index.html");
if (Dialog.getCheckbox()) run("URL...", "url=https://wsr.imagej.net//developer/macro/functions.html");
if (Dialog.getCheckbox()) run("URL...", "url=https://forum.image.sc/tags/imagej");
if (Dialog.getCheckbox()) run("URL...", "url=https://list.nih.gov/cgi-bin/wa.exe?A0=IMAGEJ");
if (Dialog.getCheckbox()) run("URL...", "url=https://stackoverflow.com/search?tab=active&q=ImageJ");
if (Dialog.getCheckbox()) run("URL...", "url=https://imagej.github.io/list-of-update-sites");
}
if (openGuiOptions) run("Appearance...");
if (replaceSmthSC) run("Replace Smooth Shortcut");
saveSettings(); /* Save settings so that they can be restored to defaults if necessary */
showStatus("!ImageJ: " + IJ.getFullVersion + " \(" + getVersion() + "\), Memory: " + IJ.freeMemory() + ", Java: v." + getInfo("java.runtime.version") + " \(" + getInfo("java.vendor") + "\)");
if (record) run("Record...");
if (edPrefs) {
setOption("WaitForCompletion", false);
exec("cmd /c C:" + fS + "Windows" + fS + "explorer.exe \"" + userPrefs + "\"");
}
// if (defaultSettings) run("Commands..."); /* Opens a list of commonly and recently used commands - 1.52s 10 December 2019 */
/* Add other commands here e.g. Mahdi Rawak's command Bar https://imagej.net/ij/plugins/command-bar/index.html
run("Command Bar");
*/
/*
( 8(|) ( 8(|) ASC Functions @@@@@:-) @@@@@:-)
*/
function checkForPluginNameContains(pluginNamePart) {
/* v180831 1st version to check for partial names so avoid versioning problems
...
v220722 Uses File.separator and adds .class
v230912 This version is case insensitive and does NOT require restoreExit.
NOTE: underlines are NOT converted to spaces in names */
pluginCheck = false;
pluginNamePart = toLowerCase(pluginNamePart);
fS = File.separator;
pluginDir = getDirectory("plugins");
if (pluginDir == "") IJ.log("Failure to find any plugins!");
else {
pluginFolderList = getFileList(pluginDir);
subFolderList = newArray();
pluginList = newArray();
for (l = 0; l < pluginFolderList.length; l++) {
if (endsWith(pluginFolderList[l], fS)) subFolderList = Array.concat(subFolderList, pluginFolderList[l]);
else if (endsWith(pluginFolderList[l], "/")) subFolderList = Array.concat(subFolderList, pluginFolderList[l]); /* File.separator does not seem to be working here */
else if (endsWith(toLowerCase(pluginFolderList[l]), ".jar") || endsWith(toLowerCase(pluginFolderList[l]), ".class")) pluginList = Array.concat(pluginList, toLowerCase(pluginFolderList[l]));
}
/* First check root plugin folder */
for (i = 0; i < lengthOf(pluginList) && !pluginCheck; i++) {
if (indexOf(pluginList[i], pluginNamePart) >= 0) pluginCheck = true;
}
/* If not in the root try the subfolders */
if (!pluginCheck) {
for (i = 0; i < subFolderList.length && !pluginCheck; i++) {
subFolderPluginList = getFileList(pluginDir + subFolderList[i]);
for (k = 0; k < subFolderPluginList.length; k++) subFolderPluginList[k] = toLowerCase(subFolderPluginList[k]);
for (j = 0; j < subFolderPluginList.length && !pluginCheck; j++) {
if (endsWith(subFolderPluginList[j], ".jar") || endsWith(subFolderPluginList[j], ".class"))
if (indexOf(subFolderPluginList[j], pluginNamePart) >= 0) pluginCheck = true;
}
}
}
}
return pluginCheck;
}
function findAppPath(appName, appEx, defaultPath) {
/* v210921 1st version: appName is assumed to be the app folder name, appEx is the executable, default is the default return value
v211018: assumes specific executable path stored in prefs. Logs message rather than exits when app not found
v211213: fixed defaultPath error
v211214: Adds additional location as packaged within a Fiji/IJ distribution
v220121: Changed fS line
v230803: Replaced getDir with getDirectory for ImageJ 1.54g9
*/
functionL = "findAppPath_v230803";
fS = File.separator;
ijPath = getDirectory("imagej");
appsPath = substring(ijPath, 0, lengthOf(ijPath) - 1);
appsPath = substring(appsPath, 0, lastIndexOf(appsPath, fS));
appFound = false;
prefsName = "asc.external.paths." + toLowerCase(appName) + "." + appEx;
appPath = call("ij.Prefs.get", prefsName, defaultPath);
appLoc = "" + fS + appName + fS + appEx;
cProg = "C:" + fS + "Program Files";
defAppPaths = newArray(cProg + fS + "Utilities" + appLoc, cProg + " \(x86\)" + fS + "Utilities" + appLoc, cProg + appLoc, cProg + " \(x86\)" + appLoc, appsPath + appLoc, ijPath + "Apps" + appLoc);
if (!File.exists(appPath)) {
for (i = 0; i < lengthOf(defAppPaths); i++) {
if (File.exists(defAppPaths[i])) {
appPath = defAppPaths[i];
call("ij.Prefs.set", prefsName, appPath);
appFound = true;
i = lengthOf(defAppPaths);
}
}
} else appFound = true;
if (appFound == false) {
Dialog.create("Find location of " + appEx + " version: " + functionL);
Dialog.addMessage(appEx + " can provide additional functionality to this macro\nbut has not been found in the expected locations");
Dialog.addCheckbox("Get me out of here, I don't want to try and find " + appName + ", whatever that is", false);
Dialog.addFile("Locate " + appEx + ":", "C:" + fS + "Program Files");
Dialog.addMessage("If found, the location will be saved in prefs for future use:\n" + prefsName);
Dialog.show;
if (Dialog.getCheckbox()) appFound = false;
else {
appPath = Dialog.getString();
if (!File.exists(appPath)) IJ.log(appEx + " not found");
else {
call("ij.Prefs.set", prefsName, appPath);
appFound = true;
}
}
}
if (appFound) return appPath;
else return defaultPath;
}
function getSystemInfo() {
lfunction = "getSystemInfo_v240624";
os = getInfo("os.name");
win = startsWith(os, "Windows");
javaV = "" + getInfo("java.runtime.version");
javaVendor = getInfo("java.vendor");
fS = File.separator;
memMax = IJ.maxMemory();
memMax /= 1000000;
gSPath = findAppPath("Gifsicle", "gifsicle.exe", "not found");
iMConvPath = findAppPath("ImageMagick", "magick.exe", "not found");
gnuWin32Path = findAppPath("GnuWin32" + fS + "bin", "tiffsplit.exe", "not found");
/* This section shortens directory paths using the common base ImageJ directory if possible */
userDirL = getInfo("user.dir");
username = getInfo("user.name");
imageJDir = getDirectory("imagej");
javaHDir = replace(getInfo("java.home"), "/", fS);
if (startsWith(javaHDir, imageJDir)) javaHDir = " ..." + substring(javaHDir, lengthOf(imageJDir)) + " ";
else javaHDir = javaHDir + "\n";
javaCP = replace(getInfo("java.class.path"), "/", fS);
if (startsWith(javaCP, imageJDir)) javaCP = " ..." + substring(javaCP, lengthOf(imageJDir));
else javaCP = javaCP + "\n";
pluginsDir = getDirectory("plugins");
if (startsWith(pluginsDir, imageJDir)) pluginsDir = " ..." + substring(pluginsDir, lengthOf(imageJDir)) + " ";
else pluginsDir = pluginsDir + "\n";
macrosDir = getDirectory("macros");
if (File.exists(macrosDir + "runAtStartup.ijm")) rASModString = " \(date: " + File.dateLastModified(macrosDir + "runAtStartup.ijm") + "\)";
else rASModString = "";
if (File.exists(macrosDir + "StartupMacros.fiji.ijm")) sMString = "\nFiji startup last modified: " + File.dateLastModified(macrosDir + "StartupMacros.fiji.ijm");
else if (File.exists(macrosDir + "StartupMacros.ijm")) sMString = "\nImageJ startup last modified: " + File.dateLastModified(macrosDir + "StartupMacros.ijm");
else sMString = "";
if (startsWith(macrosDir, imageJDir)) macrosDir = " ..." + substring(macrosDir, lengthOf(imageJDir));
/* End of abbreviation section */
systemInfoTxt = "ImageJ Version: " + IJ.getFullVersion + " \(" + getVersion() + "\)" +
"\nMemory status: " + IJ.freeMemory() + ", IJ assigned max: " + memMax + " MB" +
"\nJava: " + getInfo("java.runtime.name") +
"\n Java version: " + javaV +
"\n Java Vendor: " + javaVendor +
"\nCharacter encoding: " + getInfo("file.encoding") + " \(ASC macros should be Cp-1252\)" +
"\nOperating system: " + getInfo("os.name") + " \(ASC macros only tested in Windows\)" +
"\nUser name: " + username +
"\nUser home: " + getInfo("user.home") +
"\nIJ prefs: \\.imagej" +
"\nUser directory: " + userDirL +
"\nImageJ directory: " + imageJDir +
"\nJava home dir.: " + javaHDir +
"\nJava class path: " + javaCP + "\)" +
"\nPlugins directory: " + pluginsDir +
"\nMacros directory: " + macrosDir +
"\nGifsicle path: " + gSPath +
"\nImageMagick Convert path: " + iMConvPath +
"\nGnuWin32 path: " + gnuWin32Path +
"\nRun at startup pop-up menu: " + rASModString + sMString +
"\n---------------\n";
return systemInfoTxt;
}
function killOnZ() {
functionL = "killOnZ_v230803";
/* Poison pill section to stop running from distribution directory */
fS = File.separator;
zRepDir = "Z:" + fS + "ASC" + fS + "Software and Drivers" + fS + "Fiji";
warnFile = "Z:" + fS + "ASC" + fS + "Software and Drivers" + fS + "Fiji" + fS + "Do_NOT_Run_Fiji_from_Z.txt";
if (File.exists(warnFile)) canWarn = true;
else canWarn = false;
if (indexOf(getDirectory("startup"), zRepDir) >= 0) {
if (startsWith(getInfo("os.name"), "Windows") && canWarn) exec("cmd /c C:" + fS + "Windows" + fS + "explorer.exe \"" + warnFile + "\"");
run("Quit");
}
/* end of pill */
}