forked from aarpon/hrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapturing_parameter.php
747 lines (639 loc) · 24.9 KB
/
capturing_parameter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
<?php
// This file is part of the Huygens Remote Manager
// Copyright and license notice: see license.txt
use hrm\DatabaseConnection;
use hrm\Nav;
use hrm\param\base\Parameter;
use hrm\param\CCDCaptorSizeX;
use hrm\param\ImageFileFormat;
use hrm\param\NumericalAperture;
use hrm\param\PinholeSize;
use hrm\param\PinholeSpacing;
use hrm\param\TimeInterval;
use hrm\param\ZStepSize;
use hrm\Util;
require_once dirname(__FILE__) . '/inc/bootstrap.php';
/* *****************************************************************************
*
* START SESSION, CHECK LOGIN STATE, INITIALIZE WHAT NEEDED
*
**************************************************************************** */
session_start();
if (!isset($_SESSION['user']) || !$_SESSION['user']->isLoggedIn()) {
header("Location: " . "login.php");
exit();
}
$message = "";
/* *****************************************************************************
*
* SET THE CONFIDENCES FOR THE RELEVANT PARAMETERS
*
**************************************************************************** */
/** @var ImageFileFormat $fileFormat */
$fileFormat = $_SESSION['setting']->parameter("ImageFileFormat");
$parameterNames = $_SESSION['setting']->capturingParameterNames();
$db = DatabaseConnection::get();
foreach ($parameterNames as $name) {
/** @var Parameter $parameter */
$parameter = $_SESSION['setting']->parameter($name);
$confidenceLevel = $db->getParameterConfidenceLevel($fileFormat->value(), $name);
$parameter->setConfidenceLevel($confidenceLevel);
$_SESSION['setting']->set($parameter);
}
/* *****************************************************************************
*
* MANAGE THE MULTI-CHANNEL PINHOLE RADII
*
**************************************************************************** */
/** @var PinholeSize $pinholeParam */
$pinholeParam = $_SESSION['setting']->parameter("PinholeSize");
$pinhole = $pinholeParam->value();
for ($i = 0; $i < $_SESSION['setting']->numberOfChannels(); $i++) {
$pinholeKey = "PinholeSize{$i}";
if (isset($_POST[$pinholeKey])) {
$pinhole[$i] = $_POST[$pinholeKey];
}
}
$pinholeParam->setValue($pinhole);
$pinholeParam->setNumberOfChannels($_SESSION['setting']->numberOfChannels());
$_SESSION['setting']->set($pinholeParam);
/* *****************************************************************************
*
* WHICH IS THE NEXT PAGE?
*
**************************************************************************** */
// Here we try to figure out whether we have to continue after this page or not.
// If the user chose to use a measured PSF or if there is a refractive index
// mismatch, there will be more pages after this. Otherwise, we save the
// settings to the database and go back to select_parameter_settings.php.
// Besides the destination page, also the control buttons will need to be
// adapted.
$saveToDB = false;
$PSF = $_SESSION['setting']->parameter('PointSpreadFunction')->value();
$MICR = $_SESSION['setting']->parameter("MicroscopeType")->value();
if ($MICR == "STED" || $MICR == 'STED 3D') {
$pageToGo = 'sted_parameters.php';
} elseif ($MICR == "SPIM") {
$pageToGo = 'spim_parameters.php';
} elseif ($PSF == 'measured') {
$pageToGo = 'select_psf.php';
// Make sure to turn off the correction
$_SESSION['setting']->parameter(
'AberrationCorrectionNecessary')->setValue('0');
} else {
// Get the refractive indices: if they are not set, the floatval conversion
// will change them into 0s
$sampleRI = floatval($_SESSION['setting']->parameter(
'SampleMedium')->translatedValue());
$objectiveRI = floatval($_SESSION['setting']->parameter(
'ObjectiveType')->translatedValue());
// Calculate the deviation
if (($sampleRI == 0) || ($objectiveRI == 0)) {
// If at least one of the refractive indices is not known, we cannot
// calculate whether an aberration correction is necessary and we leave
// the decision to the user in the aberration_correction.php page.
$pageToGo = 'aberration_correction.php';
$_SESSION['setting']->parameter(
'AberrationCorrectionNecessary')->setValue('1');
} else {
// If we know both the refractive indices we can calculate the deviation
// and skip the aberration correction page in case the deviation is smaller
// than 1%.
$deviation = abs($sampleRI - $objectiveRI) / $objectiveRI;
// Do we need to go to the aberration correction page?
if ($deviation < 0.01) {
// We can save the parameters
$saveToDB = true;
$pageToGo = 'select_parameter_settings.php';
// Make sure to turn off the correction
$_SESSION['setting']->parameter(
'AberrationCorrectionNecessary')->setValue('0');
} else {
$pageToGo = 'aberration_correction.php';
$_SESSION['setting']->parameter(
'AberrationCorrectionNecessary')->setValue('1');
}
}
}
/* *****************************************************************************
*
* PROCESS THE POSTED PARAMETERS
*
**************************************************************************** */
if ($_SESSION['setting']->checkPostedCapturingParameters($_POST)) {
if ($saveToDB) {
$saved = $_SESSION['setting']->save();
$message = $_SESSION['setting']->message();
if ($saved) {
header("Location: " . $pageToGo);
exit();
}
}
header("Location: " . $pageToGo);
exit();
} else {
$message = $_SESSION['setting']->message();
}
/* *****************************************************************************
*
* CREATE THE PAGE
*
**************************************************************************** */
// Javascript includes
$script = array("settings.js", "quickhelp/help.js",
"quickhelp/capturingParameterHelp.js");
include("header.inc.php");
// If all necessaty Parameters were set, the Nyquist rate can be calculated
// displayed. If not, we inform the user
if ($_SESSION['setting']->isSted() || $_SESSION['setting']->isSpim()
|| $_SESSION['setting']->isSted3D()) {
$NyquistMessage = "To calculate the ideal sampling sizes for this " .
"microscope type please consult the online Nyquist " .
"calculator below.";
} else {
$nyquist = $_SESSION['setting']->calculateNyquistRate();
if ($nyquist === false) {
$NyquistMessage = "The optimal Nyquist sampling rate could not be " .
"calculated because not all necessary parameters were set in the " .
"previous pages. You can use the online Nyquist calculator instead.";
} else {
$NyquistMessage = "Calculated from current optical parameters, the " .
"(Nyquist) ideal pixel size is <span class=\"highlight\">" .
$nyquist[0] . " nm</span> " .
"and the ideal z-step is <span class=\"highlight\">" .
$nyquist[1] . " nm</span>.";
}
}
?>
<!--
Tooltips
-->
<?php
if ($_SESSION['setting']->isWidefield() ||
$_SESSION['setting']->isMultiPointConfocal()
) {
?>
<span class="toolTip" id="ttSpanPixelSizeFromCCD">
Calculate the image pixel size from the CCD pixel size.
</span>
<?php
}
?>
<?php
if ($_SESSION['setting']->hasPinhole()) {
?>
<span class="toolTip" id="ttSpanPinholeRadius">
Calculate the back-projected pinhole radius for your microscope.
</span>
<?php
if ($_SESSION['setting']->isNipkowDisk()) {
?>
<span class="toolTip" id="ttSpanPinholeSpacing">
Calculate the back-projected pinhole spacing for your microscope.
</span>
<?php
}
}
?>
<span class="toolTip" id="ttSpanNyquist">
Check your sampling with the online Nyquist calculator.
</span>
<span class="toolTip" id="ttSpanBack">
Go back to previous page.
</span>
<span class="toolTip" id="ttSpanCancel">
Abort editing and go back to the image parameters selection page.
All changes will be lost!
</span>
<?php
if ($saveToDB == true) {
$iconClass = "icon save";
?>
<span class="toolTip" id="ttSpanForward">
Save and return to the image parameters selection page.
</span>
<?php
} else {
$iconClass = "icon next";
?>
<span class="toolTip" id="ttSpanForward">Continue to next page.</span>
<?php
}
?>
<div id="nav">
<div id="navleft">
<ul>
<?php
echo(Nav::linkWikiPage('HuygensRemoteManagerHelpCaptor'));
?>
<li> [ <?php echo $_SESSION['setting']->name(); ?> ]</li>
</ul>
</div>
<div id="navright">
<ul>
<?php
echo(Nav::textUser($_SESSION['user']->name()));
?>
</ul>
</div>
<div class="clear"></div>
</div>
<div id="content">
<h3>Optical Parameters (2)</h3>
<form method="post" action="capturing_parameter.php" id="select">
<?php
/***************************************************************************
*
* CCDCaptorSizeX - CCDCaptorSizeY
***************************************************************************/
/** @var CCDCaptorSizeX $parameterCCDCaptorSizeX */
$parameterCCDCaptorSizeX =
$_SESSION['setting']->parameter("CCDCaptorSizeX");
?>
<fieldset class="setting
<?php echo $parameterCCDCaptorSizeX->confidenceLevel(); ?>"
onmouseover="changeQuickHelp( 'voxel' );">
<legend>
<a href="javascript:openWindow(
'http://www.svi.nl/SampleSize')">
<img src="images/help.png" alt="?"/>
</a>
Voxel Size
</legend>
<h4>How were these images captured?</h4>
<p class="message_confidence_<?php echo $parameterCCDCaptorSizeX->confidenceLevel(); ?>"></p>
<?php
$value = $parameterCCDCaptorSizeX->value();
?>
<table id="table_nyquist">
<tr>
<td>
<?php
if ($_SESSION['setting']->isArrDetConf()) {
$textForCaptorSize = "X pixel size (nm)";
} else {
$textForCaptorSize = "XY pixel size (nm)";
}
echo $textForCaptorSize; ?>
</td>
<td>
<input id="CCDCaptorSizeX"
title="Pixel size"
name="CCDCaptorSizeX"
type="text"
size="5"
value="<?php echo $value ?>"/>
</td>
<td>
<?php
// The calculation of pixel size from CCD chip makes sense
// only for widefield microscopes
if ($_SESSION['setting']->isWidefield() ||
$_SESSION['setting']->isMultiPointConfocal()
) {
?>
<p>
<a href="#"
onmouseover="TagToTip('ttSpanPixelSizeFromCCD' )"
onmouseout="UnTip()"
onclick="storeValuesAndRedirect( 'calculate_pixel_size.php');">
<img src="images/calc_small.png" alt=""/>
Calculate from CCD pixel size
</a>
</p>
<?php
}
?>
</td>
</tr>
<tr>
<td>
<?php
if ($_SESSION['setting']->isArrDetConf()) {
$textForCaptorSize = "Y pixel size (nm)";
echo $textForCaptorSize;
}
?>
</td>
<td>
<?php
if ($_SESSION['setting']->isArrDetConf()) {
$parameterCCDCaptorSizeY =
$_SESSION['setting']->parameter("CCDCaptorSizeY");
$value = $parameterCCDCaptorSizeY->value();
?>
<input id="CCDCaptorSizeY"
title="Pixel size"
name="CCDCaptorSizeY"
type="text"
size="5"
value="<?php echo $value ?>"/>
<?php
}
?>
</td>
<?php
if ($_SESSION['setting']->isArrDetConf()) {
?>
<td>
<span class="message_small">
Notice that <b>Y pixel size should be 4 * X pixel size</b> in Airyscan Fast Mode!
</span>
</td>
<?php
}
?>
</tr>
<tr>
<td>
Z-step (nm):
</td>
<?php
/***************************************************************************
*
* ZStepSize
***************************************************************************/
/** @var ZStepSize $parameterZStepSize */
$parameterZStepSize = $_SESSION['setting']->parameter("ZStepSize");
?>
<td>
<input id="ZStepSize"
title="Z step size"
name="ZStepSize"
type="text"
size="5"
value="<?php echo $parameterZStepSize->value() ?>"/>
</td>
<td>
<span class="message_small">
Set to <b>Nyquist rate in Z</b> for 2D datasets.
</span>
</td>
</tr>
</table>
<p class="message_small"><?php echo $NyquistMessage; ?></p>
<p></p>
<a href="#"
onmouseover="TagToTip('ttSpanNyquist')"
onmouseout="UnTip()"
onclick="storeValuesAndRedirectExtern(
'https://svi.nl/NyquistCalculator');">
<img src="images/calc_small.png" alt=""/>
Online Nyquist rate and PSF calculator
<img src="images/web.png" alt="external link"/>
</a>
</fieldset>
<?php
/***************************************************************************
*
* TimeInterval
***************************************************************************/
/** @var TimeInterval $parameterTimeInterval */
$parameterTimeInterval = $_SESSION['setting']->parameter("TimeInterval");
?>
<fieldset class="setting
<?php echo $parameterTimeInterval->confidenceLevel(); ?>"
onmouseover="changeQuickHelp( 'time' );">
<legend>
<a href="javascript:openWindow(
'http://www.svi.nl/TimeSeries')">
<img src="images/help.png" alt="?"/>
</a>
Time Interval
</legend>
<p class="message_confidence_<?php echo $parameterTimeInterval->confidenceLevel(); ?>"></p>
<ul>
<li>Time interval (s):
<input id="TimeInterval"
title="Time interval"
name="TimeInterval"
type="text"
size="5"
value="<?php echo $parameterTimeInterval->value() ?>"/>
<span class="message_small">
Set to <b>0</b> for a single time point.
</span>
</li>
</ul>
</fieldset>
<?php
if ($_SESSION['setting']->hasPinhole()) {
/***************************************************************************
*
* PinholeSize
***************************************************************************/
/** @var PinholeSize $parameterPinholeSize */
$parameterPinholeSize = $_SESSION['setting']->parameter("PinholeSize");
?>
<fieldset class="setting
<?php echo $parameterPinholeSize->confidenceLevel(); ?>"
onmouseover="changeQuickHelp( 'pinhole_radius' );">
<legend>
<a href="javascript:openWindow(
'http://www.svi.nl/PinholeRadius')">
<img src="images/help.png" alt="?"/>
</a>
Backprojected Pinhole Radius
</legend>
<p class="message_confidence_<?php echo $parameterPinholeSize->confidenceLevel(); ?>"></p>
<ul>
<li>backprojected pinhole radius (nm):</li>
</ul>
<?php
if ($_SESSION['setting']->numberOfChannels() > 1) {
?> <p></p> <?php
}
?>
<div class="multichannel">
<?php
// manage one pinhole radius per channel
for ($i = 0; $i < $_SESSION['setting']->numberOfChannels(); $i++) {
/* Add a line break after a number of entries. */
if ($_SESSION['setting']->numberOfChannels() == 4) {
if ($i == 2) {
echo "<br />";
}
} else {
if ($i == 3) {
echo "<br />";
}
}
?>
<span class="nowrap">
Ch<?php echo $i ?>:
<span class="multichannel">
<input id="PinholeSize<?php echo $i ?>"
name="PinholeSize<?php echo $i ?>"
title="Pinhole size channel <?php echo $i ?>"
type="text"
size="8"
value="<?php if ($i < sizeof($pinhole)) echo $pinhole[$i] ?>"
class="multichannelinput"/>
</span>
</span>
<?php
}
?></div>
<p></p>
<?php
/** @var NumericalAperture $parameterNA */
$parameterNA = $_SESSION['setting']->parameter("NumericalAperture");
$na = $parameterNA->value();
?>
<a href="#"
onmouseover="TagToTip('ttSpanPinholeRadius' )"
onmouseout="UnTip()"
onclick="storeValuesAndRedirect(
'calculate_bp_pinhole.php?na=<?php echo $na; ?>');">
<img src="images/calc_small.png" alt=""/>
Backprojected pinhole calculator
</a>
</fieldset>
<?php
}
?>
<?php
if ($_SESSION['setting']->isNipkowDisk()) {
/***************************************************************************
*
* PinholeSpacing
***************************************************************************/
/** @var PinholeSpacing $parameterPinholeSpacing */
$parameterPinholeSpacing = $_SESSION['setting']->parameter('PinholeSpacing');
?>
<fieldset class="setting
<?php echo $parameterPinholeSpacing->confidenceLevel(); ?>"
onmouseover="changeQuickHelp( 'pinhole_spacing' );">
<legend>
<a href="javascript:openWindow(
'http://www.svi.nl/PinholeSpacing')">
<img src="images/help.png" alt="?"/>
</a>
Backprojected Pinhole Spacing
</legend>
<p class="message_confidence_<?php echo $parameterPinholeSpacing->confidenceLevel(); ?>"></p>
<ul>
<li>backprojected pinhole spacing (micron):
<input id="PinholeSpacing"
title="Pinhole spacing"
name="PinholeSpacing"
type="text"
size="5"
value="<?php echo $parameterPinholeSpacing->value() ?>"/>
</li>
</ul>
<p></p>
<a href="#"
onmouseover="TagToTip('ttSpanPinholeSpacing' )"
onmouseout="UnTip()"
onclick="storeValuesAndRedirect(
'calculate_bp_pinhole.php?na=<?php echo $na; ?>');">
<img src="images/calc_small.png" alt=""/>
Backprojected pinhole calculator
</a>
</fieldset>
<?php
}
?>
<div><input name="OK" type="hidden"/></div>
<div id="controls"
onmouseover="changeQuickHelp( 'default' )">
<input type="button" value="" class="icon previous"
onmouseover="TagToTip('ttSpanBack' )"
onmouseout="UnTip()"
onclick="deleteValuesAndRedirect(
'microscope_parameter.php' );"/>
<input type="button" value="" class="icon up"
onmouseover="TagToTip('ttSpanCancel' )"
onmouseout="UnTip()"
onclick="deleteValuesAndRedirect(
'select_parameter_settings.php' );"/>
<input type="submit" value="" class="<?php echo $iconClass; ?>"
onmouseover="TagToTip('ttSpanForward' )"
onmouseout="UnTip()"
onclick="deleteValuesAndProcess();"/>
</div>
</form>
</div> <!-- content -->
<div id="rightpanel"
onmouseover="changeQuickHelp( 'default' )">
<div id="info">
<h3>Quick help</h3>
<div id="contextHelp">
<p>Here you have to enter the voxel size as it was set during
the image acquisition. Depending on the microscope type and the
dataset geometry, you might have to enter additional parameters,
such as the back-projected pinhole size and spacing, and the
time
interval for time series. For microscope types that use cameras
(such as widefield and spinning disk confocal), you have the
possibility to calculate the image pixel size from the camera
pixel size, total magnification, and binning.
</p>
<p>
In <b>Airyscan Fast Mode</b> the sampling size in the Y direction is 4
times as large as the sampling size in the X direction.
</p>
</div>
<?php
if (!$_SESSION["user"]->isAdmin()) {
?>
<div class="requirements">
Parameter requirements<br/>adapted for <b>
<?php
$fileFormat = $_SESSION['setting']->parameter("ImageFileFormat");
echo $fileFormat->value();
?>
</b> files
</div>
<?php
}
?>
</div>
<div id="message">
<?php
echo "<p>$message</p>";
?>
</div>
</div> <!-- rightpanel -->
<?php
include("footer.inc.php");
// Another horrible hack to work around an inexplicable IE8 behavior
if (Util::using_IE() && !isset($_SERVER['HTTP_REFERER'])) {
?>
<script type="text/javascript">
$(document).ready(retrieveValues());
</script>
<?php
}
if (!(strpos($_SERVER['HTTP_REFERER'],
'calculate_pixel_size.php') === false)
) {
if (isset($_SESSION['CCDCaptorSizeX_Calculated']) &&
$_SESSION['CCDCaptorSizeX_Calculated'] == 'true'
) {
?>
<script type="text/javascript">
$(document).ready(retrieveValues(new Array('CCDCaptorSizeX')));
</script>
<?php
// Now remove the SNR_Calculated flag
unset($_SESSION['CCDCaptorSizeX_Calculated']);
} else {
?>
<script type="text/javascript">
$(document).ready(retrieveValues());
</script>
<?php
}
}
if (!(strpos($_SERVER['HTTP_REFERER'],
'calculate_bp_pinhole.php') === false)
) {
?>
<script type="text/javascript">
$(document).ready(retrieveValues());
</script>
<?php
}
?>