Login  Register

Molecular Weight estimation macro malfunction

Posted by JWalker on May 19, 2014; 8:33pm
URL: http://imagej.273.s1.nabble.com/Molecular-Weight-estimation-macro-malfunction-tp5007794.html

Hello,

We have been using the following macro for some time to estimate the molecular weight of peptides which have been run on gels.
http://www.phase-hl.com/ImageJ/index.htm
(I also included the text of the macro below)

On any machine which has an updated version of ImageJ this macro is malfunctioning. I have tried to do some troubleshooting and I believe the problem lies in the getResult() function in the second macro entitled "Select Reference Bands". This function is returning NaN instead of the molecular weight. The setResult() seems to be working fine in that it is adding a column named "MW" to the results table along with the molecular weight that the user selects. But for some reason the getResult() is no longer able to read that value. Any ideas what may be causing this?

Thank you,
Jeremy



macro "Open MW File [b]"
{
open();
wait(1000);
print (getInfo());
}
//--------------------------------------------
macro "Select Reference Bands [l]"
{
run("Measure");
selectWindow("Log");
mw=split(getInfo(),'\n');
Dialog.create("Mol. Weight Select");
Dialog.addChoice("MW",mw);
Dialog.show;
setResult("MW",nResults-1,Dialog.getChoice());
updateResults();
setFont("Arial",12);
setJustification("center");
x=getResult("X",nResults-1);
y=getResult("Y",nResults-1);
drawString(getResult("MW",nResults-1),x,y);
drawLine(x,y x,y+6);

}
//-----------------------------------------
macro "Calculate Regression Line [q]"
{

if(nResults <2)
   {
     exit ("At least 2 reference bands are required!");
   }
sx=sy=sxy=sy2=sx2=0;
for (i=0;i<nResults;++i)
  {
   x=getResult('X',i);
   y=log(getResult('MW',i));
   sx=sx+x;
   sy=sy+y;
   sx2=sx2+x*x;
   sy2=sy2+y*y;
   sxy=sxy+y*x;  

   
  }
slope=(sxy-sx*sy/nResults)/(sx2-sx*sx/nResults);
intercept=sy/nResults-slope*sx/nResults;
zaehler=sxy-sx*sy/nResults;
nenner=sqrt(sy2-sy*sy/nResults)*sqrt(sx2-sx*sx/nResults);
//print ("Corr. Coeff.= "+(zaehler/nenner));
//print ("log MW= "+toString(slope)+"*distance + "+toString(intercept));
setResult("Slope",0,toString(slope));
setResult("Intercept",0,toString(intercept));
setResult("Corr.",0,(zaehler/nenner));
updateResults();
}
// ---------------------------------------
macro "Estimate unknown MW [y]"
{
run("Measure");
slope=getResult("Slope",0);
intercept=getResult("Intercept",0);
x=getResult("X",(nResults-1));
y=getResult("Y",(nResults-1));
molw=round(exp(x*slope+intercept));
setResult("MW",nResults-1,molw);
updateResults();
setFont("Arial",12);
setJustification("center");
drawString(molw,x,y);
drawLine(x,y x,y+6);
}