//run("Install...", "install=/home/standa/Plocha/New_.ijm"); var i = 0; var wd = ""; var export; var lw = 10; var lei = false; var gauss = 1.0; var delim = "_-"; var ex = "0 1 2 3"; var calibration = "Results"; var fileModel = "model"; var plotModel = false; var model = ""; var pdfModel = false; var plotWidth = 800; var plotHeight = 600; var selectData = "Results"; var selectModel = "Recently created"; var fileDistrib = "distrib"; var plotDistrib = false; var variantsBoxplot = newArray(true, false, false, false, false); var pdfDistrib = false; var sys = getInfo("os.name"); var r = "" var filtering = "filtered <- profile"; var cutOff = 0.2; var filterDistrib = true; var filterProfile = false; var filterModel = false; var filterPlot = false; var selectPlot = "Results"; var variantsPlot = newArray(true, false, false, false, false, false); var filePlot = "plot"; var pdfPlot = false; var filterChannel = newArray("GFP", "FM4", "FM4"); var filterMode = newArray("bellow", "bellow", "above"); var filterX0 = newArray("0", "0", "0"); var filterY0 = newArray("1", "1", "1"); var filterX = newArray("0", "0", "0"); var filterY = newArray("1", "1", "1"); var predFrom = -1.5; var predTo = 1.5; var predStep = 0.1; var lambdaExGFP = 0.488; var lambdaExFM4 = 0.514; var lambdaEmGFP = 0.520; var lambdaEmFM4 = 0.800; macro "Import options [f1]" { //print("Adjust an image scale and a colour mode for Leica .lei images"); do { Dialog.create("Import options"); Dialog.addCheckbox("Leica .lei images", lei); Dialog.addNumber("Gaussian blur radius (px):", gauss); Dialog.addNumber("Profile line width (px):", lw); Dialog.addMessage("Image title parsing"); Dialog.addString("Parsing delimiters", delim, 3); Dialog.addString("Exported items", ex); Dialog.addMessage("Image titles will be splited around specified characters\ninto set of items, from which the selected will be used\nas sample grouping factors."); if (matches(sys, ".*Windows.*")) { a = exec("WHERE /R \"c:\\Program Files\" R.exe"); b = split(a,"\n"); r = b[0]; Dialog.addString("Path to R.exe", r); } Dialog.show(); lei = Dialog.getCheckbox(); gauss = Dialog.getNumber(); lw = Dialog.getNumber(); delim = Dialog.getString(); ex = Dialog.getString(); export = split(ex); if (matches(sys, ".*Windows.*")) { r = Dialog.getString(); } selectImage(1); if (delim!="") { title = split(getTitle(), delim); } else { title = newArray(1); title[0] = getTitle(); } for (e=0; e < export.length; e++) if (parseInt(export[e]) < title.length) String.append(title[parseInt(export[e])]+" .. "); OK = getBoolean("Parsing example:\nSamples\n"+String.buffer+"\nwill be exported", "OK", "Back"); String.resetBuffer; } while (OK==false); run("Clear Results"); run("Line Width...", "line="+lw); for (j=1; j<=nImages; j++) { selectImage(j); if (lei==true) { // Image info collecting, developed for .lei file only p = split(getImageInfo(),'\n\n'); sti =split(getTitle()); print("Working on image ... "+sti[2]); // Searching for a line with real width value... for (k=0; k < lengthOf(p); k++) { l = split(p[k], '='); if (l[0] == sti[2]+" Dim0 physical length ") { sdim = split(l[1], ' '); realwidth = 1000000*sdim[0]; print("Real width = "+realwidth+" um"); } } sirka = getWidth(); run("Set Scale...", "distance=sirka known=realwidth pixel=1 unit=um"); } // LUTs and colour mode setting... run("Green"); run("Next Slice [>]"); run("Magenta"); run("Previous Slice [<]"); Stack.setDisplayMode("composite"); run("Gaussian Blur...", "sigma="+gauss); t = getTitle(); setResult("Title",j-1,t); if (delim!="") { title = split(t, delim); } else { title = newArray(1); title[0] = t; } for (e=0; e < export.length; e++) if (parseInt(export[e]) < title.length) setResult(e,j-1,title[export[e]]); } updateResults; IJ.renameResults("Filename parsing"); } macro "Take profile Action Tool - Cf00P0d417dadff0C0b0P0f4277a8bcff0" { takeProfile(); } macro "Take profile [x]" { takeProfile(); } function takeProfile() { k = nResults; if (delim!="") { title = split(getTitle(), delim); } else { title = newArray(1); title[0] = getTitle(); } //Get profile data getSelectionCoordinates(x, y); getPixelSize(unit, pixelWidth, pixelHeight); profileC1 = getProfile(); run("Next Slice [>]"); profileC2 = getProfile(); run("Previous Slice [<]"); //Compute length of profile x0 = x[0]*pixelWidth; x1 = x[1]*pixelWidth; y0 = y[0]*pixelHeight; y1 = y[1]*pixelHeight; length = sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)); //Obtain x-coordinate vector in microns xt = newArray(profileC1.length); for (j=0; j 0.9*max) { GFPmax = GFPmax + profileC1[n]; p++; } GFP = profileC1; for (n=0; n < profileC1.length; n++) GFP[n] = profileC1[n]/GFPmax*p; //FM4 normalisation FM4 = profileC2; for (n=0; n < profileC2.length; n++) FM4[n] = profileC2[n]/FM4maxY; for (j=0; jResults< window","From >Saved profiles< window","Single file", "All files in directory"), 4, 1, selectPlot); Dialog.addMessage("Select sample grouping factors for plotting\n(selection of non-existing levels cause error)"); Dialog.addCheckboxGroup(variantsPlot.length, 1, newArray("i","Fac_0", "Fac_1", "Fac_2", "Fac_3", "Fac_4"), variantsPlot); Dialog.addString("Output file prefix", filePlot); Dialog.addNumber("Plot width:", plotWidth, 0, 5, "px"); Dialog.addNumber("Plot height:", plotHeight, 0, 5, "px"); Dialog.addCheckbox("Pdf output?", pdfPlot); Dialog.show(); filterPlot = Dialog.getCheckbox(); selectPlot = Dialog.getRadioButton(); variants = "c("; for (n=0; nResults< window") { selectWindow("Results"); saveAs("results"); IJ.renameResults("Saved profiles"); ff = File.directory+File.name; wd = File.directory; if (matches(sys, ".*Windows.*")) { ffw=replace(ff,"\\","/"); plotting = plotting+"\nprofile <- read.profile(file=\""+ffw+"\")"; } else { plotting = plotting+"\nprofile <- read.profile(file=\""+ff+"\")"; } } if (selectPlot=="From >Saved profiles< window") { selectWindow("Saved profiles"); saveAs("results"); IJ.renameResults("Saved profiles"); ff = File.directory+File.name; wd = File.directory; if (matches(sys, ".*Windows.*")) { ffw=replace(ff,"\\","/"); plotting = plotting+"\nprofile <- read.profile(file=\""+ffw+"\")"; } else { plotting = plotting+"\nprofile <- read.profile(file=\""+ff+"\")"; } } // Filter input data if (filterPlot == true) { plotting = plotting+"\n"+filtering; } else { plotting = plotting+"\nfiltered <- profile"; } // Create plots if (matches(sys, ".*Windows.*")) { wdw=replace(wd,"\\","/"); plotting = plotting+"\npng(\""+wdw+filePlot+".png\", width="+plotWidth+", height = "+plotHeight+")\nplot(filtered, variants="+variants+")\ndev.off()"; } else { plotting = plotting+"\npng(\""+wd+filePlot+".png\", width="+plotWidth+", height = "+plotHeight+")\nplot(filtered, variants="+variants+")\ndev.off()"; } if (pdfPlot == true) { if (matches(sys, ".*Windows.*")) { wdw=replace(wd,"\\","/"); plotting = plotting+"\npdf(\""+wdw+filePlot+".pdf\", width=10, height = 8)\nplot(filtered, variants="+variants+")\ndev.off()"; } else { plotting = plotting+"\npdf(\""+wd+filePlot+".pdf\", width=10, height = 8)\nplot(filtered, variants="+variants+")\ndev.off()"; } } Rs = wd+filePlot+".R"; Ro = wd+filePlot+".Rout"; OK = getBoolean("R commands for a plot creating:\n \n"+plotting+"\n\nRuning: R "+r+" CMD BATCH "+Rs+" "+Ro+" ...", "OK", "Back"); } while (OK==false); // Generate R script File.saveString(plotting, Rs); // Running R script if (matches(sys, ".*Windows.*")) { showStatus("Runing: "+r+" CMD BATCH "+Rs+" "+Ro+" ..."); exec(r+" CMD BATCH "+Rs+" "+Ro); } else { showStatus("Runing: R CMD BATCH "+Rs+" "+Ro+" ..."); exec("R CMD BATCH "+Rs+" "+Ro); } showStatus("Finnished"); // Load R outputs run("Text File... ", "open="+Ro); open(wd+filePlot+".png"); } var prikazy = newMenu("Peripheral Protein Menu Tool", newArray("Import options [f1]", "Take profile [x]", "Profile filtering setup [f2]", "Create model [f3]", "Calculate distribution [f4]", "Plot profile data [f5]", "-", "Help [f10]")); macro "Peripheral Protein Menu Tool - C0b0T0b13PCf00T8b13M" { cmd = getArgument(); if (cmd!="-") run(cmd); }