Skip to content

Commit d52c1db

Browse files
author
cervenyj
committed
UPDATE UserDefinedProtol and help reorganized
1 parent b857a87 commit d52c1db

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

PP-GrowthOptimizer.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ var UserDefinedProtocol = {
1010
// -optimizer stability check
1111
growthStatistics: true,
1212
regressionODType: 680,
13-
regressionCoDMin: 0.75,
13+
regressionCoDMin: 75,
1414
stabilizationTimeMin: 12,
1515
stabilizationTimeMax: 36,
1616
growthRateEvalFrac: 2 / 3,
1717
analyzedSteps: 6,
18-
intervalOfConfidenceMax: 3.5,
1918
growthTrendMax: 1.5,
19+
intervalOfConfidenceMax: 3.5,
2020
// -peristaltic pump settings
2121
peristalticPumpID: 5,
2222
peristalticPumpSpeed: 100,
@@ -47,27 +47,28 @@ var UserDefinedProtocol = {
4747
* @param {number} turbidostatODMax [AU] - Maximum OD/upper bound for OD regulator/turbidostat
4848
* @param {number} turbidostatODType [680/720/735] - OD sensor used for turbidostat control
4949
* @param {number} ODReadoutInterval [s] - Defines how often is the OD measured
50-
* @param {number} peristalticPumpID [3-7] - Defines peristaltic pump ID set to the pump used for fresh media supply (quasi-continuous mode)
51-
* @param {number} peristalticPumpSpeed [%] - Nominal pump speed used for dilution of the suspension
52-
* @param {number} peristalticPumpSlowDownRange [%] - Lower range where the pump slows down
53-
* @param {number} peristalticPumpSlowDownFactor [%] - Slow down factor for the pump
54-
* @param {number} growthStatistics [true/false] - Enable or disable calculation of growth statistics. Note that the doubling time (Dt) calculation also includes information about the fit coefficient of determination (CoD in %), known as R-squared
55-
* @param {number} regressionODType [680/720/735] - OD sensor used for doubling time determination
56-
* @param {number} analyzedSteps [-] - Number of steps to be analyzed for stability check
57-
* @param {number} intervalOfConfidenceMax [%] - Maximum allowed percents of 95% Confidence Interval
58-
* @param {number} growthTrendMax [%] - Maximum growth speed trend in time
59-
* @param {number} stabilizationTimeMin [h] - Minimum duration of each characterization step
60-
* @param {number} stabilizationTimeMax [h] - Maximum duration of each characterization step
61-
* @param {number} growthRateEvalDelay [s] - Time after dilution where data for doubling time determination are ignored. By default growthRateEvalFrac, i.e. only limited fraction of the data points is used for calculations.
62-
* @param {number} growthRateEvalFrac [0-1] - Defines whether to use particular fraction of the data points for doubling time determination.
63-
* This is to prevent influence of post dilution effect on doubling time evaluation. If 0 or false, growthRateEvalDelay is used instead. Note that to completely disable data limitation you need to set both growthRateEvalFrac and growthRateEvalDelay to 0.
6450
* @param {string} controlledParameter ['none'/'temperature'/'lights'/'GMS'/'stirrer'/'ODRange'] - Supported parameters to control by the script
6551
* @param {array} controlledParameterSteps - List of values for the controlled parameter. Examples:
6652
* temperature = [ 28, 32, 34, 30, 26, 22 ]; // [oC]
6753
* lights = [[ 55, 25 ],[ 110, 25 ],[ 220, 25 ],[ 440, 25 ],[ 880,25 ]]; // [uE]
6854
* GMS = [[ 195.88, 5.873 ],[ 195.88, 12.478 ],[ 185.30, 18.257 ],[ 185.30,25.274 ]]; // [ml/min]
6955
* stirrer = [ 30, 50, 65, 80, 95 ]; // [%] !!! works only with SW version 0.7.14 and later
7056
* ODRange = [[0.4, 0.425], [0.2, 0.215], [0.1, 0.113]]; // [AU]
57+
* @param {number} growthStatistics [true/false] - Enable or disable calculation of growth statistics. Note that the doubling time (Dt) calculation also includes information about the fit coefficient of determination (CoD in %), known as R-squared
58+
* @param {number} regressionODType [680/720/735] - OD sensor used for doubling time determination
59+
* @param {number} regressionCoDMin [%] - Minimum accpeted coefficient of determination for staility check evaluation (values below are ignored)
60+
* @param {number} stabilizationTimeMin [h] - Minimum duration of each characterization step
61+
* @param {number} stabilizationTimeMax [h] - Maximum duration of each characterization step
62+
* @param {number} growthRateEvalFrac [0-1] - Defines whether to use particular fraction of the data points for doubling time determination.
63+
* @param {number} analyzedSteps [-] - Number of steps to be analyzed for stability check
64+
* @param {number} growthTrendMax [%] - Maximum growth speed trend in time
65+
* @param {number} intervalOfConfidenceMax [%] - Maximum allowed percents of 95% Confidence Interval
66+
* @param {number} peristalticPumpID [3-7] - Defines peristaltic pump ID set to the pump that is used for fresh media supply (quasi-continuous mode)
67+
* @param {number} peristalticPumpSpeed [%] - Nominal pump speed used for dilution of the suspension
68+
* @param {number} peristalticPumpSlowDownRange [%] - Lower range where the pump slows down
69+
* @param {number} peristalticPumpSlowDownFactor [%] - Slow down factor for the pump
70+
* @param {number} growthRateEvalDelay [s] - Time after dilution where data for doubling time determination are ignored. By default growthRateEvalFrac, i.e. only limited fraction of the data points is used for calculations.
71+
* This is to prevent influence of post dilution effect on doubling time evaluation. If 0 or false, growthRateEvalDelay is used instead. Note that to completely disable data limitation you need to set both growthRateEvalFrac and growthRateEvalDelay to 0.
7172
* @param {string} groupGMS - Identifies the group that contains Gas Mixing System.
7273
*
7374
* @return Flow of external/additional pump
@@ -265,7 +266,7 @@ if (!theAccessory.context().getInt('initialization', 0)) {
265266
*/
266267
function controlPump () {
267268
// Control the pump
268-
// Following ready for function
269+
// Following code ready for functional implementation
269270
// setODSensorString("turbidostat");
270271
// setODSensorString("regression");
271272
var odSensorString, odSensorRegressionString
@@ -346,7 +347,7 @@ function controlPump () {
346347
var stepDuration = theAccessory.context().get('stepDuration', 0.0)
347348
var stepDoublingTime = theAccessory.context().get('stepDoublingTime', 0.0)
348349
var stabilizedTime = theAccessory.context().getInt('stabilizedTime', 0)
349-
var stabilizedTimeMax = theAccessory.context().getInt('stabilizedTimeMax', 0)
350+
// var stabilizedTimeMax = theAccessory.context().getInt('stabilizedTimeMax', 0)
350351
if (!Array.isArray(expDuration)) {
351352
stepCounter = 0
352353
expDuration = []; stepDuration = []; stepDoublingTime = []
@@ -363,7 +364,7 @@ function controlPump () {
363364
var DHCapacity = (Math.floor(stepDuration[stepCounter] / UserDefinedProtocol.ODReadoutInterval) - 3) > 0 ? (Math.floor(stepDuration[stepCounter] / UserDefinedProtocol.ODReadoutInterval) - 3) : 60
364365
var regCoefExp = odSensorRegression.getDataHistory().regression(ETrendFunction.EXP, Math.ceil(DHCapacity - (UserDefinedProtocol.growthRateEvalFrac ? DHCapacity * (UserDefinedProtocol.growthRateEvalFrac / 100) : UserDefinedProtocol.growthRateEvalDelay / UserDefinedProtocol.ODReadoutInterval)))
365366
debugLogger('Growth parameters: ' + regCoefExp.join(', '))
366-
if (Number(regCoefExp[2]) >= UserDefinedProtocol.regressionCoDMin) {
367+
if (Number(regCoefExp[2]) >= UserDefinedProtocol.regressionCoDMin * 100) {
367368
stepDoublingTime[stepCounter] = (1 / (Number(regCoefExp[1]) * 3600 * 10)) * Math.LN2
368369
theAccessory.context().put('stepCounter', ++stepCounter)
369370
}
@@ -373,12 +374,12 @@ function controlPump () {
373374
var stepDoublingTimeSD = 0
374375
var stepDoublingTimeIC95 = 0
375376
var stepTrend = 0
376-
var stepCoD = 0
377+
// var stepCoD = 0
377378
var sumXY = 0
378379
var sumX = 0
379380
var sumY = 0
380381
var sumX2 = 0
381-
var sumY2 = 0
382+
// var sumY2 = 0
382383
// Average of steps doubling time
383384
for (var i = (stepCounter - 1); i >= (stepCounter - UserDefinedProtocol.analyzedSteps); i--) {
384385
stepDoublingTimeAvg += Number(stepDoublingTime[i])
@@ -395,11 +396,11 @@ function controlPump () {
395396
sumX += Number(expDuration[i])
396397
sumX2 += Math.pow(expDuration[i], 2)
397398
sumY += Number(stepDoublingTime[i])
398-
sumY2 += Math.pow(stepDoublingTime[i], 2)
399+
// sumY2 += Math.pow(stepDoublingTime[i], 2)
399400
sumXY += Number(expDuration[i]) * Number(stepDoublingTime[i])
400401
}
401402
stepTrend = (UserDefinedProtocol.analyzedSteps * sumXY - sumX * sumY) / (UserDefinedProtocol.analyzedSteps * sumX2 - Math.pow(sumX, 2)) * 3600
402-
stepCoD = (UserDefinedProtocol.analyzedSteps * sumXY - sumX * sumY) / (Math.sqrt((UserDefinedProtocol.analyzedSteps * sumX2 - Math.pow(sumX, 2)) * (UserDefinedProtocol.analyzedSteps * sumY2 - Math.pow(sumY, 2))))
403+
// stepCoD = (UserDefinedProtocol.analyzedSteps * sumXY - sumX * sumY) / (Math.sqrt((UserDefinedProtocol.analyzedSteps * sumX2 - Math.pow(sumX, 2)) * (UserDefinedProtocol.analyzedSteps * sumY2 - Math.pow(sumY, 2))))
403404
theExperiment.addEvent('Steps doubling time Avg: ' + round(stepDoublingTimeAvg, 2) + ' h, IC95 ' + round(stepDoublingTimeIC95, 2) + ' h (' + round(stepDoublingTimeIC95 / stepDoublingTimeAvg * 100, 1) + '%) with ' + round(stepTrend, 2) + ' h/h trend (' + round(stepTrend / stepDoublingTimeAvg * 100, 1) + '%)')
404405
// Growth stability test and parameters control
405406
if (((stepDoublingTimeIC95 / stepDoublingTimeAvg) <= (UserDefinedProtocol.intervalOfConfidenceMax / 100) && (Math.abs(stepTrend / stepDoublingTimeAvg) <= (UserDefinedProtocol.growthTrendMax / 100)) && (stabilizedTime <= Number(theExperiment.getDurationSec())))) {

0 commit comments

Comments
 (0)