v1.0 ReCALIBRATION: Relative Chlorophyll (SPAD)


This performes a standard blank at 3 different simulated leaf thicknesses, and also calibrates each thickness to a known SPAD value from a Minolta SPAD meter. When you have multiple SPAD devices involved in a single project, you can use this protocol to ensure that all devices are calibrated together. MultispeQs have some natural variation in the SPAD value between devices, and this reduces that variation by calibrating them all against a common standard.
//============================================
// Macro for blank and spad calibration, Greg Austic
// created: 2/24/2015
//============================================
    
// blank1/2/3 represent the blanks for 3 leaf thicknesses (lowest to highest).  spad_cal1/2/3 is the calibration to a known Minolta SPAD meter value for each of those thicknesses in the form y = mx+b where the two saved values in the array are x and b.


var output = {};
var spad;
var sample_940 = [];
var sample_650 = [];
var spad1 = [];
var spad2 = [];
var spad3 = [];
var blank1 = [];
var blank2 = [];
var blank3 = [];
var spad_cal1 = [];
var spad_cal2 = [];
var spad_cal3 = [];
var minolta_spad = [];
var minolta_spad1 = [];
var minolta_spad2 = [];
var minolta_spad3 = [];
var message = json.message;
var nine40_temp = [];
var six50_temp = [];


// pull and average the calibration values for 940 and 650 LEDs from the trace
for (x=0;x<9;x++) {
	var temp_940 = MathROUND(MathMEAN(json.data_raw.slice(2+20*x,8+20*x)),0);
    sample_940.push(temp_940);  
	var temp_650 = MathROUND(MathMEAN(json.data_raw.slice(12+20*x,18+20*x)),0);
    sample_650.push(temp_650);  
  	}

// calculate all of the spad values from each of the Minolta SPAD calibrations (3 calibrations for each leaf thickness, 3 points per calibration)
for (x=0;x<3;x++) {
	var spad1_temp= MathLOG((sample_940[x] / json.recall["colorcal_blank1[6]"]) / (sample_650[x] / json.recall["colorcal_blank1[2]"]))*100;
	var spad2_temp= MathLOG((sample_940[x+3] / json.recall["colorcal_blank2[6]"]) / (sample_650[x+3] / json.recall["colorcal_blank2[2]"]))*100;
	var spad3_temp= MathLOG((sample_940[x+6] / json.recall["colorcal_blank3[6]"]) / (sample_650[x+6] / json.recall["colorcal_blank3[2]"]))*100;
    spad1.push(MathROUND(spad1_temp,1));
    spad2.push(MathROUND(spad2_temp,1));
    spad3.push(MathROUND(spad3_temp,1));
  
}

/*
output ["spad1"] = (spad1);
output ["spad2"] = (spad2);
output ["spad3"] = (spad3);
*/

// Pull out the actual Minolta numbers from the user inputted message
// If left blank, then use factory SPAD calibration sheet values.
// 8, 17.4, 31.2, 24.4, 38.8, 47.7, 25.8, 48.6, 72
// old - 6.1, 16.9, 32.8, 25.1, 38.8, 46.3, 20.6, 43.1, 72
// factory calibrations last updated 10/10/16
minolta_spad_factory = [8, 17.4, 31.2, 24.4, 38.8, 47.7, 25.8, 48.6, 72];

for (var x = 0; x < message.length; x=x+2)

{
  if (Number(message[x][2]) == "") {
    minolta_spad.push(minolta_spad_factory[Math.floor(x/2)]);
   warning('Make Sure to Enter in SPAD Values',output);
  }
  else {
    minolta_spad.push(Number(message[x][2]));
  }
}


output ["minolta spad"] = minolta_spad;

/*
output ["allspad"] = minolta_spad+"+";
output ["allspad1"] = spad1+"+";
output ["allspad2"] = spad2+"+";
output ["allspad3"] = spad3+"+";
*/

//output ["minolta1"] = (minolta_spad);
// run regressions on PhotosynQ SPAD versus Minolta SPAD
var reg1 = MathLINREG(minolta_spad.slice(0,3),spad1);
var reg2 = MathLINREG(minolta_spad.slice(3,6),spad2);
var reg3 = MathLINREG(minolta_spad.slice(6,9),spad3);

// Now perform the regression to get y = mx + b for each leaf thickness

/*
output ["sample 940"] = sample_940;
output ["sample 650"] = sample_650;
output ["blank1"] = blank1;
output ["blank2"] = blank2;
output ["blank3"] = blank3;
output ["spad1"] = spad1;
output ["spad2"] = spad2;
output ["spad3"] = spad3;
output ["minolta_spad"]  = minolta_spad;
output ["minolta_spad1"] = minolta_spad1;
output ["minolta_spad2"] = minolta_spad2;
output ["minolta_spad3"] = minolta_spad3;
*/
output ["colorcal_blank1[6]"] = json.recall["colorcal_blank1[6]"];
output ["colorcal_blank2[6]"] = json.recall["colorcal_blank2[6]"];
output ["colorcal_blank3[6]"] = json.recall["colorcal_blank3[6]"];
output ["colorcal_blank1[2]"] = json.recall["colorcal_blank1[2]"];
output ["colorcal_blank2[2]"] = json.recall["colorcal_blank2[2]"];
output ["colorcal_blank3[2]"] = json.recall["colorcal_blank3[2]"];
output ["spad1_m"] = MathROUND(reg1.m);
output ["spad1_b"] = MathROUND(reg1.b);
output ["spad1 r2"] = MathROUND(reg1.r);
output ["spad2_m"] = MathROUND(reg2.m);
output ["spad2_b"] = MathROUND(reg2.b);
output ["spad2 r2"] = MathROUND(reg2.r);
output ["spad3_m"] = MathROUND(reg3.m);
output ["spad3_b"] = MathROUND(reg3.b);
output ["spad3 r2"] = MathROUND(reg3.r);

output ["toDevice"] = "set_colorcal1+2+";
output ["toDevice"] += Number(MathROUND(reg1.m, 3));
output ["toDevice"] += "+";
output ["toDevice"] += Number(MathROUND(reg1.b, 1));
output ["toDevice"] += "+-1+";
output ["toDevice"] += "set_colorcal2+2+";
output ["toDevice"] += Number(MathROUND(reg2.m, 3));
output ["toDevice"] += "+";
output ["toDevice"] += Number(MathROUND(reg2.b, 1));
output ["toDevice"] += "+-1+";
output ["toDevice"] += "set_colorcal3+2+";
output ["toDevice"] += Number(MathROUND(reg3.m, 3));
output ["toDevice"] += "+";
output ["toDevice"] += Number(MathROUND(reg3.b, 1));
output ["toDevice"] += "+-1+";

/*
output ["toDevice"] += "+";
output ["toDevice"] += "1022+";
output ["toDevice"] += blank1[0]+"+"+blank1[1];
output ["toDevice"] += "+";
output ["toDevice"] += "1023+";
output ["toDevice"] += blank2[0]+"+"+blank2[1];
output ["toDevice"] += "+";
output ["toDevice"] += "1024+";
output ["toDevice"] += blank3[0]+"+"+blank3[1];
output ["toDevice"] += "+";
output ["toDevice"] += "-1+";

*/

output ["order"] = ["spad1 r2","spad2 r2","spad3 r2"];

return output;
{
  "time_offset": 240,
  "time": 1471460394992,
  "device_version": "1",
  "device_id": "d4:f5:10:14:06:65",
  "device_battery": 84,
  "device_firmware": "1.06",
  "firmware_version": "1.06",
  "device_time": 1471442414,
  "sample": [
    [
      {
        "time": 1471460395009,
        "protocol_id": 1,
        "message": [
          [
            "prompt",
            "Clamp tile 3 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 4 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 5 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 6 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 7 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 8 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 9 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 10 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ],
          [
            "prompt",
            "Clamp tile 11 and enter Minolta SPAD value",
            ""
          ],
          [
            "0",
            "0",
            ""
          ]
        ],
        "recall": {
          "time": 1471460434149,
          "colorcal_blank1[2]": 12927,
          "colorcal_blank2[2]": 15096,
          "colorcal_blank3[2]": 10041,
          "colorcal_blank1[6]": 26263.5,
          "colorcal_blank2[6]": 35288,
          "colorcal_blank3[6]": 30774
        },
        "data_raw": [
          4136,
          4133,
          4134,
          4134,
          4137,
          4135,
          4135,
          4135,
          4132,
          4139,
          1219,
          1217,
          1217,
          1217,
          1217,
          1213,
          1215,
          1215,
          1214,
          1218,
          3832,
          3828,
          3832,
          3827,
          3831,
          3829,
          3835,
          3834,
          3836,
          3829,
          613,
          611,
          609,
          611,
          608,
          612,
          611,
          611,
          611,
          613,
          3981,
          3982,
          3985,
          3978,
          3982,
          3983,
          3974,
          3985,
          3985,
          3984,
          257,
          257,
          260,
          257,
          255,
          260,
          255,
          256,
          259,
          255,
          33296,
          33303,
          33296,
          33295,
          33301,
          33302,
          33304,
          33296,
          33309,
          33300,
          3159,
          3157,
          3161,
          3160,
          3161,
          3158,
          3163,
          3159,
          3159,
          3157,
          34374,
          34378,
          34380,
          34382,
          34382,
          34375,
          34381,
          34386,
          34381,
          34379,
          1570,
          1574,
          1574,
          1571,
          1573,
          1570,
          1574,
          1574,
          1572,
          1572,
          25186,
          25187,
          25188,
          25189,
          25183,
          25187,
          25179,
          25185,
          25189,
          25188,
          818,
          818,
          818,
          814,
          819,
          821,
          820,
          819,
          816,
          818,
          44083,
          44089,
          44093,
          44093,
          44093,
          44090,
          44087,
          44094,
          44083,
          44082,
          6051,
          6056,
          6055,
          6055,
          6053,
          6050,
          6051,
          6049,
          6051,
          6046,
          43346,
          43346,
          43347,
          43343,
          43341,
          43349,
          43350,
          43349,
          43352,
          43354,
          2171,
          2172,
          2169,
          2167,
          2169,
          2166,
          2165,
          2167,
          2167,
          2167,
          41438,
          41440,
          41444,
          41442,
          41440,
          41440,
          41441,
          41437,
          41441,
          41443,
          957,
          959,
          957,
          957,
          957,
          958,
          959,
          960,
          961,
          958
        ]
      }
    ]
  ],
  "app_os": "linux",
  "app_name": "PhotosynQ",
  "app_version": "0.3.4",
  "app_device": "x86-64",
  "location": [
    "42.7225781",
    "-84.4746662"
  ]
}
Default avatar
Created by

Sean


Protocol connections:
1
Latest Update:
Jan 2017