/** * MRI MS2 QUANT PRE-PROCESSING * * Do the preprocessing for MS2Quant * - concatenate stacks * - measure and report the mean intensity in a 3D background region * - crop 4D cells and save them in separate files * - allow to outline and save transcription sites, nuclei and control regions as input to ms2quant * * written 2013 by Volker Baecker (INSERM) at Montpellier RIO Imaging (www.mri.cnrs.fr) */ var _SLICES = 12; var _FRAMES = 304; var sourceDir = ""; var _COUNTER = 0; var _CELL_FOLDER; var _CELL_NAME; var _ENHANCE_CONTRAST = 1; var _MARK = "PST"; var helpURL = "http://dev.mri.cnrs.fr/projects/imagej-macros/wiki/MS2Quant_Pre-Processing"; macro "run tests [f12]" { runTests(); } macro "MS2 Quant PP Help [f1]" { showHelp(); } macro "MS2 Quant PP concatenate stacks [f2]" { ms2quantPPConcatenateStacks(); } macro "MS2 Quant PP measure background [f3]" { ms2quantPPMeasureMeanBackground(); } macro "MS2 Quant PP crop and save cell [f4]" { ms2quantPPCropAndSave(); } macro "MS2 Quant PP add selection [f5]" { ms2quantPPAddRoi(); } macro "Unused Tool - C037" { } macro "MS2 Quant PP Help (f1) Action Tool - C037T0d08MT8d08STed082"{ showHelp(); } macro 'MS2 Quant PP Help (f1) Action Tool Options...' { Dialog.create("MS2QuantPP Options"); Dialog.addNumber("z-slices: ", _SLICES); Dialog.addNumber("time-frames: ", _FRAMES); Dialog.addNumber("enhance contrast (%saturated): ", _ENHANCE_CONTRAST); Dialog.addString("mark: ", _MARK); Dialog.show(); _SLICES = Dialog.getNumber(); _FRAMES = Dialog.getNumber(); _ENHANCE_CONTRAST = Dialog.getNumber(); _MARK = Dialog.getString(); } macro "concatenate stacks (f2) Action Tool - C037T0d14cTad14s" { ms2quantPPConcatenateStacks(); } macro "measure background (f3) Action Tool - C037T0d14mTcd14b" { ms2quantPPMeasureMeanBackground(); } macro "crop and save cell (f4) Action Tool - C037T0d09cT5d09rT8d09oTdd09p" { ms2quantPPCropAndSave(); } macro "add selection (f5) Action Tool - C037T0d09+T6d09rTad09oTfd09i" { ms2quantPPAddRoi(); } function showHelp() { run('URL...', 'url='+helpURL); } function ms2quantPPAddRoi() { count = roiManager("count"); if (count==3) roiManager("reset"); count = roiManager("count"); name = "T"; if (count == 1) name = "N"; if (count == 2) name = "C"; roiManager("Add"); roiManager("Deselect"); roiManager("Show None"); roiManager("Show All"); run("Select None"); roiManager("Select", count); roiManager("Rename", name); roiManager("Deselect"); roiManager("Show None"); roiManager("Show All"); if (count == 2) { roiManager("Save", _CELL_FOLDER + "/RoiSet.zip"); title = _CELL_NAME + ".tif"; selectImage(title); close(); selectImage("MAX_"+title); close(); selectImage("MAX_MAX_"+title); close(); run("Add Selection..."); } } function ms2quantPPCropAndSave() { sourceDir = getDirectory("image"); title = getTitle(); parts = split(title, "."); cellNumber = getCellNumber(sourceDir, parts[0]); _CELL_NAME = parts[0] + "_c" + cellNumber; newTitle = _CELL_NAME + ".tif"; run("Duplicate...", "title="+newTitle+" duplicate range=1-" + nSlices); if (!File.exists(sourceDir + newTitle)) File.makeDirectory(sourceDir + _CELL_NAME); _CELL_FOLDER = sourceDir + _CELL_NAME; run("Remove Overlay"); save(_CELL_FOLDER + "/" + newTitle); showHyperstackAndProjections(); roiManager("Reset"); } function showHyperstackAndProjections() { run("Stack to Hyperstack...", "order=xyczt(default) channels=1 slices="+_SLICES+" frames="+_FRAMES+" display=Color"); run("Enhance Contrast", "saturated=" + _ENHANCE_CONTRAST); getDimensions(width, height, channels, slices, frames); run("Z Project...", "start=1 stop="+slices+" projection=[Max Intensity] all"); run("Enhance Contrast", "saturated=" + _ENHANCE_CONTRAST); run("Z Project...", "start=1 stop="+frames+" projection=[Max Intensity]"); run("Enhance Contrast", "saturated=" + _ENHANCE_CONTRAST); run("Tile"); setTool("freehand"); } function ms2quantPPMeasureMeanBackground() { setBatchMode(true); sourceDir = getDirectory("Choose the source directory"); files = getFileList(sourceDir); images = filterTifFiles(files); _COUNTER = 0 logStart("MEASURE BACKGROUND"); for(i=0; i