//LigninJ Version 1.0 //Author: Masato Nakamura, Tomoaki Kamehama, Yasushi Sato //Organization: Graduate School of Science and Engineering, Ehime University, Japan //Source: Masato Nakamura, Tomoaki Kamehama, Yasushi Sato (2020) Image analysis of stress-induced lignin deposition in Arabidopsis thaliana using the macro program LigninJ for ImageJ software. Plant Biotechnology. (https://doi.org/10.5511/plantbiotechnology.20.0110a) macro "LigninJ" { requires("1.52q"); d = getDirectory("Choose a Directory"); Dialog.create("Parameters"); Dialog.addNumber("Known distance:", 100); Dialog.addString("Unit:", "um"); Dialog.addNumber("Pixels of known distance:", 73.9); Dialog.addNumber("Lower threshold of a* :", 20); Dialog.addNumber("Lower size limits of lignified area (Unit^2) :", 20); Dialog.show(); D=Dialog.getNumber(); Unit=Dialog.getString(); P=Dialog.getNumber(); LT=Dialog.getNumber(); LS=Dialog.getNumber(); files = getFileList(d); for (i = 0; i < files.length; i++) { f = d + files[i]; doLignin(f); } function doLignin(f) { setBatchMode("hide"); open(f); run("Set Scale...", "distance=P known=D pixel=1 unit=Unit global"); rename("copy"); origBit = bitDepth; if (bitDepth() != 24) exit; //Reduce picture to 1/50 for background correction run("Averaging Reducer", "x=50 y=50"); max = 0; width = getWidth(); height = getHeight(); for (y=0; ymax) { max = value; xmax = x; ymax = y; } } } selectWindow("Reduced copy"); run("RGB Stack"); val = newArray(3); for (s=1;s<=3;s++) { setSlice(s); val[s-1] = getPixel(xmax,ymax); } run("Close"); selectWindow("copy"); run("RGB Stack"); for (s=1; s<=3; s++) { setSlice(s); dR = 255/val[s-1]; run("Multiply...","value=dR slice"); } run("Convert Stack to RGB"); rename("correct"); newpath = File.directory + File.separator + File.nameWithoutExtension+"_1.jpg"; saveAs(".jpg", newpath); run("Lab Stack"); run("Next Slice [>]"); run("Threshold..."); setThreshold(LT, 128.0000); run("Set Measurements...", "area redirect=None decimal=3"); run("Analyze Particles...", "size=LS-infenity summarize add slice"); selectWindow("correct"); newpath = File.directory + File.separator + File.nameWithoutExtension+"_2.jpg"; saveAs(".jpg", newpath); run("Set Measurements...", "area mean redirect=None decimal=3"); if (roiManager("count") > 0) { roiManager("Multi Measure append"); roiManager("Delete"); } else { makeRectangle(1,1,1,1); roiManager("add"); run("Set Measurements...", "area redirect=None decimal=3"); roiManager("Multi Measure append"); roiManager("Delete"); } run("Close All"); selectWindow("Threshold"); run("Close"); } selectWindow("Summary of correct"); newpath = File.directory + File.separator + "Summary.csv"; saveAs("results", newpath); run("Close"); selectWindow("Results"); newpath = File.directory + File.separator + "Results.csv"; saveAs("results", newpath); run("Close"); }