/* Macros to process spectral images from the Zeiss 880. * They may also be used for spectral data from other resources where the data are a stack of images * of increasing wavelength. * * Earlier version of macros binned channels for spectral detection. This had the benefit of * reducing noise due to detectors. However, the original chemistry paper used narrower spectra * for the analysis. Therefore, these macros modified to conform to the chemistry as originally * reported by Canary lab. * * Instructions: * * Individual cells must be traced. The tracings do not need to be perfect. If all cells were isolated, * automated segmentation would work, but many cells touch. * * Original format is Zeiss CZI. When Zeiss files are opened into ImageJ, the path, where they * are located on disk, is lost. Therefore, save the file as TIF. * * Cells are traced using any polygon tool (including thresholding and magic wand) and put into the * ROI Manager using t. * * When ROI manager is populated, click on the image (image must be active) and run the macro Save ROI Manager [F7]. * This will save the ROI Manager in the same directory as the image with the same root name so they will * be grouped. * * You may add to or subtract from the ROI Manager at any time and resave. * * If working on a new image, be sure to start a new ROI Manager. There are a few ways to do this. Perhaps * the easiest is to close it. * * Later, the ROI Manager and the image can be reopened together for analysis. * * * */ /* These two values, start of wavelength sequence and width of each bin, may be entered * manually as done here or may be extracted from czi file metadata. * Macros writtend for data collected with first bin 409.50705799999997-418.415301 nm which * is a 8.908 nm step. * Previous version of this analysis binned spectral ranges for less noise, but to conform to original paper, * this version of macro uses single images in the spectral series. Therefore, these global variables may not * be used in this revision of macros. */ var startingWavelength = 409.5; // First wavelength in sequence, can be center of bin or beginning of bin. var wavelengthStep = 8.9; // Width of each bin of wavelengths collected in nm. var minThreshold = 512; // cutoff signal from background; allows for rougher cell tracing or no tracing // original version set to 1600 for whole cell method and 512 for pixel-by-pixel method /* This function steps through the ROI Manager and returns for each ROI the ratio(s) of intensities * of wavelength ranges. For instance, slices 3, 4, 5 may represent blue light with bins centered on 433, * 442, and 451 nm and these would be ratioed with red light measured in slices 17 to 25 representing light * in bins centered on wavelengths from 559 to 631 nm. In the example these macros were written for, the * peak "reference" wavelengths are at slices 8 to 12 or wavelengths 478 to 514 nm. * * Original characterization of the probe measured fluorescent intensities of 10 μM probe at 474 nm and 574 nm. * Slice #8 collected 472 to 481 nm and slice #19 570 to 579 nm. * Previous version of this analysis binned spectral ranges for less noise, but to conform to original paper, * this version of macro uses single images in the spectral series. */ macro "measure ratios from spectal image [q]" { requires("1.53d"); // macro written 20200907 in Fiji if (roiManager("count") < 1) exit("Must have ROI Manager open and populated."); // Get info for saving the results in a text file dir = getDirectory("image"); // where to save results if (lengthOf(dir) < 1) exit("Make image saved as TIFF."); titleNoExtension = getTitleStripExtension(); newName = dir + titleNoExtension + "_table.txt"; // if prefer comma delimiter to tabs, change ext to .csv run("Hyperstack to Stack"); blueInt = newArray(roiManager("count")); greenInt = newArray(roiManager("count")); redInt = newArray(roiManager("count")); redDivGreen = newArray(roiManager("count")); redDivBlue = newArray(roiManager("count")); blueDivGreen = newArray(roiManager("count")); //run("Set Measurements...", "mean limit redirect=None decimal=2"); // not needed if use getValue("Mean limit"); setThreshold(minThreshold, 65535); // so tracings may be very rough, eliminate background for (i=0; i