print("\\Clear"); print("===== ignore these tests of IJ-macro functions... ======"); print("=== test macro functions ==="); number = 2.5; print(number); numberString = getNumberToStringMacroFunction(number, 3, 6); print("number after function", numberString); outputPath = getDirectory("temp"); saveLogMacroFunction(outputPath + "Log_test_macro" + "" + ".txt"); print("Log was saved..."); print("\n================ M A C R O E X T E N S I O N S f o r F I J I - T O O L S - F O R - H C S =======================\n\n"); print("this is a short introduction into the usage of the MacroExtensions written for the Fiji-Tools-For-HCS"); print("you can find this macro also in your plugin folder and check it out how the code works..."); folderOfThisMacro = getDirectory("plugins") + "Scripts" + File.separator + "Plugins" + File.separator + "Fiji-Tools-for-HCS" + File.separator + "Development"; print(folderOfThisMacro); print("\nfor examples and documentation of the Java code of the MacroExtensions look here:"); print("https://imagej.nih.gov/ij/plugins/download/Image5D_Extensions.java"); print("https://github.com/jayunruh/Jay_Plugins2/blob/master/PlotWindow_Extensions_jru_v1.java"); print("\n===== test macro extensions ====="); print("to use the MacroExtensions of Fiji-Tools-For-HCS you first have to call/run the plugin..."); print("run(\"Fiji-Tools-for-HCS-plugin\");"); run("Fiji-Tools-for-HCS-plugin"); //run("Fiji-Tools-ForHCS"); print("\nnow you can make use of the MacroExtensions by calling an external function using this syntax:"); print("Ext.myCoolJavaFunction(stringParameter, numberParameter, arrayParameter);"); print("see the available functions below and check out the documentation mentioned below..."); print("\nthe version can be recorded to Log window..."); Ext.getMacroExtensionVersion(); print("\nthe functions can be listed:"); Ext.getMacroExtensionNames(); print("\nfor further help and documentation see here:"); print("https://github.com/stoeter/FijiToolsForHCSplugin/... this needs to be done"); print("\n=== saveLog ==="); outputPath = getDirectory("temp"); Ext.saveLog(outputPath + "Log_test_macro2" + "" + ".txt"); print("Log was saved..."); print("\n=== getNumberToString ==="); number = 2.5; Ext.getNumberToString(number, 3, 6); print("double number as modified string is: ", number); print("\n=== getRegexMatchesFromArray ==="); stringArrayForQuery = newArray("171020-dyes-10x_G03_T0001F005L01A01Z01C01.tif","171020-dyes-10x_G04_T0001F004L01A01Z01C02.tif","171020-dyes-10x_H05_T0001F003L01A01Z01C04.tif"); regexPattern = "(.*)_([A-P][0-9]{2})_(T[0-9]{4})(F[0-9]{3})(L[0-9]{2})(A[0-9]{2})(Z[0-9]{2})(C[0-9]{2}).tif$"; regexPattern = "(?.*)_(?[A-P][0-9]{2})_(?T[0-9]{4})(?F[0-9]{3})(?L[0-9]{2})(?A[0-9]{2})(?Z[0-9]{2})(?C[0-9]{2}).tif$"; myRegexResults = ""; Ext.getRegexMatchesFromArray(stringArrayForQuery, regexPattern, myRegexResults); print("result string contains all sets of unique regex matches separated by a -sign (\\t) (this sign is invisible in Log window!) and all sets of regex groups separated by double-pipe (||)...\n", myRegexResults); print("\nsets of regex groups can be split into an array using the (||) and the split() command from IJ-macro language..."); myRegexGroupArray = split(myRegexResults, "||"); Array.print(myRegexGroupArray); print("by definition the first array contains the named groups of the regex: " + myRegexGroupArray[0]); print("\nsets of regex matches of a single group can be further split into an array using the (\\t) and the split() command from IJ-macro language..."); myRegexWellArray = split(myRegexGroupArray[2], "\t"); Array.print(myRegexWellArray); print("here are my individual well: " + myRegexWellArray[0]); Array.show(myRegexWellArray); print("\n=== testStringArray ==="); myArray = newArray("2","3","6"); //print("doubleNumber (asString) is :",doubleNumber); Ext.testStringArray(returnString,myArray); print("string array (as one String) is: ", returnString); myNewArray = split(returnString, "\t"); print("array as strings..."); Array.print(myNewArray); Array.show(myNewArray); print("\n=== testDoubleArray ==="); returnString = "someString"; myArray = newArray(2,3.1,6.3663553); Ext.testDoubleArray(returnString,myArray); print("double array (as one String) is: ", returnString); myNewArray = split(returnString, "\t"); print("array as strings (these are not numbers get)..."); Array.print(myNewArray); for (i=0; i < myNewArray.length; ++i) { myNewArray[i] = parseFloat(myNewArray[i]); } print("array as doubles..."); Array.print(myNewArray); //function saves the log window in the given path //example: saveLog("C:\\Temp\\Log_temp.txt"); function saveLogMacroFunction(logPath) { if (nImages > 0) currentWindow = getTitle(); selectWindow("Log"); saveAs("Text", logPath); if (nImages > 0) selectWindow(currentWindow); } //function returns a number in specific string format, e.g 2.5 => 02.500 //example: myStringNumber = getNumberToString(2.5, 3, 6); function getNumberToStringMacroFunction(number, decimalPlaces, lengthNumberString) { numberString = "000000000000" + toString(number, decimalPlaces); //convert to number to string and add zeros in the front numberString = substring(numberString, lengthOf(numberString) - lengthNumberString, lengthOf(numberString)); //shorten string to lengthNumberString return numberString; }