// Single Panel Gel Analyzer
//
// This macro uses the Plot functions and the Roi Manager to 
// plot multiple gel lanes in a single window. Just add the line
// selections (lanes) to plot to the ROI Manager and all lanes will 
// be plotted in a single plot window. A results table is also produced 
// with values for all lanes. It does this because the 'List' button in the
// Plot windows only lists values for the first series added to the Plot.

  macro "Load demo data" {
     // loads demo gel image 
     // and creates some line ROIs to be plot.
     run("Gel (105K)");
     roiManager("Reset");
     makeLine(31, 24, 32, 370); roiManager("Add");
     makeLine(78, 24, 79, 370); roiManager("Add"); 
     makeLine(125, 24, 126, 370); roiManager("Add");
     makeLine(166, 24, 167, 370); roiManager("Add");
     makeLine(209, 24, 210, 370); roiManager("Add");
     makeLine(252, 24, 253, 370); roiManager("Add"); 
     run("Select None");
     setOption("Show All",true);
  }

  macro "Single Panel Gel Analyser" {
     if (isOpen("Results")) {
        showMessageWithCancel("Result table will be closed\nis that OK ?"); 
        selectWindow("Results"); run("Close");
     }
     if (roiManager("count")==0)
        exit("The ROI Manager has no line selections");
     roiManager("select",0); 
     values =getProfile();  
     colors = newArray("black","blue","green","red",
        "gray","cyan","lightGray","magenta","orange","pink",
        "darkGray","yellow");
     Plot.create("Single Panel Gel Analyser","pixels",""); 
     Plot.setLimits (0, values.length,0,256);
     nroi = roiManager("count");
     for (i=0; i<nroi; i++) {
        roiManager("select",i);
        values =getProfile();
        Plot.setColor (colors[i%colors.length]);
        Plot.add("line", values);
        Plot.addText("L"+i,-0.1,0.05+i*0.08);
        for (j=0; j<values.length; j++)
           setResult("Lane"+i, j, values[j]);
     }
     run("Select None");
     Plot.show();
     updateResults();
  }



        setKeyDown("alt"); // assume vertical lane
        values = getProfile();
    Plot.create("Single Panel Gel Analyser","pixels","", values); 

setKeyDown("alt"); // assume vertical lane
yValues = getProfile();
valuesLength = lengthOf (yValues);
Plot.create("fluorescence Correlation", "X", "Y",yValues);
Plot.setLimits(0, valuesLength, 0, 255);



