function get($name, $dbconn, $params = []) { switch ($name) { case 'all_countries': $out = all_countries($dbconn); return $out; case 'all_configurations': $out = all_configurations($dbconn); return $out; case 'mean': $out = mean($dbconn, $params); return $out; case 'country_means': $out = country_means($dbconn, $params); return $out; case 'country_data': $out = country_data($dbconn, $params); return $out; case 'prime_ministers': $out = prime_ministers($dbconn, $params); return $out; case 'years': $out = years($dbconn, $params); return $out; } return []; }
function standard_deviation_population($b) { //variable and initializations $the_standard_deviation = 0.0; $the_variance = 0.0; $the_mean = 0.0; $number_elements = count($b); //count the number of elements //calculate the mean $the_mean = mean($b); //calculate the variance for ($i = 0; $i < $number_elements; $i++) { //sum the array $the_variance = $the_variance + ($b[$i] - $the_mean) * ($b[$i] - $the_mean); } if ($number_elements > 0) { $the_variance = $the_variance / $number_elements; } else { $the_variance = 0; } //calculate the standard deviation $the_standard_deviation = pow($the_variance, 0.5); //return the variance return $the_standard_deviation; }
function variance($a) { $v = 0; $mean = mean($a); foreach ($a as $x) { $v += pow($x - $mean, 2); } return $v / (count($a) - 1); }
function stdev($samples, $m = null) { if ($m == null) { $m = mean($samples); } return sqrt(array_sum(array_map(function ($x) use($m) { $t = $x - $m; return $t * $t; }, $samples)) / count($samples) - 1); }
function variance($values) { $mean = mean($values); $num = count($values); $x = 0; foreach ($values as $value) { $diff = $value - $mean; $x += $diff * $diff; } $variance = $x / $num; return $variance; }
function normalized_variance($x) { $sum = 0; $n = count($x); $m = mean($x); for ($i = 0; $i < $n; $i++) { $d = $x[$i] - $m; $sum += $d * $d; //echo "$x[$i] "; } //echo "\n"; $nv = sqrt($sum) / ($n * $m); //echo "nresults $n mean $m sum $sum nv $nv\n"; return $nv; }
public static function timeop($opname, $time_function) { // Pick sample size, results normalized against median function call cost $run_count = 10; // Run operation a few times before starting timer $result = $time_function(20); echo "\n{$opname} result = {$result}"; // Record time $time = array(); for ($iter = 0; $iter < $run_count; $iter++) { $start_time = microtime(true); $result = $time_function(10000); $end_time = microtime(true); if ($iter == 0) { echo "\n{$opname} result = {$result}"; } $time[$iter] = ($end_time - $start_time) * 1000; } // Compute stats $max = max($time); $min = min($time); $mean = mean($time); $median = median($time); $std_dev = std_dev($time); // Confidence in results TimeHHOperations::$operationsCount++; if ($max > 10 * $min || $std_dev / $mean > 0.1) { TimeHHOperations::$lowconfidenceCount++; } if ($opname == 'function_call') { TimeHHOperations::$nmedian = $median; } // Print stats echo "\nCPU cost normalized against median function call cost"; echo "\n-----------------------------------------------------"; echo "\n{$opname} max = ", $max / TimeHHOperations::$nmedian; echo "\n{$opname} min = ", $min / TimeHHOperations::$nmedian; echo "\n{$opname} mean = ", $mean / TimeHHOperations::$nmedian; echo "\n{$opname} median = ", $median / TimeHHOperations::$nmedian; echo "\n{$opname} std. dev = {$std_dev}"; echo "\n{$opname} time measurement complete. Run count = {$run_count}."; echo "\n"; // Write stats to csv file fputcsv(TimeHhOperations::$file, array($opname, $max / TimeHHOperations::$nmedian, $min / TimeHHOperations::$nmedian, $mean / TimeHHOperations::$nmedian, $median / TimeHHOperations::$nmedian)); }
{ $sum = 0; // Инициализация для подавления предупреждений echo "count of arguments: " . ($size = func_num_args() . "<br>"); //определение //числа переданных перменных // Перебор массива и суммирование чисел for ($i = 0; $i < $size; $i++) { $sum += func_get_arg($i); } $average = $sum / $size; // Деление на количество слагаемых return $average; // Функция возвращает среднее арифметическое } echo "mean val of 96, 93, 98 and 98 is: " . mean(96, 93, 98, 98) . "<br>"; // возвращение значения по ссылке echo "<h4> return by reference </h4>"; function &rByRef(&$arg) { return ++$arg; } $a = 5; echo "\$a = {$a} <br>"; $b =& rByRef($a); //$b ссылается на $a echo "\$b = {$b} <br>"; $b++; //изменение $b затрагивает $a echo "\$a = {$a} <br>"; echo "\$b = {$b} <br>";
public function predict($input_data, $path = null, $missing_strategy = Tree::LAST_PREDICTION) { /* Makes a prediction based on a number of field values. The input fields must be keyed by Id. There are two possible strategies to predict when the value for the splitting field is missing: 0 - LAST_PREDICTION: the last issued prediction is returned. 1 - PROPORTIONAL: as we cannot choose between the two branches in the tree that stem from this split, we consider both. The algorithm goes on until the final leaves are reached and all their predictions are used to decide the final prediction. */ if ($path == null) { $path = array(); } if ($missing_strategy == Tree::PROPORTIONAL) { $predict_pro = $this->predict_proportional($input_data, $path); $final_distribution = $predict_pro[0]; $d_min = $predict_pro[1]; $d_max = $predict_pro[2]; $last_node = $predict_pro[3]; $distribution = array(); if ($this->regression) { // singular case // when the prediction is the one given in a 1-instance node if (count($final_distribution) == 1) { foreach ($final_distribution as $prediction => $instances) { if ($instances == 1) { return new Prediction($last_node->output, $path, $last_node->confidence, $last_node->distribution, $instances, $last_node->distribution_unit, $last_node->median, $last_node->children, $last_node->min, $last_node->max); } break; } } ksort($final_distribution); foreach ($final_distribution as $key => $val) { array_push($distribution, array(floatval($key), $val)); } $distribution_unit = 'counts'; if (count($distribution) > Tree::BINS_LIMIT) { $distribution_unit = 'bins'; } $distribution = merge_bins($distribution, Tree::BINS_LIMIT); $prediction = mean($distribution); $total_instances = 0; foreach ($distribution as $key => $val) { $total_instances += $val[1]; } $confidence = regression_error(unbiased_sample_variance($distribution, $prediction), $total_instances); return new Prediction($prediction, $path, $confidence, $distribution, $total_instances, $distribution_unit, dist_median($distribution, $total_instances), $last_node->children, $d_min, $d_max); } else { ksort($final_distribution); $distribution = array(); foreach ($final_distribution as $key => $val) { array_push($distribution, array($key, $val)); } return new Prediction($distribution[0][0], $path, ws_confidence($distribution[0][0], $final_distribution), $distribution, get_instances($distribution), 'categorial', null, $last_node->children, null, null); } } else { if ($this->children != null) { #&& array_key_exists(splitChildren($this->children), $input_data) ) { foreach ($this->children as $child) { if ($child->predicate->apply($input_data, $this->fields)) { $new_rule = $child->predicate->to_rule($this->fields); array_push($path, $new_rule); return $child->predict($input_data, $path); } } } return new Prediction($this->output, $path, $this->confidence, $this->distribution, get_instances($this->distribution), $this->distribution_unit, $this->regression == null ? null : $this->median, $this->children, $this->regression == null ? null : $this->min, $this->regression == null ? null : $this->max); } }
public function colourCalibrate($colours, $expand = 25, $SD = 2) { // $colours lists x-coordinate, y-coordinate, and L, a* and b* values for each colour on the checker chart // $expand = number of pixels plus or minus the reference x and y-corrdinates // $SD = exclude pixels more than $sd standard deviations from the mean for that area if (!imageistruecolor($this->_image)) { return false; } $w = $this->getWidth(); $h = $this->getHeight(); $rgb255 = array(); foreach ($colours as $cname => $c) { // get color from x and y coordinates $imgcolor = array(); for ($x = $c[0] - $expand; $x <= $c[0] + $expand; $x++) { for ($y = $c[1] - $expand; $y <= $c[1] + $expand; $y++) { $rgb = imagecolorat($this->_image, $x, $y); $imgcolor['r'][] = $rgb >> 16 & 0xff; $imgcolor['g'][] = $rgb >> 8 & 0xff; $imgcolor['b'][] = $rgb & 0xff; } } foreach ($imgcolor as $rgb => $valuearray) { $mode = mode($valuearray, 0.25); $stdev = stdev($valuearray); foreach ($valuearray as $i => $v) { if ($v > $mode + $SD * $stdev || $v < $mode - $SD * $stdev) { // remove from list unset($valuearray[$i]); } } $averages[$rgb] = round(mean($valuearray), 12); $stdevs[$rgb] = round(stdev($valuearray), 4); $counts[$rgb] = count($valuearray); } $rgb255[] = $averages; $lab = rgb2lab($averages['r'], $averages['g'], $averages['b']); $deltaE = deltaE($lab, array($c[2], $c[3], $c[4])); $check[$cname] = sprintf("Lab(%.1f, %.1f, %.1f)\n", round($lab['L'], 1), round($lab['a'], 1), round($lab['b'], 1)); /* $check .= "--myLab: (" . implode(',', $lab['lab']) . ")\n"; $check .= "--chartLab: ($c[2], $c[3], $c[4])\n"; $check .= "--deltaE = $deltaE\n"; $check .= "--RGB: (" . implode(',', $averages) . ")\n"; $check .= "--SD: (" . implode(',', $stdevs) . ")\n"; $check .= "--N: (" . implode(',', $counts) . ")\n"; */ if (!is_nan($deltaE)) { $deltaEs[] = $deltaE; } } $meanDeltaE = round(mean($deltaEs), 4); $maxDeltaE = round(max($deltaEs), 4); $patch = $expand * 2 + 1; $this->setDescription(array("colour calibrate" => array("path dimension" => "{$patch} x {$patch}", "SD" => $SD, "deltaE" => array("M" => $meanDeltaE, "max" => $maxDelta), "check" => $check))); /* MATLAB code ************************************ % Calculate camera Characterisation - Least Squares fit of rgb to Lab patches: rgb = Rgb_vals/255; for i = 1:length(rgb) train(i,:) = rgb2rgbpoly(rgb(i,:),11); end R=train\spectrod65; % Calculate predicted lab values from characterisation lab_calc = train*R; squaredDifference = (lab_calc-spectrod65).^2; meanDeltaE = mean(sqrt(sum(squaredDifference'))) maxDeltaE = max(sqrt(sum(squaredDifference'))) **************************************************/ include_once "Math/Matrix.php"; foreach ($colours as $v) { $spectrod65[] = array($v[2], $v[3], $v[4]); } foreach ($rgb255 as $i => $v) { foreach ($v as $j => $c) { $rgb1[$i][] = $c / 255; } } foreach ($rgb1 as $v) { $train[] = rgb2rgbpoly($v, 11); } $rgbM = new Math_Matrix($rgb1); $trainM = new Math_matrix($train); return $this; }
<?php // find the "average" of a group of numbers function mean($numbers) { // initialize to avoid warnings $sum = 0; // the number of elements in the array $size = count($numbers); // iterate through the array and add up the numbers for ($i = 0; $i < $size; $i++) { $sum += $numbers[$i]; } // divide by the amount of numbers $average = $sum / $size; // return average return $average; } // $mean is 96.25 $mean = mean(array(96, 93, 98, 98));
break; case 2: $ind[$i][] = $row->indikator_3; break; case 3: $ind[$i][] = $row->indikator_4; break; } } } $i += 1; } /*menghitung rata-rata */ $average_pegawai = mean($a); $average_barang = mean($b); $average_modal = mean($c); /*menghitung standar deviasi */ $standard_deviation_pegawai = standard_deviation_population($a); $standard_deviation_barang = standard_deviation_population($b); $standard_deviation_modal = standard_deviation_population($c); } //while $dataX = $ind; $dataY = $tot; $M = new matrix($dataX); $X = $M->ArrayData; $M = new matrix($dataY); $Y = $M->ArrayData; $Xt = $M->Transpose($X); $XtX = $M->MultiplyMatrix($Xt, $X); $XtY = $M->MultiplyMatrix($Xt, $Y);
function coefficient_of_variation($arr) { return std($arr) / mean($arr) * 100; }
/** * Calculate covariance. * * @param array $x_values Dependent variable values. * @param array $y_values Independent variable values. * @return string Covariance of x and y. */ function covariance(array $x_values, array $y_values) { $l = bcdiv(sumxy($x_values, $y_values), math_count($x_values)); $r = bcmul(mean($x_values), mean($y_values)); return bcsub($l, $r); #return sumxy($x_values, $y_values)/math_count($x_values) - mean($x_values)*mean($y_values); }
function getTopDeviations($account = null, $count = null) { $pcount = $count; $qcount = tryGET('count'); $vcount = 10; if (isset($pcount)) { $vcount = $pcount; } else { if (isset($qcount)) { $vcount = $qcount; } } if ($vcount > 100) { $vcount = 100; } $settings = getSettings(); if (!isset($account)) { $account = $settings["Account"]; } $start = tryGET('start'); $end = tryGET('end'); if (!isset($start) || !isset($end)) { return null; } $ndays = getDays($start, $end); $start = GoogleDate($start); $end = GoogleDate($end); $analytics = getAnalytics(); $filter = ""; //More than 1 pageview an hour to cut down on outliers and processing $dims = "ga:hostname,ga:pagePath,ga:date"; $metric = "ga:pageviews"; $sort = "-ga:pageviews"; $count = 10000; //max $data = runQuery($analytics, $account, $start, $end, $metric, $dims, $sort, $count, $filter); if (isset($data->ga_error)) { return DoNotCache(); } $data = $data->getRows(); $values = array(); $path = ''; $tvals = array(); foreach ($data as $key => $row) { if (!isset($values[$row[0] . $row[1]])) { $values[$row[0] . $row[1]] = array(); } array_push($values[$row[0] . $row[1]], floatval($row[3])); } foreach ($values as $key => $val) { $rem = $ndays - count($val); for ($i = 0; $i < $rem; $i++) { array_push($val, 0); } $mean = mean($val); if ($mean < 1) { continue; } //Aviod super low page averages $sd = stdev($mean, $val); if ($sd == 0) { continue; } //Let's not deal with how this is even possible for right now $stdevs[$key] = array('mean' => $mean, 'stdev' => $sd, 'values' => $val); } $count = 100 * $vcount; $filter = ""; $dims = "ga:date,ga:hour,ga:hostname,ga:pagePath,ga:pageTitle"; $metric = "ga:pageviews"; $sort = "-ga:pageviews"; $data = runQuery($analytics, $account, $start, $end, $metric, $dims, $sort, $count, $filter); if (isset($data->ga_error)) { return DoNotCache(); } $data = $data->getRows(); $result = array(); foreach ($data as $key => $row) { $path = $row[2] . $row[3]; if (!isset($stdevs[$path])) { continue; } //if($sd['mean'] <= 0) continue; $sd = $stdevs[$path]; $z = zscore($sd['stdev'], $sd['mean'], $row[5]); $y = substr($row[0], 0, 4); $m = substr($row[0], 4, 2); $d = substr($row[0], 6, 2); $time = "{$y}-{$m}-{$d} " . $row[1] . ":00"; $ts = strtotime($time); $result[] = array('path' => $path, 'title' => $row[4], 'mean' => $sd['mean'], 'stdev' => $sd['stdev'], 'pageviews' => $row[5], 'z' => $z, 'timestamp' => $ts, "time" => $time, "values" => $sd['values']); } usort($result, "zsort"); $ret = array_splice($result, 0, $vcount); return $ret; }
<?php // find the "average" of a group of numbers function mean() { // initialize to avoid warnings $sum = 0; // the arguments passed to the function $size = func_num_args(); // iterate through the arguments and add up the numbers foreach (func_get_args() as $arg) { $sum += $arg; } // divide by the amount of numbers $average = $sum / $size; // return average return $average; } // $mean is 96.25 $mean = mean(96, 93, 98, 98);
function DisplayPipelineForm($type, $id) { if ($id == "" && $type == "edit") { ?> <div class="error"><b>Error</b> - pipeline ID blank</div><?php return; } $level = 0; /* populate the fields if this is an edit */ if ($type == "edit") { $sqlstring = "select a.*, b.username from pipelines a left join users b on a.pipeline_admin = b.user_id where a.pipeline_id = {$id}"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $title = $row['pipeline_name']; $pipeline_status = $row['pipeline_status']; $pipeline_statusmessage = $row['pipeline_statusmessage']; $pipeline_laststart = $row['pipeline_laststart']; $pipeline_lastfinish = $row['pipeline_lastfinish']; $pipeline_lastcheck = $row['pipeline_lastcheck']; $desc = $row['pipeline_desc']; $numproc = $row['pipeline_numproc']; $submithost = $row['pipeline_submithost']; $queue = $row['pipeline_queue']; $remove = $row['pipeline_removedata']; $version = $row['pipeline_version']; $directory = $row['pipeline_directory']; $usetmpdir = $row['pipeline_usetmpdir']; $tmpdir = $row['pipeline_tmpdir']; $pipelinenotes = $row['pipeline_notes']; $pipelinegroup = $row['pipeline_group']; $resultscript = $row['pipeline_resultsscript']; $deplevel = $row['pipeline_dependencylevel']; $depdir = $row['pipeline_dependencydir']; $deplinktype = $row['pipeline_deplinktype']; $completefiles = $row['pipeline_completefiles']; $dependency = $row['pipeline_dependency']; $groupid = $row['pipeline_groupid']; $dynamicgroupid = $row['pipeline_dynamicgroupid']; $level = $row['pipeline_level']; $owner = $row['username']; $ishidden = $row['pipeline_ishidden']; $isenabled = $row['pipeline_enabled']; //echo "<pre>"; //print_r($GLOBALS); //echo "</pre>"; if ($owner == $GLOBALS['username'] || $GLOBALS['issiteadmin']) { $readonly = false; } else { $readonly = true; } $formaction = "update"; $formtitle = "{$title}"; $submitbuttonlabel = "Update Pipeline Info"; } else { $formaction = "add"; $formtitle = "Add new pipeline"; $submitbuttonlabel = "Add Pipeline Info"; $remove = "0"; $level = 1; $directory = "/home/" . $GLOBALS['username'] . "/onrc/data"; $readonly = false; } if ($readonly) { $disabled = "disabled"; } else { $disabled = ""; } if ($numproc == "") { $numproc = 1; } //$urllist['Analysis'] = "analysis.php"; $urllist['Pipelines'] = "pipelines.php"; $urllist[$title] = "pipelines.php?action=editpipeline&id={$id}"; NavigationBar("Analysis", $urllist); ?> <script type="text/javascript"> $(document).ready(function() { /* default action */ <?php if ($level == 1) { ?> $('.level0').hide(); $('.level1').show(); $('.level2').hide(); <?php } elseif ($level == 0) { ?> $('.level0').show(); $('.level1').hide(); $('.level2').hide(); <?php } else { ?> $('.level0').hide(); $('.level1').show(); $('.level2').show(); <?php } ?> /* click events */ $('#level0').click(function() { if($('#level0').is(':checked')) { $('.level0').show("highlight",{},1000); $('.level1').hide(); $('.level2').hide(); } }); $('#level1').click(function() { if($('#level1').is(':checked')) { $('.level0').hide(); $('.level1').show("highlight",{},1000); $('.level2').hide(); } }); $('#level2').click(function() { if($('#level2').is(':checked')) { $('.level0').hide(); $('.level1').show(); $('.level2').show("highlight",{},1000); } }); }); function AlphaNumeric(e) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); keychar = keychar.toLowerCase(); // control keys if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true; // alphas and numbers else if ((("abcdefghijklmnopqrstuvwxyz0123456789_").indexOf(keychar) > -1)) return true; else return false; } </script> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px">Status</legend> <table class="entrytable" style="border:0px"> <tr> <td class="label" valign="top">Enabled</td> <td valign="middle"> <?php if ($isenabled) { ?> <a href="pipelines.php?action=disable&returnpage=pipeline&id=<?php echo $id; ?> "><img src="images/checkedbox16.png"title="Pipeline enabled, click to disable"></a><?php } else { ?> <a href="pipelines.php?action=enable&returnpage=pipeline&id=<?php echo $id; ?> "><img src="images/uncheckedbox16.png" title="Pipeline disabled, click to enable"></a><?php } ?> </td> </tr> <tr> <td class="label" valign="top">Status<br><br></td> <td valign="top" style="font-size: 10pt"> <b>Status</b> <?php echo $pipeline_status; ?> <?php if ($pipeline_status == "running") { ?> (<a href="pipelines.php?action=reset&id=<?php echo $info['id']; ?> " style="color: darkred" title="Reset the status if you KNOW the pipeline has stopped running... ie, it hasn't updated the status in a couple days">reset</a>)<?php } ?> <br> <b>Status message</b> <?php echo $pipeline_statusmessage; ?> <br> <b>Last start</b> <?php echo $pipeline_laststart; ?> <br> <b>Last finish</b> <?php echo $pipeline_lastfinish; ?> <br> <b>Last check</b> <?php echo $pipeline_lastcheck; ?> <br> </td> </tr> </table> </fieldset> <br> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px"> <b><?php echo $formtitle; ?> </b> version <?php echo $version; ?> </legend> <table> <tr> <td style="padding-right:40px"> <table class="entrytable" style="border:0px"> <form method="post" action="pipelines.php"> <input type="hidden" name="action" value="<?php echo $formaction; ?> "> <input type="hidden" name="id" value="<?php echo $id; ?> "> <tr> <td class="label" valign="top">Title</td> <td valign="top"> <input type="text" name="pipelinetitle" value="<?php echo $title; ?> " maxlength="50" size="60" onKeyPress="return AlphaNumeric(event)" <?php if ($type == "edit") { echo "readonly style='background-color: #EEE; border: 1px solid gray; color: #888'"; } ?> > </td> </tr> <tr> <td class="label" valign="top">Description</td> <td valign="top"><input type="text" <?php echo $disabled; ?> name="pipelinedesc" value="<?php echo $desc; ?> " size="60"></td> </tr> <tr> <td class="label" valign="top">Stats level</td> <td valign="top"> <!--<input type="radio" name="level" id="level0" value="0" <?php echo $disabled; ?> <?php if ($level == 0) { echo "checked"; } ?> >One-shot <span class="tiny">Runs only once. No associated data</span><br>--> <input type="radio" name="level" id="level1" value="1" <?php echo $disabled; ?> <?php if ($level == 1) { echo "checked"; } ?> >First <span class="tiny">subject level</span><br> <input type="radio" name="level" id="level2" value="2" <?php echo $disabled; ?> <?php if ($level == 2) { echo "checked"; } ?> >Second <span class="tiny">group level</span><br> </td> </tr> <tr> <td class="label" valign="top">Group</td> <td valign="top"> <input type="text" name="pipelinegroup" list="grouplist" <?php echo $disabled; ?> value="<?php echo $pipelinegroup; ?> " maxlength="255" size="60"> </td> <datalist id="grouplist"> <?php $sqlstring = "select distinct(pipeline_group) 'pipeline_group' from pipelines"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pgroup = $row['pipeline_group']; echo "<option value='{$pgroup}'>"; } ?> </datalist> </tr> <tr> <td class="label" valign="top">Directory <img src="images/help.gif" title="<b>Directory</b><br><br>A directory called <b>Title</b> (same name as this analysis) will be created inside this directory and will contain the analyses for this pipeline.<br><br>If blank, the analyses for this pipeline will be written to the default pipeline directory: <span style='color: #E8FFFF'>[<?php echo $GLOBALS['cfg']['analysisdir']; ?> ]</span>"></td> <td valign="top"> <input type="text" name="pipelinedirectory" <?php echo $disabled; ?> value="<?php echo $directory; ?> " maxlength="255" size="60" <?php if ($type == "edit") { echo "readonly style='background-color: #EEE; border: 1px solid gray; color: #888'"; } ?> > </td> </tr> <tr class="level1"> <td class="label" valign="top">Concurrent processes <img src="images/help.gif" title="<b>Concurrent processes</b><br><br>This is the number of concurrent jobs allowed to be submitted to the cluster at a time. This number is separate from the number of slots available in the cluster queue, which specified in the grid engine setup"></td> <td valign="top"><input type="number" name="pipelinenumproc" <?php echo $disabled; ?> value="<?php echo $numproc; ?> " min="1" max="350"></td> </tr> <tr> <td class="label" valign="top">Submit host <img src="images/help.gif" title="<b>Submit host</b><br><br>The hostname of the SGE head node to submit to. If blank, the default submit host is used (<?php echo $GLOBALS['cfg']['clustersubmithost']; ?> )"></td> <td valign="top"><input type="text" name="pipelinesubmithost" <?php echo $disabled; ?> value="<?php echo $submithost; ?> "></td> </tr> <tr> <td class="label" valign="top">Queue name <img src="images/help.gif" title="<b>Queue name</b><br><br>The sun grid (SGE) queue to submit to"></td> <td valign="top"><input type="text" name="pipelinequeue" <?php echo $disabled; ?> value="<?php echo $queue; ?> " required></td> </tr> <tr> <td class="label" valign="top">Use temporary directory <img src="images/help.gif" title="<b>Use tmp directory</b><br><br>This option will copy all data into the temporary directory first, process it there, and copy it back to its final location"></td> <td valign="top"><input type="checkbox" name="pipelineusetmpdir" <?php echo $disabled; ?> value="1" <?php if ($usetmpdir == "1") { echo "checked"; } ?> > <input type="text" name="pipelinetmpdir" <?php echo $disabled; ?> value="<?php echo $tmpdir; ?> " size="56"><br> <span class="tiny">Usually <tt>/tmp</tt>. Check with your sysadmin</span></td> </tr> <!--<tr class="level1"> <td class="label" valign="top">Data download</td> <td valign="top"> <input type="radio" name="dataand" value="0" <?php echo $disabled; ?> <?php if ($dataand == 0) { echo "checked"; } ?> >or <span class="tiny">download any of the data specified below</span><br> <input type="radio" name="dataand" value="1" <?php echo $disabled; ?> <?php if ($dataand == 1) { echo "checked"; } ?> >and <span class="tiny">only download data if all of the series specified exist in the study</span><br> <input type="radio" name="dataand" value="-1" <?php echo $disabled; ?> <?php if ($dataand == -1) { echo "checked"; } ?> >none <span class="tiny">no data download. only use if the pipeline has a dependency</span> </td> </tr>--> <!--<tr class="level1"> <td class="label" valign="top">Remove downloaded data?</td> <td valign="top" title="<b>Remove downloaded data</b><br><br>Deletes all downloaded (raw) data after analysis is complete. Assumes that the analsysis will have copied or converted the necessary data and no longer needs it"><input type="checkbox" name="pipelineremovedata" value="1" <?php if ($remove) { echo "checked"; } ?> ></td> </tr>--> <tr> <td class="label" valign="top">Successful files <img src="images/help.gif" title="<b>Successful files</b><br><br>The analysis is marked as successful if ALL of the files specified exist at the end of the analysis. If left blank, the analysis will always be marked as successful"></td> <td valign="top"><textarea name="completefiles" <?php echo $disabled; ?> rows="5" cols="60"><?php echo $completefiles; ?> </textarea><br> <span class="tiny">Comma seperated list of files (relative paths)</span></td> </tr> <tr> <td class="label" valign="top">Results script <img src="images/help.gif" title="<b>Results script</b><br><br>This script will be executed last and can be re-run separate from the analysis pipeline. The results script would often be used to create thumbnails of images and parse text files, and reinsert those results back into the database. The same pipeline variables available in the script command section below are available here to be passed as parameters to the results script"></td> <td valign="top"> <textarea name="pipelineresultsscript" rows="3" cols="60"><?php echo $resultscript; ?> </textarea> </td> </tr> <tr class="level1"> <td class="label" valign="top">Pipeline dependency<br> </td> <td valign="top"> <table class="entrytable"> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Dependency</td> <td valign="top"> <select name="dependency[]" <?php echo $disabled; ?> multiple="multiple" size="7"> <option value="">(No dependency)</option> <?php $sqlstring = "select * from pipelines order by pipeline_name"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $d_name = $row['pipeline_name']; $d_id = $row['pipeline_id']; $d_ver = $row['pipeline_version']; /* get the number of analyses in the pipeline */ $sqlstringA = "select count(*) 'count' from analysis where pipeline_id = {$d_id} and analysis_status = 'complete'"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); $rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC); $nummembers = $rowA['count']; if (in_array($d_id, explode(",", $dependency))) { $selected = "selected"; } else { $selected = ""; } if ($id != $d_id) { ?> <option value="<?php echo $d_id; ?> " <?php echo $selected; ?> ><?php echo $d_name; ?> [<?php echo $nummembers; ?> ]</option> <?php } } ?> </select> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Criteria</td> <td valign="top"> <input type="radio" name="deplevel" value="study" <?php echo $disabled; ?> <?php if ($deplevel == "study" || $deplevel == "") { echo "checked"; } ?> > study <span class="tiny">use dependencies from same study</span><br> <input type="radio" name="deplevel" value="subject" <?php echo $disabled; ?> <?php if ($deplevel == "subject") { echo "checked"; } ?> > subject <span class="tiny">use dependencies from same subject (other studies)</span> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Directory</td> <td valign="top"> <input type="radio" name="depdir" value="root" <?php echo $disabled; ?> <?php if ($depdir == "root" || $depdir == "") { echo "checked"; } ?> > root directory <img src="images/help.gif" title="copies all files into the analysis root directory <code>{analysisrootdir}/*</code>"><br> <input type="radio" name="depdir" value="subdir" <?php echo $disabled; ?> <?php if ($depdir == "subdir") { echo "checked"; } ?> > sub-directory <img src="images/help.gif" title="copies dependency into a subdirectory of the analysis <code>{analysisrootdir}/<i>DependencyName</i>/*</code>"> </td> </tr> <tr> <td valign="top" align="right" style="font-size:10pt; font-weight:bold;color: #555;">Linking type</td> <td valign="top"> <input type="radio" name="deplinktype" value="hardlink" <?php echo $disabled; ?> <?php if ($deplinktype == "hardlink" || $deplinktype == "") { echo "checked"; } ?> > hard link<br> <input type="radio" name="deplinktype" value="softlink" <?php echo $disabled; ?> <?php if ($deplinktype == "softlink") { echo "checked"; } ?> > soft link<br> <input type="radio" name="deplinktype" value="regularcopy" <?php echo $disabled; ?> <?php if ($deplinktype == "regularcopy") { echo "checked"; } ?> > Regular copy<br> </td> </tr> </table> </td> </tr> <tr class="level1"> <td class="label" valign="top">Group(s) <img src="images/help.gif" title="Perform this analysis ONLY<br>on the studies in the specified groups"><br> <span class="level2" style="color:darkred; font-size:8pt; font-weight:normal"> Second level must have<br> at least one group.<br>Group(s) must be identical to<br>first level <b>dependency's</b> group(s)</span> </td> <td valign="top"> <select name="groupid[]" <?php echo $disabled; ?> multiple="multiple" size="7"> <option value="">(No group)</option> <?php $sqlstring = "select * from groups where group_type = 'study' order by group_name"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $g_name = $row['group_name']; $g_id = $row['group_id']; /* get the number of members of the group */ $sqlstringA = "select count(*) 'count' from group_data where group_id = {$g_id}"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); $rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC); $nummembers = $rowA['count']; if (in_array($g_id, explode(",", $groupid))) { $selected = "selected"; } else { $selected = ""; } ?> <option value="<?php echo $g_id; ?> " <?php echo $selected; ?> ><?php echo $g_name; ?> [<?php echo $nummembers; ?> ]</option> <?php } ?> </select> </td> </tr> <tr> <td class="label" valign="top">Notes<br><span class="tiny">Any information about the analysis</span></td> <td valign="top"><textarea name="pipelinenotes" <?php echo $disabled; ?> rows="8" cols="60"><?php echo $pipelinenotes; ?> </textarea></td> </tr> <tr> <td class="label" valign="top">Hidden?</td> <td valign="top" title="<b>Hidden</b><br><br>Useful to hide a pipeline from the main pipeline list. The pipeline still exists, but it won't show up"><input type="checkbox" name="pipelineishidden" value="1" <?php if ($ishidden) { echo "checked"; } ?> ></td> </tr> <tr> <td colspan="2" align="center"> <br> <input type="submit" <?php echo $disabled; ?> value="<?php echo $submitbuttonlabel; ?> "> </td> </tr> </form> </table> </td> <?php if ($formaction == "update") { ?> <td valign="top"> <?php /* gather statistics about the analyses */ $sqlstring = "select sum(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'cluster_time' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totaltime = $row['cluster_time']; $totaltime = number_format($totaltime / 60 / 60, 2); $sqlstring = "select sum(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'cluster_timesuccess' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete' and analysis_iscomplete = 1"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $totaltimesuccess = $row['cluster_timesuccess']; $totaltimesuccess = number_format($totaltimesuccess / 60 / 60, 2); $sqlstring = "select count(*) 'numcomplete' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numcomplete = $row['numcomplete']; $sqlstring = "select count(*) 'numcompletesuccess' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'complete' and analysis_iscomplete = 1"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numcompletesuccess = $row['numcompletesuccess']; $sqlstring = "select count(*) 'numprocessing' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'processing'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numprocessing = $row['numprocessing']; $sqlstring = "select count(*) 'numpending' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status = 'pending'"; $result = MySQLQuery($sqlstring, __FILE__, __LINE__); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numpending = $row['numpending']; /* get mean processing times */ $sqlstring = "select analysis_id, timestampdiff(second, analysis_startdate, analysis_enddate) 'analysis_time', timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate) 'cluster_time' from analysis a left join studies b on a.study_id = b.study_id left join enrollment c on b.enrollment_id = c.enrollment_id left join subjects d on c.subject_id = d.subject_id where a.pipeline_id = {$id} and analysis_status <> ''"; //PrintSQL($sqlstring); $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //$analysis_id = $row['analysis_id']; $analysistimes[] = $row['analysis_time']; $clustertimes[] = $row['cluster_time']; } if (count($clustertimes) == 0) { $clustertimes[] = 0; } if (count($analysistimes) == 0) { $analysistimes[] = 0; } ?> <table class="twocoltable"> <tr> <th colspan="2">Analysis Statistics</th> </tr> <tr> <td>Processing Complete<br><span style="font-weight: normal">Total CPU time</span></td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numcomplete; ?> </a><br><?php echo $totaltime; ?> hours</td> </tr> <tr> <td>Successfuly Completed<br><span style="font-weight: normal">Total CPU time</span></td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numcompletesuccess; ?> </a><br><?php echo $totaltimesuccess; ?> hours</td> </tr> <tr> <td>Processing</td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numprocessing; ?> </a></td> </tr> <tr> <td>Pending</td> <td><a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><?php echo $numpending; ?> </a></td> </tr> </tr> <td>Setup Time</td> <td><?php echo number_format(min($analysistimes), 1); ?> - <?php echo number_format(max($analysistimes), 1); ?> seconds <br>Mean: <?php echo number_format(mean($analysistimes), 1); ?> seconds</td> </tr> <tr> <td>Cluster Time</td> <td><?php echo number_format(min($clustertimes) / 60 / 60, 2); ?> - <?php echo number_format(max($clustertimes) / 60 / 60, 2); ?> hours <br>Mean: <?php echo number_format(mean($clustertimes) / 60 / 60, 2); ?> hours</td> </tr> <tr> <td colspan="2"> <!-- display performance by hostname --> <details> <summary style="color: #3B5998"> Computing Performance </summary> <table class="smallgraydisplaytable"> <tr> <th colspan="3">Computing performance<br><span class="tiny">Successful analyses only</span></th> </tr> <tr> <td><b>Hostname</b></td> <td><b>Avg CPU</b></td> <td><b>Count</b></td> </tr> <?php $sqlstring = "SELECT avg(timestampdiff(second, analysis_clusterstartdate, analysis_clusterenddate)) 'avgcpu', count(analysis_hostname) 'count', analysis_hostname FROM `analysis` WHERE pipeline_id = {$id} and analysis_iscomplete = 1 group by analysis_hostname order by analysis_hostname"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $cpuhrs = number_format($row['avgcpu'] / 60 / 60, 2); $count = $row['count']; $hostname = $row['analysis_hostname']; ?> <tr> <td><?php echo $hostname; ?> </td> <td><?php echo $cpuhrs; ?> hrs</td> <td><?php echo $count; ?> </td> </tr> <?php } ?> </table> </details> </td> </tr> </table> <br> <br> <script> function GetNewPipelineName(){ var newname = prompt("Please enter a name for the new pipeline","<?php echo $title; ?> "); if (newname != null){ $("#newname").attr("value", newname); document.copypipeline.submit(); } } </script> <details> <summary style="color: #3B5998"> Pipeline Operations </summary> <br> <a href="pipelines.php?action=viewpipeline&id=<?php echo $id; ?> "><img src="images/printer16.png" border="0"> Print view</a> <span class="tiny">(and previous pipeline versions)</span><br><br> <a href="pipelines.php?action=viewanalyses&id=<?php echo $id; ?> "><img src="images/preview.gif"> View analyses</a><br><br> <a href="pipelines.php?action=viewfailedanalyses&id=<?php echo $id; ?> " title="View all imaging studies which did not meet the data criteria, and therefore the pipeline did not attempt to run the analysis"><img src="images/preview.gif"> View ignored studies</a><br><br> <form action="pipelines.php" method="post" name="copypipeline"> <input type="hidden" name="action" value="copy"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <input type="hidden" name="newname" id="newname" value="<?php echo $id; ?> "> <img src="images/copy16.gif"> <input type="button" value="Copy to new pipeline..." onClick="GetNewPipelineName();"><br><br> </form> <?php if (!$readonly) { ?> Change pipeline owner to: <form> <input type="hidden" name="action" value="changeowner"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <select name="newuserid"> <?php $sqlstring = "select * from users where user_enabled = 1 order by username"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $userid = $row['user_id']; $username = $row['username']; $userfullname = $row['user_fullname']; if ($userfullname != "") { $userfullname = "[{$userfullname}]"; } ?> <option value="<?php echo $userid; ?> "><?php echo $username; ?> <?php echo $userfullname; ?> </option><?php } ?> </select> <input type="submit" value="Change"> </form> <a href="pipelines.php?action=detach$id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to completely detach this pipeline?')" title="This will completely inactivate the pipeline and remove all analyses from the pipeline control. Since the data will no longer be under pipeline control, all analysis results will be deleted. All analysis data will be moved to the directory you specify"><img src="images/disconnect16.png"> Detach entire pipeline</a><br><br> <a href="pipelines.php?action=resetanalyses&id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to reset the analyses for this pipeline?')" title="This will remove any entries in the database for studies which were not analyzed. If you change your data specification, you will want to reset the analyses. This option does not remove existing analyses, it only removes the flag set for studies that indicates the study has been checked for the specified data"><img src="images/reset16.png"> Reprocess ignored studies</a><br><br> <a href="pipelines.php?action=delete&id=<?php echo $id; ?> " onclick="return confirm('Are you sure you want to delete this pipeline?')"><img src="images/delete16.png"> Delete this pipeline</a> <?php } ?> </details> <br> <span style="color:#555; font-size:11pt; font-weight: bold">Where is my data?</span><br><br> <span style="background-color: #ddd; padding:5px; font-family: monospace; border-radius:3px"> <?php if ($directory != "") { echo $directory; } else { echo $GLOBALS['cfg']['analysisdir']; } ?> /<i>UID</i>/<i>StudyNum</i>/<?php echo $title; ?> </span> </td> <?php } ?> </tr> </table> </fieldset> <?php if ($type == "edit") { ?> <br><br> <script> function addParam(value,id){ var TheTextBox = document.getElementById(id); TheTextBox.value = TheTextBox.value + ' ' + value; } </script> <fieldset style="border: 3px solid #999; border-radius:5px"> <legend style="background-color: #3B5998; color:white; padding:5px 10px; border-radius:5px"> Pipeline specification </legend> <form method="post" action="pipelines.php" name="stepsform" id="stepsform"> <input type="hidden" name="action" value="updatepipelinedef"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <?php if ($level == 1 || $level == 2 && $dependency == '') { ?> <br> <style> td.dataheader { padding: 5px; border-bottom: 2px solid #999; background-color: #eee; text-align: center } </style> <div style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;" class="level1">Data</div> <br> <table class="level1" cellspacing="0" cellpadding="0"> <tr style="color:#444; font-size:10pt;"> <td class="dataheader"><b>Enabled</b></td> <td class="dataheader"><b>Optional</b></td> <td class="dataheader"><b>Order</b></td> <td class="dataheader"><b>Protocol</b></td> <td class="dataheader"><b>Modality</b></td> <td class="dataheader"><b>Where's the data coming from?</b> <img src="images/help.gif" title="<b>Data Source</b><br>All analyses are run off of the study level. If you want data from this subject, but the data was collected in a different study, select the Subject data level. For example, the subject has been scanned on three different dates, but only one of them has"></td> <td class="dataheader"><b>Subject linkage</b> <img src="images/help.gif" title="<b>Data Level</b><br>Only use this option if your data is coming from the subject level"></td> </tr> <?php $neworder = 1; /* display all other rows, sorted by order */ $sqlstring = "select * from pipeline_data_def where pipeline_id = {$id} and pipeline_version = {$version} order by pdd_order + 0"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pipelinedatadef_id = $row['pipelinedatadef_id']; $dd_order = $row['pdd_order']; $dd_seriescriteria = $row['pdd_seriescriteria']; $dd_protocol = $row['pdd_protocol']; $dd_modality = $row['pdd_modality']; $dd_dataformat = $row['pdd_dataformat']; $dd_imagetype = $row['pdd_imagetype']; $dd_gzip = $row['pdd_gzip']; $dd_location = $row['pdd_location']; $dd_useseries = $row['pdd_useseries']; $dd_preserveseries = $row['pdd_preserveseries']; $dd_usephasedir = $row['pdd_usephasedir']; $dd_behformat = $row['pdd_behformat']; $dd_behdir = $row['pdd_behdir']; $dd_numboldreps = $row['pdd_numboldreps']; $dd_enabled = $row['pdd_enabled']; $dd_assoctype = $row['pdd_assoctype']; $dd_optional = $row['pdd_optional']; $dd_datalevel = $row['pdd_level']; $dd_numimagescriteria = $row['pdd_numimagescriteria']; //PrintVariable($row); ?> <script> $(document).ready(function() { $('.row<?php echo $neworder; ?> ').mouseover(function() { $('.row<?php echo $neworder; ?> ').css('background-color','#eee'); }) .mouseout(function() { $('.row<?php echo $neworder; ?> ').css('background-color',''); }); }); </script> <tr class="row<?php echo $neworder; ?> "> <td width="10" valign="top" style="padding: 5px;" align="center"> <input class="small" type="checkbox" name="dd_enabled[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_enabled) { echo "checked"; } ?> > </td> <td valign="top" style="padding: 5px" align="center"> <input type="checkbox" name="dd_optional[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_optional) { echo "checked"; } ?> > </td> <td style="padding: 5px" valign="top"> <input class="small" type="text" name="dd_order[<?php echo $neworder; ?> ]" size="2" maxlength="3" value="<?php echo $neworder; ?> "> </td> <td valign="top" style="padding: 5px"> <input class="small" type="text" name="dd_protocol[<?php echo $neworder; ?> ]" size="50" value='<?php echo $dd_protocol; ?> ' title='Enter exact protocol name(s). Use quotes if entering a protocol with spaces or entering more than one protocol: "Task1" "Task 2" "Etc". Use multiple protocol names ONLY if you do not expect the protocols to occur in the same study'> </td> <td id="row<?php echo $neworder; ?> " valign="top" style="padding: 5px"> <select class="small" name="dd_modality[<?php echo $neworder; ?> ]"> <option value="">(Select modality)</option> <?php $sqlstringA = "select * from modalities order by mod_desc"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) { $mod_code = $rowA['mod_code']; $mod_desc = $rowA['mod_desc']; /* check if the modality table exists */ $sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($mod_code) . "_series'"; //echo $sqlstring2; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { /* if the table does exist, allow the user to search on it */ if ($mod_code == $dd_modality) { $selected = "selected"; } else { $selected = ""; } ?> <option value="<?php echo $mod_code; ?> " <?php echo $selected; ?> ><?php echo $mod_code; ?> </option> <?php } } ?> </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_datalevel[<?php echo $neworder; ?> ]"> <option value="">(select data level) <option value="study" <?php if ($dd_datalevel == "study" || $dd_datalevel == "") { echo "selected"; } ?> >Study <option value="subject" <?php if ($dd_datalevel == "subject") { echo "selected"; } ?> >Subject </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_studyassoc[<?php echo $neworder; ?> ]"> <option value="">(select study link) <option value="nearestintime" <?php if ($dd_assoctype == "nearestintime" || $dd_assoctype == "") { echo "selected"; } ?> >Nearest in time <option value="samestudytype" <?php if ($dd_assoctype == "samestudytype") { echo "selected"; } ?> >Same study type </select> </td> </tr> <tr class="row<?php echo $neworder; ?> "> <td valign="top" colspan="7" style="padding-left:25px"> <details class="level1" style="padding:0px;margin:0px"> <summary style="padding:0px; font-size:9pt">Options</summary> <table class="entrytable" style="background-color: #EEE; border-radius:4px; border: 1px solid #999"> <tr> <td class="label">Data format</td> <td> <select class="small" name="dd_dataformat[<?php echo $neworder; ?> ]"> <option value="native" <?php if ($dd_dataformat == "native") { echo "selected"; } ?> >Native</option> <option value="dicom" <?php if ($dd_dataformat == "dicom") { echo "selected"; } ?> >DICOM</option> <option value="nifti3d" <?php if ($dd_dataformat == "nifti3d") { echo "selected"; } ?> >Nifti 3D</option> <option value="nifti4d" <?php if ($dd_dataformat == "nifti4d") { echo "selected"; } ?> >Nifti 4D</option> <option value="analyze3d" <?php if ($dd_dataformat == "analyze3d") { echo "selected"; } ?> >Analyze 3D</option> <option value="analyze4d" <?php if ($dd_dataformat == "analyze4d") { echo "selected"; } ?> >Analyze 4D</option> </select> </td> </tr> <tr> <td class="label">Image type</td> <td><input class="small" type="text" name="dd_imagetype[<?php echo $neworder; ?> ]" size="30" value="<?php echo $dd_imagetype; ?> "></td> </tr> <tr> <td class="label">g-zip</td> <td><input class="small" type="checkbox" name="dd_gzip[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_gzip) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Directory <img src="images/help.gif" title="<b>Tip:</b> choose a directory called 'data/<i>taskname</i>'. If converting data or putting into a new directory structure, this data directory can be used as a staging area and can then be deleted later in your script"><br><span class="tiny">Relative to analysis root</span></td> <td><input class="small" type="text" name="dd_location[<?php echo $neworder; ?> ]" size="30" value="<?php echo $dd_location; ?> "></td> </tr> <tr> <td class="label">Criteria <img src="images/help.gif" title="<b>All</b> - All matching series will be downloaded<br><b>First</b> - Only the lowest numbered series will be downloaded<br><b>Last</b> - Only the highest numbered series will be downloaded<br><b>Largest</b> - Only one series with the most number of volumes or slices will be downloaded<br><b>Smallest</b> - Only one series with the least number of volumes or slices will be downloaded"></td> <td> <select class="small" name="dd_seriescriteria[<?php echo $neworder; ?> ]"> <option value="all" <?php if ($dd_seriescriteria == "all") { echo "selected"; } ?> >All</option> <option value="first" <?php if ($dd_seriescriteria == "first") { echo "selected"; } ?> >First</option> <option value="last" <?php if ($dd_seriescriteria == "last") { echo "selected"; } ?> >Last</option> <option value="largestsize" <?php if ($dd_seriescriteria == "largestsize") { echo "selected"; } ?> >Largest</option> <option value="smallestsize" <?php if ($dd_seriescriteria == "smallestsize") { echo "selected"; } ?> >Smallest</option> <option value="usesizecriteria" <?php if ($dd_seriescriteria == "usesizecriteria") { echo "selected"; } ?> >Use size criteria below</option> </select> </td> </tr> <tr> <td class="label">Number of BOLD reps <img src="images/help.gif" title="<b>Must be an integer or a criteria:</b><ul><li><i>N</i> (exactly N)<li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>"></td> <td><input type="text" name="dd_numboldreps[<?php echo $neworder; ?> ]" value="<?php echo $dd_numboldreps; ?> "></td> </tr> <tr> <td class="label">Use series directories <img src="images/help.gif" title="<b>Tip:</b> If you plan to download multiple series with the same name, you will want to use series directories. This option will place each series into its own directory (data/task/1, data/task/2, etc)"></td> <td><input class="small" type="checkbox" name="dd_useseriesdirs[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_useseries) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Preserve series numbers <img src="images/help.gif" title="If data is placed in a series directory, check this box to preserve the original series number. Otherwise the series number directories will be sequential starting at 1, regardless of the orignal series number"></td> <td><input class="small" type="checkbox" name="dd_preserveseries[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_preserveseries) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Phase encoding direction <img src="images/help.gif" title="<b>Phase Encoding Direction</b> If selected, it will write the data to a subdirectory corresponding to the acquired phase encoding direction: AP, PA, RL, LR, COL, ROW, unknownPE"></td> <td><input class="small" type="checkbox" name="dd_usephasedir[<?php echo $neworder; ?> ]" value="1" <?php if ($dd_usephasedir) { echo "checked"; } ?> ></td> </tr> <tr> <td class="label">Behavioral data directory format</td> <td> <select class="small" name="dd_behformat[<?php echo $neworder; ?> ]"> <option value="behnone" <?php if ($dd_behformat == "behnone") { echo "selected"; } ?> >Don't download behavioral data</option> <option value="behroot" <?php if ($dd_behformat == "behroot") { echo "selected"; } ?> >Place in root (file.log)</option> <option value="behrootdir" <?php if ($dd_behformat == "behrootdir") { echo "selected"; } ?> >Place in directory in root (beh/file.log)</option> <option value="behseries" <?php if ($dd_behformat == "behseries") { echo "selected"; } ?> >Place in series (2/file.log)</option> <option value="behseriesdir" <?php if ($dd_behformat == "behseriesdir") { echo "selected"; } ?> >Place in directory in series (2/beh/file.log)</option> </select> </td> </tr> <tr> <td class="label">Behavioral data directory name</td> <td><input class="small" type="text" name="dd_behdir[<?php echo $neworder; ?> ]" value="<?php echo $dd_behdir; ?> "></td> </tr> </table> <br> </details> </td> </tr> <?php $neworder++; } for ($ii = 0; $ii < 5; $ii++) { ?> <script> $(document).ready(function() { $('.row<?php echo $neworder; ?> ').mouseover(function() { $('.row<?php echo $neworder; ?> ').css('background-color','#eee'); }) .mouseout(function() { $('.row<?php echo $neworder; ?> ').css('background-color',''); }); }); </script> <tr class="row<?php echo $neworder; ?> "> <td width="10" valign="top" style="padding: 5px;" align="center"> <input class="small" type="checkbox" name="dd_enabled[<?php echo $neworder; ?> ]" value="1"> </td> <td valign="top" style="padding: 5px" align="center"> <input type="checkbox" name="dd_optional[<?php echo $neworder; ?> ]" value="1"> </td> <td style="padding: 5px" valign="top"> <input class="small" type="text" name="dd_order[<?php echo $neworder; ?> ]" size="2" maxlength="3" value="<?php echo $neworder; ?> "> </td> <td valign="top" style="padding: 5px"> <input class="small" type="text" name="dd_protocol[<?php echo $neworder; ?> ]" size="50" title='Enter exact protocol name(s). Use quotes if entering a protocol with spaces or entering more than one protocol: "Task1" "Task 2" "Etc". Use multiple protocol names ONLY if you do not expect the protocols to occur in the same study'> </td> <td valign="top" style="padding: 5px"> <select class="small" name="dd_modality[<?php echo $neworder; ?> ]"> <option value="">(Select modality)</option> <?php $sqlstringA = "select * from modalities order by mod_desc"; $resultA = MySQLiQuery($sqlstringA, __FILE__, __LINE__); while ($rowA = mysqli_fetch_array($resultA, MYSQLI_ASSOC)) { $mod_code = $rowA['mod_code']; $mod_desc = $rowA['mod_desc']; /* check if the modality table exists */ $sqlstring2 = "show tables from " . $GLOBALS['cfg']['mysqldatabase'] . " like '" . strtolower($mod_code) . "_series'"; //echo $sqlstring2; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { ?> <option value="<?php echo $mod_code; ?> "><?php echo $mod_code; ?> </option> <?php } } ?> </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_datalevel[<?php echo $neworder; ?> ]"> <option value="">(select data level) <option value="study" selected>Study <option value="subject">Subject </select> </td> <td valign="top" style="font-size:8pt; padding: 5px" align="left"> <select name="dd_studyassoc[<?php echo $neworder; ?> ]"> <option value="">(select study link) <option value="nearestintime" selected>Nearest in time <option value="samestudytype">Same study type </select> </td> </tr> <tr class="row<?php echo $neworder; ?> "> <td valign="top" colspan="7" style="padding-left:25px"> <details class="level1" style="padding:0px;margin:0px"> <summary style="padding:0px; font-size:9pt">Options</summary> <table class="entrytable" style="background-color: #EEE; border-radius:4px; border: 1px solid #999"> <tr> <td class="label">Data format</td> <td> <select class="small" name="dd_dataformat[<?php echo $neworder; ?> ]"> <option value="native" selected>Native</option> <option value="dicom">DICOM</option> <option value="nifti3d">Nifti 3D</option> <option value="nifti4d">Nifti 4D</option> <option value="analyze3d">Analyze 3D</option> <option value="analyze4d">Analyze 4D</option> </select> </td> </tr> <tr> <td class="label">Image type</td> <td><input class="small" type="text" name="dd_imagetype[<?php echo $neworder; ?> ]" size="30"></td> </tr> <tr> <td class="label">g-zip</td> <td><input class="small" type="checkbox" name="dd_gzip[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Directory <img src="images/help.gif" title="<b>Tip:</b> choose a directory called 'data/<i>taskname</i>'. If converting data or putting into a new directory structure, this data directory can be used as a staging area and can then be deleted later in your script"><br><span class="tiny">Relative to analysis root</span></td> <td><input class="small" type="text" name="dd_location[<?php echo $neworder; ?> ]" size="30"></td> </tr> <tr> <td class="label">Criteria <img src="images/help.gif" title="<b>All</b> - All matching series will be downloaded<br><b>First</b> - Only the lowest numbered series will be downloaded<br><b>Last</b> - Only the highest numbered series will be downloaded<br><b>Largest</b> - Only one series with the most number of volumes or slices will be downloaded<br><b>Smallest</b> - Only one series with the least number of volumes or slices will be downloaded"></td> <td> <select class="small" name="dd_seriescriteria[<?php echo $neworder; ?> ]"> <option value="all" selected>All</option> <option value="first">First</option> <option value="last">Last</option> <option value="largestsize">Largest</option> <option value="smallestsize">Smallest</option> <option value="usesizecriteria">Use size criteria below</option> </select> </td> </tr> <tr> <td class="label">Number of BOLD reps <img src="images/help.gif" title="<b>Must be an integer or a criteria:</b><ul><li><i>N</i> (exactly N)<li>> <i>N</i> (greater than)<li>>= <i>N</i> (greater than or equal to)<li>< <i>N</i> (less than)<li><= <i>N</i> (less than or equal to)<li>~ <i>N</i> (not)</ul>"></td> <td><input type="text" name="dd_numboldreps[<?php echo $neworder; ?> ]"></td> </tr> <tr> <td class="label">Use series directories <img src="images/help.gif" title="<b>Tip:</b> If you plan to download multiple series with the same name, you will want to use series directories. This option will place each series into its own directory (data/task/1, data/task/2, etc)"</td> <td><input class="small" type="checkbox" name="dd_useseriesdirs[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Preserve series numbers <img src="images/help.gif" title="If data is placed in a series directory, check this box to preserve the original series number. Otherwise the series number directories will be sequential starting at 1, regardless of the orignal series number"></td> <td><input class="small" type="checkbox" name="dd_preserveseries[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Phase encoding direction <img src="images/help.gif" title="<b>Phase Encoding Direction</b> If selected, it will write the data to a subdirectory corresponding to the acquired phase encoding direction: AP, PA, RL, LR, COL, ROW, noPE"></td> <td><input class="small" type="checkbox" name="dd_usephasedir[<?php echo $neworder; ?> ]" value="1"></td> </tr> <tr> <td class="label">Behavioral data directory format</td> <td> <select class="small" name="dd_behformat[<?php echo $neworder; ?> ]"> <option value="behnone" selected>Don't download behavioral data</option> <option value="behroot">Place in root (file.log)</option> <option value="behrootdir">Place in directory in root (beh/file.log)</option> <option value="behseries">Place in series (2/file.log)</option> <option value="behseriesdir">Place in directory in series (2/beh/file.log)</option> </select> </td> </tr> <tr> <td class="label">Behavioral data directory name</td> <td><input class="small" type="text" name="dd_behdir[<?php echo $neworder; ?> ]"></td> </tr> </table> <br> </details> </td> </tr> <?php $neworder++; ?> <?php } ?> </table> <?php } /* end of the check to display the data specs */ ?> <br><br> <div style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;">Main Script Commands<br><span class="tiny" style="font-weight:normal">Ctrl+S to save</span></div> <br><br> <style type="text/css" media="screen"> #commandlist { position: relative; width: 1000px; height: 700px; top: 0; right: 0; bottom: 0; left: 0; } #supplementcommandlist { position: relative; width: 1000px; height: 300px; top: 0; right: 0; bottom: 0; left: 0; } </style> </b> <table> <tr> <td valign="top"> <textarea name="commandlist" style="font-weight:normal"><?php $sqlstring = "select * from pipeline_steps where pipeline_id = {$id} and pipeline_version = {$version} and ps_supplement <> 1 order by ps_order + 0"; $result = MySQLiQuery($sqlstring, __FILE__, __LINE__); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $pipelinestep_id = $row['pipelinestep_id']; $ps_desc = $row['ps_description']; $ps_order = $row['ps_order']; $ps_command = $row['ps_command']; $ps_workingdir = $row['ps_workingdir']; $ps_enabled = $row['ps_enabled']; $ps_logged = $row['ps_logged']; if ($ps_enabled == 1) { $enabled = ""; } else { $enabled = "#"; } if ($ps_logged == 1) { $logged = ""; } else { $logged = "{NOLOG}"; } echo "{$enabled}{$ps_command} # {$logged} {$ps_desc}\n"; } ?> </textarea> <div id="commandlist" style="border: 1px solid #666; font-weight: normal"></div> </td> <td valign="top" align="center"> <b>Available pipeline variables</b><br> <span class="tiny">Click variable to insert at current editor location</span> <br><br> <table> <tr><td class="pipelinevariable" onclick="insertText('{analysisrootdir}');" title="Full path to the root directory of the analysis">{analysisrootdir}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{subjectuid}');" title="Example: S1234ABC">{subjectuid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studynum}');" title="Example: 1">{studynum}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynum}');" title="Example: S1234ABC1">{uidstudynum}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{pipelinename}');" title="<?php echo $title; ?> ">{pipelinename}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studydatetime}');" title="YYYYMMDDHHMMSS">{studydatetime}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{first_ext_file}');" title="Expands to first file found with extenstion. Replace ext with the extension">{first_ext_file}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{first_n_ext_files}');" title="Finds first file with extension">{first_n_ext_files}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{last_ext_file}');" title="Finds last file (alphabetically) with extension">{last_ext_file}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{all_ext_files}');" title="Finds all files matching the extension">{all_ext_files}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{command}');" title="Full command, excluding comment">{command}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{workingdir}');" title="Not dynamic, not changed at run-time">{workingdir}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{description}');" title="The description (comment)">{description}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{analysisid}');" title="Analysis ID">{analysisid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{NOLOG}');" title="Insert in the comment and the line will not be logged. Useful if the command is using the > or >> operators to write to a file">{NOLOG}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{NOCHECKIN}');" title="Insert in the comment and the step will not be reported. Useful for command line for-loops">{NOCHECKIN}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{subjectuids}');" title="Space separated list of UIDs. For group analyses">{subjectuids}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{studydatetimes}');" title="Space separated list of datetimes, ordered by datetime. For group analyses">{studydatetimes}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{analysisgroupid}');" title="Group analysis ID">{analysisgroupid}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynums}');" title="Space separated list of uidstudynums for all groups">{uidstudynums}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{numsubjects}');" title="Number of subjects from all groups">{numsubjects}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{groups}');" title="Space separated list of groups">{groups}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{numsubjects_groupname}');" title="Number of subjects (sessions) in the group specified">{numsubjects_groupname}</td></tr> <tr><td class="pipelinevariable" onclick="insertText('{uidstudynums_groupname}');" title="Space separated list of uidstudynums for the group specified">{uidstudynums_groupname}</td></tr> </table> <br><br> <span class="editoroptions" onClick="toggleWrap()">Toggle text wrap</span> </td> </tr> <tr> <td colspan="6" align="left"> <?php $sqlstring2 = "select * from pipeline_steps where pipeline_id = {$id} and pipeline_version = {$version} and ps_supplement = 1 order by ps_order + 0"; $result2 = MySQLiQuery($sqlstring2, __FILE__, __LINE__); if (mysqli_num_rows($result2) > 0) { $open = "open"; } else { $open = ""; } ?> <details <?php echo $open; ?> > <summary style="text-align:left; font-size:12pt; font-weight: bold; color:#214282;">Supplementary script commands</summary> <br> <div id="supplementcommandlist" style="border: 1px solid #666; font-weight: normal"></div> <textarea name="supplementcommandlist"><?php while ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { $pipelinestep_id = $row2['pipelinestep_id']; $ps_desc = $row2['ps_description']; $ps_order = $row2['ps_order']; $ps_command = $row2['ps_command']; $ps_workingdir = $row2['ps_workingdir']; $ps_enabled = $row2['ps_enabled']; $ps_logged = $row2['ps_logged']; if ($ps_enabled == 1) { $enabled = ""; } else { $enabled = "#"; } if ($ps_logged == 1) { $logged = ""; } else { $logged = "{NOLOG}"; } echo "{$enabled}{$ps_command} # {$logged} {$ps_desc}\n"; } ?> </textarea> <span class="editoroptions" onClick="toggleWrap2()">Toggle text wrap</span> </details> </td> </tr> <tr> <td colspan="6" align="center"> <br><br> <input type="submit" <?php echo $disabled; ?> value="Update Pipeline Definition Only"> </td> </tr> </form> </table> </fieldset> <script src="scripts/aceeditor/ace.js" type="text/javascript" charset="utf-8"></script> <script> var editor = ace.edit("commandlist"); var textarea = $('textarea[name="commandlist"]').hide(); editor.setFontSize(12); editor.getSession().setMode("ace/mode/sh"); editor.getSession().setUseWrapMode(false); editor.getSession().setValue(textarea.val()); <?php if ($readonly) { ?> editor.setReadOnly(); <?php } ?> editor.getSession().on('change', function(){ textarea.val(editor.getSession().getValue()); }); editor.setTheme("ace/theme/xcode"); function insertText(text) { editor.insert(text); } function toggleWrap() { if (editor.getSession().getUseWrapMode()) { editor.getSession().setUseWrapMode(false); } else { editor.getSession().setUseWrapMode(true); } } $(window).bind('keydown', function(event) { if (event.ctrlKey || event.metaKey) { switch (String.fromCharCode(event.which).toLowerCase()) { case 's': event.preventDefault(); //alert('ctrl-s'); document.getElementById('stepsform').submit(); break; } } }); var editor2 = ace.edit("supplementcommandlist"); var textarea2 = $('textarea[name="supplementcommandlist"]').hide(); editor2.setFontSize(12); editor2.getSession().setMode("ace/mode/sh"); editor2.getSession().setUseWrapMode(false); editor2.getSession().setValue(textarea2.val()); <?php if ($readonly) { ?> editor2.setReadOnly(); <?php } ?> editor2.getSession().on('change', function(){ textarea2.val(editor2.getSession().getValue()); }); editor2.setTheme("ace/theme/xcode"); function insertText2(text) { editor2.insert(text); } function toggleWrap2() { if (editor2.getSession().getUseWrapMode()) { editor2.getSession().setUseWrapMode(false); } else { editor2.getSession().setUseWrapMode(true); } }; </script> <br><br> <br><br> <?php } }
function variance($cadena) { $mean = mean($cadena); $data = preg_split("/,/", $cadena, -1, PREG_SPLIT_NO_EMPTY); $sum = 0; $numValidElements = 0; foreach ($data as $key => $val) { if (isset($val)) { $tmp = $val - $mean; $sum += $tmp * $tmp; $numValidElements += 1; } } $variance = $sum / ($numValidElements - 1); $variance = round($variance, 3); return $variance; }
function get_apa_stats() { $p = apa_round($this->get_p()); $pvalue = $p < 0.001 ? '< .001' : "= {$p}"; $m1 = apa_round(mean($this->get_var1())); $m2 = apa_round(mean($this->get_var2())); $sd1 = apa_round(stdev($this->get_var1())); $sd2 = apa_round(stdev($this->get_var2())); $n1 = count($this->get_var1()); $n2 = count($this->get_var2()); $stats = '<i>M</i><sub>' . $this->get_vname1() . '</sub> = ' . $m1 . ', '; $stats .= '<i>SD</i><sub>' . $this->get_vname1() . '</sub> = ' . $sd1 . ', '; $stats .= '<i>N</i><sub>' . $this->get_vname1() . '</sub> = ' . $n1 . '; '; $stats .= '<i>M</i><sub>' . $this->get_vname2() . '</sub> = ' . $m2 . ', '; $stats .= '<i>SD</i><sub>' . $this->get_vname2() . '</sub> = ' . $sd2 . ', '; $stats .= '<i>N</i><sub>' . $this->get_vname2() . '</sub> = ' . $n2 . '<br />'; $stats .= '<i>t</i><sub>' . $this->get_df() . '</sub> = ' . apa_round($this->get_t()) . ', '; $stats .= '<i>p</i> ' . $pvalue . ', '; $stats .= '<i>d</i> = ' . apa_round($this->get_d()); return $stats; }
function stddev(&$hits, $total = false) { $n = count($hits); if (!$total) { $total = array_reduce($hits, 'rsum'); } $GLOBALS['mean'] = $total / $n; $r = array_map(create_function('$i', 'global $mean; return ($i-$mean)*($i-$mean);'), $hits); unset($GLOBALS['mean']); return (double) sqrt(mean($r, $total) * ($n / (double) ($n - 1))); }