-
Notifications
You must be signed in to change notification settings - Fork 13
/
libics_sensor.c
1175 lines (1014 loc) · 38.1 KB
/
libics_sensor.c
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
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* libics: Image Cytometry Standard file reading and writing.
*
* Copyright 2015-2019:
* Scientific Volume Imaging Holding B.V.
* Hilversum, The Netherlands.
* https://www.svi.nl
*
* Copyright (C) 2000-2013 Cris Luengo and others
*
* Large chunks of this library written by
* Bert Gijsbers
* Dr. Hans T.M. van der Voort
* And also Damir Sudar, Geert van Kempen, Jan Jitze Krol,
* Chiel Baarslag and Fons Laan.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* FILE : libics_sensor.c
* Written by Bert Gijsbers, Scientific Volume Imaging BV, Hilversum, NL
*
* The following library functions are contained in this file:
*
* IcsEnableWriteSensor
* IcsSetSensorType
* IcsSetSensorModel
* IcsSetSensorChannels
* IcsSetSensorPinholeRadius
* IcsSetSensorExcitationWavelength
* IcsSetSensorEmissionWavelength
* IcsSetSensorPhotonCount
* IcsSetSensorMediumRI
* IcsSetSensorLensRI
* IcsSetSensorNumAperture
* IcsSetSensorPinholeSpacing
* IcsSetSTEDMode
* IcsSetSTEDLambda
* IcsSetSTEDSaturationFactor
* IcsSetSTEDImmunityFactor
* IcsSetSTEDVortexToPhasePlateMix
* IcsSetDetectorPPU
* IcsSetDetectorBaseline
* IcsSetDetectorLineAvgCnt
* IcsSetDetectorNoiseGain
*/
#include <stdlib.h>
#include <string.h>
#include "libics_sensor.h"
#include "libics_intern.h"
/* This function enables writing the sensor parameters to disk. */
Ics_Error IcsEnableWriteSensor(ICS *ics,
int enable)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->writeSensor = enable ? 1 : 0;
return IcsErr_Ok;
}
/* This function enables writing the sensor parameter statess to disk. */
Ics_Error IcsEnableWriteSensorStates(ICS *ics,
int enable)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->writeSensorStates = enable ? 1 : 0;
return IcsErr_Ok;
}
/* Get the sensor type string of a sensor channel. */
char const* IcsGetSensorType(const ICS *ics,
int channel)
{
return ics->type[channel];
}
/* Set the sensor type string for a sensor channel. */
Ics_Error IcsSetSensorType(ICS *ics,
int channel,
const char *sensorType)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
IcsStrCpy(ics->type[channel], sensorType, sizeof(ics->type[channel]));
return IcsErr_Ok;
}
/* Get the sensor model string. */
const char *IcsGetSensorModel(const ICS *ics)
{
return ics->model;
}
/* Set the sensor model string. */
Ics_Error IcsSetSensorModel(ICS *ics,
const char *sensorModel)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
IcsStrCpy(ics->model, sensorModel, sizeof(ics->model));
return IcsErr_Ok;
}
/* Get the number of sensor channels. */
int IcsGetSensorChannels(const ICS *ics)
{
return ics->sensorChannels;
}
/* Set the number of sensor channels. */
Ics_Error IcsSetSensorChannels(ICS *ics,
int channels)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channels < 0 || channels > ICS_MAX_LAMBDA)
return IcsErr_NotValidAction;
ics->sensorChannels = channels;
return IcsErr_Ok;
}
/* Get the number of sensor detectors. */
int IcsGetSensorDetectors(const ICS *ics)
{
return ics->sensorDetectors;
}
/* Set the number of sensor detectors. */
Ics_Error IcsSetSensorDetectors(ICS *ics,
int detectors)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (detectors < 0 || detectors > ICS_MAX_DETECT)
return IcsErr_NotValidAction;
ics->sensorDetectors = detectors;
return IcsErr_Ok;
}
/* Get the pinhole radius for a sensor channel. */
double IcsGetSensorPinholeRadius(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->pinholeRadius[channel];
}
/* Set the pinhole radius for a sensor channel. */
Ics_Error IcsSetSensorPinholeRadius(ICS *ics,
int channel,
double radius)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->pinholeRadius[channel] = radius;
return IcsErr_Ok;
}
/* Get the excitation wavelength for a sensor channel. */
double IcsGetSensorExcitationWavelength(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->lambdaEx[channel];
}
/* Set the excitation wavelength for a sensor channel. */
Ics_Error IcsSetSensorExcitationWavelength(ICS *ics,
int channel,
double wl)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->lambdaEx[channel] = wl;
return IcsErr_Ok;
}
/* Get the emission wavelength for a sensor channel. */
double IcsGetSensorEmissionWavelength(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->lambdaEm[channel];
}
/* Set the emission wavelength for a sensor channel. */
Ics_Error IcsSetSensorEmissionWavelength(ICS *ics,
int channel,
double wl)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->lambdaEm[channel] = wl;
return IcsErr_Ok;
}
/* Get the excitation photon count for a sensor channel. */
int IcsGetSensorPhotonCount(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->exPhotonCnt[channel];
}
/* Set the excitation photon count for a sensor channel. */
Ics_Error IcsSetSensorPhotonCount(ICS *ics,
int channel,
int cnt)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->exPhotonCnt[channel] = cnt;
return IcsErr_Ok;
}
/* Get the sensor embedding medium refractive index. */
double IcsGetSensorMediumRI(const ICS *ics)
{
return ics->refrInxMedium;
}
/* Set the sensor embedding medium refractive index. */
Ics_Error IcsSetSensorMediumRI(ICS *ics,
double ri)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->refrInxMedium = ri;
return IcsErr_Ok;
}
/* Get the sensor design medium refractive index. */
double IcsGetSensorLensRI(const ICS *ics)
{
return ics->refrInxLensMedium;
}
/* Set the sensor design medium refractive index. */
Ics_Error IcsSetSensorLensRI(ICS *ics,
double ri)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->refrInxLensMedium = ri;
return IcsErr_Ok;
}
/* Get the sensor numerical apperture */
double IcsGetSensorNumAperture(const ICS *ics)
{
return ics->numAperture;
}
/* Set the sensor numerical apperture */
Ics_Error IcsSetSensorNumAperture(ICS *ics,
double na)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->numAperture = na;
return IcsErr_Ok;
}
/* Get the sensor Nipkow Disk pinhole spacing. */
double IcsGetSensorPinholeSpacing(const ICS *ics)
{
return ics->pinholeSpacing;
}
/* Set the sensor Nipkow Disk pinhole spacing. */
Ics_Error IcsSetSensorPinholeSpacing(ICS *ics,
double spacing)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
ics->pinholeSpacing = spacing;
return IcsErr_Ok;
}
/* Get the STED mode per channel. */
const char * IcsGetSensorSTEDDepletionMode(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->stedDepletionMode[channel];
}
/* Set the STED depletion mode per channel. */
Ics_Error IcsSetSensorSTEDDepletionMode(ICS *ics,
int channel,
const char *depletionMode)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
IcsStrCpy(ics->stedDepletionMode[channel], depletionMode,
sizeof(ics->stedDepletionMode[channel]));
return IcsErr_Ok;
}
/* Get the STED inhibition wavelength per channel. */
double IcsGetSensorSTEDLambda(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->stedLambda[channel];
}
/* Set the STED inhibition wavelength per channel. */
Ics_Error IcsSetSensorSTEDLambda(ICS *ics,
int channel,
double lambda)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->stedLambda[channel] = lambda;
return IcsErr_Ok;
}
/* Get the STED saturation factor per channel. */
double IcsGetSensorSTEDSatFactor(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->stedSatFactor[channel];
}
/* Set the STED saturation factor per channel. */
Ics_Error IcsSetSensorSTEDSatFactor(ICS *ics,
int channel,
double factor)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->stedSatFactor[channel] = factor;
return IcsErr_Ok;
}
/* Get the STED immunity fraction per channel. */
double IcsGetSensorSTEDImmFraction(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->stedImmFraction[channel];
}
/* Set the STED immunity fraction per channel. */
Ics_Error IcsSetSensorSTEDImmFraction(ICS *ics,
int channel,
double fraction)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->stedImmFraction[channel] = fraction;
return IcsErr_Ok;
}
/* Get the STED vortex to phase plate mix per channel. */
double IcsGetSensorSTEDVPPM(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->stedVPPM[channel];
}
/* Set the STED vortex to phase plate mix per channel. */
Ics_Error IcsSetSensorSTEDVPPM(ICS *ics,
int channel,
double vppm)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->stedVPPM[channel] = vppm;
return IcsErr_Ok;
}
/* Get the Detector ppu per channel. */
double IcsGetSensorDetectorPPU(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->detectorPPU[channel];
}
/* Set the Detector ppu per channel. */
Ics_Error IcsSetSensorDetectorPPU(ICS *ics,
int channel,
double ppu)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->detectorPPU[channel] = ppu;
return IcsErr_Ok;
}
/* Get the Detector baseline per channel. */
double IcsGetSensorDetectorBaseline(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->detectorBaseline[channel];
}
/* Set the Detector baseline per channel. */
Ics_Error IcsSetSensorDetectorBaseline(ICS *ics,
int channel,
double baseline)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->detectorBaseline [channel] = baseline;
return IcsErr_Ok;
}
/* Get the Detector lineAvgCnt per channel. */
double IcsGetSensorDetectorLineAvgCnt(const ICS *ics,
int channel)
{
if (channel < 0 || channel >= ics->sensorChannels)
return 0;
else
return ics->detectorLineAvgCnt[channel];
}
/* Set the Detector lineAvgCnt per channel. */
Ics_Error IcsSetSensorDetectorLineAvgCnt(ICS *ics,
int channel,
double lineAvgCnt)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
ics->detectorLineAvgCnt[channel] = lineAvgCnt;
return IcsErr_Ok;
}
/* Get the state of a sensor parameter. */
Ics_Error IcsGetSensorParameter(const ICS *ics,
Ics_SensorParameter parameter,
int channel,
double *value,
Ics_SensorState *state)
{
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
switch (parameter) {
case ICS_SENSOR_NUMERICAL_APERTURE:
*value = ics->numAperture;
*state = ics->numApertureState;
break;
case ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX:
*value = ics->refrInxMedium;
*state = ics->refrInxMediumState;
break;
case ICS_SENSOR_LENS_REFRACTIVE_INDEX:
*value = ics->refrInxLensMedium;
*state = ics->refrInxLensMediumState;
break;
case ICS_SENSOR_PINHOLE_RADIUS:
*value = ics->pinholeRadius[channel];
*state = ics->pinholeRadiusState[channel];
break;
case ICS_SENSOR_ILL_PINHOLE_RADIUS:
*value = ics->illPinholeRadius[channel];
*state = ics->illPinholeRadiusState[channel];
break;
case ICS_SENSOR_PINHOLE_SPACING:
*value = ics->pinholeSpacing;
*state = ics->pinholeSpacingState;
break;
case ICS_SENSOR_EXCITATION_BEAM_FILL:
*value = ics->excitationBeamFill[channel];
*state = ics->excitationBeamFill[channel];
break;
case ICS_SENSOR_LAMBDA_EXCITATION:
*value = ics->lambdaEx[channel];
*state = ics->lambdaExState[channel];
break;
case ICS_SENSOR_LAMBDA_EMISSION:
*value = ics->lambdaEm[channel];
*state = ics->lambdaEmState[channel];
break;
case ICS_SENSOR_PHOTON_COUNT:
*value = ics->exPhotonCnt[channel];
*state = ics->exPhotonCntState[channel];
break;
case ICS_SENSOR_INTERFACE_PRIMARY:
*value = ics->interfacePrimary;
*state = ics->interfacePrimaryState;
break;
case ICS_SENSOR_INTERFACE_SECONDARY:
*value = ics->interfaceSecondary;
*state = ics->interfaceSecondaryState;
break;
case ICS_SENSOR_DETECTOR_MAGN:
*value = ics->detectorMagn[channel];
*state = ics->detectorMagnState[channel];
break;
case ICS_SENSOR_DETECTOR_PPU:
*value = ics->detectorPPU[channel];
*state = ics->detectorPPUState[channel];
break;
case ICS_SENSOR_DETECTOR_BASELINE:
*value = ics->detectorBaseline[channel];
*state = ics->detectorBaselineState[channel];
break;
case ICS_SENSOR_DETECTOR_LINE_AVG_COUNT:
*value = ics->detectorLineAvgCnt[channel];
*state = ics->detectorLineAvgCntState[channel];
break;
case ICS_SENSOR_DETECTOR_NOISE_GAIN:
*value = ics->detectorNoiseGain[channel];
*state = ics->detectorNoiseGainState[channel];
break;
case ICS_SENSOR_DETECTOR_SCALE:
*value = ics->detectorScale[channel];
*state = ics->detectorScaleState[channel];
break;
case ICS_SENSOR_DETECTOR_STRETCH:
*value = ics->detectorStretch[channel];
*state = ics->detectorStretchState[channel];
break;
case ICS_SENSOR_DETECTOR_ROT:
*value = ics->detectorRot[channel];
*state = ics->detectorRotState[channel];
break;
case ICS_SENSOR_STED_LAMBDA:
*value = ics->stedLambda[channel];
*state = ics->stedLambdaState[channel];
break;
case ICS_SENSOR_STED_SATURATION_FACTOR:
*value = ics->stedSatFactor[channel];
*state = ics->stedSatFactorState[channel];
break;
case ICS_SENSOR_STED_IMM_FRACTION:
*value = ics->stedImmFraction[channel];
*state = ics->stedImmFractionState[channel];
break;
case ICS_SENSOR_STED_VPPM:
*value = ics->stedVPPM[channel];
*state = ics->stedVPPMState[channel];
break;
case ICS_SENSOR_SPIM_FILL_FACTOR:
*value = ics->spimFillFactor[channel];
*state = ics->spimFillFactorState[channel];
break;
case ICS_SENSOR_SPIM_PLANE_NA:
*value = ics->spimPlaneNA[channel];
*state = ics->spimPlaneNAState[channel];
break;
case ICS_SENSOR_SPIM_PLANE_GAUSS_WIDTH:
*value = ics->spimPlaneGaussWidth[channel];
*state = ics->spimPlaneGaussWidthState[channel];
break;
case ICS_SENSOR_SPIM_PLANE_CENTER_OFF:
*value = ics->spimPlaneCenterOff[channel];
*state = ics->spimPlaneCenterOffState[channel];
break;
case ICS_SENSOR_SPIM_PLANE_FOCUS_OFF:
*value = ics->spimPlaneFocusOff[channel];
*state = ics->spimPlaneFocusOffState[channel];
break;
case ICS_SENSOR_SCATTER_FREE_PATH:
*value = ics->scatterFreePath[channel];
*state = ics->scatterFreePathState[channel];
break;
case ICS_SENSOR_SCATTER_REL_CONTRIB:
*value = ics->scatterRelContrib[channel];
*state = ics->scatterRelContribState[channel];
break;
case ICS_SENSOR_SCATTER_BLURRING:
*value = ics->scatterBlurring[channel];
*state = ics->scatterBlurringState[channel];
break;
default:
*value = 0;
*state = IcsSensorState_default;
return IcsErr_NotValidAction;
}
return IcsErr_Ok;
}
/* Get the state of a vector sensor parameter. */
Ics_Error IcsGetSensorParameterVector(const ICS *ics,
Ics_SensorParameter parameter,
int channel,
const double **values,
Ics_SensorState *state)
{
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
switch (parameter) {
case ICS_SENSOR_SPIM_PLANE_PROP_DIR:
*values = ics->spimPlanePropDir[channel];
*state = ics->spimPlanePropDirState[channel];
break;
case ICS_SENSOR_DETECTOR_SENSITIVITY:
*values = ics->detectorSensitivity[channel];
*state = ics->detectorSensitivityState[channel];
break;
case ICS_SENSOR_DETECTOR_RADIUS:
*values = ics->detectorRadius[channel];
*state = ics->detectorRadiusState[channel];
break;
default:
*values = NULL;
*state = IcsSensorState_default;
return IcsErr_NotValidAction;
}
return IcsErr_Ok;
}
/* Get the state of a matrix sensor parameter. Sets **values to a pointer to
the matrix, which effectively becomes a flattened array. */
Ics_Error IcsGetSensorParameterMatrix(const ICS *ics,
Ics_SensorParameter parameter,
int channel,
const double **values,
Ics_SensorState *state)
{
if (channel < 0 || channel >= ics->sensorChannels) {
return IcsErr_NotValidAction;
}
switch (parameter) {
case ICS_SENSOR_DETECTOR_OFFSET:
*values = (const double*)ics->detectorOffset[channel];
*state = ics->detectorOffsetState[channel];
break;
default:
*values = NULL;
*state = IcsSensorState_default;
return IcsErr_NotValidAction;
}
return IcsErr_Ok;
}
/* Get the state of a sensor parameter. */
Ics_Error IcsGetSensorParameterInt(const ICS *ics,
Ics_SensorParameter parameter,
int channel,
int *value,
Ics_SensorState *state)
{
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
switch (parameter) {
case ICS_SENSOR_OBJECTIVE_QUALITY:
*value = ics->objectiveQuality[channel];
*state = ics->objectiveQualityState[channel];
break;
case ICS_SENSOR_PHOTON_COUNT:
*value = ics->exPhotonCnt[channel];
*state = ics->exPhotonCntState[channel];
break;
default:
*value = 0;
*state = IcsSensorState_default;
return IcsErr_NotValidAction;
}
return IcsErr_Ok;
}
/* Get the state of a sensor parameter. */
Ics_Error IcsGetSensorParameterString(const ICS *ics,
Ics_SensorParameter parameter,
int channel,
const char **value,
Ics_SensorState *state)
{
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
switch (parameter) {
case ICS_SENSOR_DETECTOR_MIRROR:
*value = ics->detectorMirror[channel];
*state = ics->detectorMirrorState[channel];
break;
case ICS_SENSOR_DETECTOR_MODEL:
*value = ics->detectorModel[channel];
*state = ics->detectorModelState[channel];
break;
case ICS_SENSOR_DETECTOR_REDUCEHIST:
*value = ics->detectorRedHist[channel];
*state = ics->detectorRedHistState[channel];
break;
case ICS_SENSOR_IMAGING_DIRECTION:
*value = ics->imagingDirection[channel];
*state = ics->imagingDirectionState[channel];
break;
case ICS_SENSOR_STED_DEPLETION_MODE:
*value = ics->stedDepletionMode[channel];
*state = ics->stedDepletionModeState[channel];
break;
case ICS_SENSOR_SPIM_EXCITATION_TYPE:
*value = ics->spimExcType[channel];
*state = ics->spimExcTypeState[channel];
break;
case ICS_SENSOR_SCATTER_MODEL:
*value = ics->scatterModel[channel];
*state = ics->scatterModelState[channel];
break;
case ICS_SENSOR_DESCRIPTION:
*value = ics->description[channel];
*state = ics->descriptionState[channel];
break;
default:
*value = "";
*state = IcsSensorState_default;
return IcsErr_NotValidAction;
}
return IcsErr_Ok;
}
/* Set the state of a sensor parameter. */
Ics_Error IcsSetSensorParameter(ICS *ics,
Ics_SensorParameter parameter,
int channel,
double value,
Ics_SensorState state)
{
if ((ics == NULL) || (ics->fileMode == IcsFileMode_read))
return IcsErr_NotValidAction;
if (channel < 0 || channel >= ics->sensorChannels)
return IcsErr_NotValidAction;
switch (parameter) {
case ICS_SENSOR_NUMERICAL_APERTURE:
ics->numAperture = value;
ics->numApertureState = state;
break;
case ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX:
ics->refrInxMedium = value;
ics->refrInxMediumState = state;
break;
case ICS_SENSOR_LENS_REFRACTIVE_INDEX:
ics->refrInxLensMedium = value;
ics->refrInxLensMediumState = state;
break;
case ICS_SENSOR_PINHOLE_RADIUS:
ics->pinholeRadius[channel] = value;
ics->pinholeRadiusState[channel] = state;
break;
case ICS_SENSOR_ILL_PINHOLE_RADIUS:
ics->illPinholeRadius[channel] = value;
ics->illPinholeRadiusState[channel] = state;
break;
case ICS_SENSOR_PINHOLE_SPACING:
ics->pinholeSpacing = value;
ics->pinholeSpacingState = state;
break;
case ICS_SENSOR_EXCITATION_BEAM_FILL:
ics->excitationBeamFill[channel] = value;
ics->excitationBeamFillState[channel] = state;
break;
case ICS_SENSOR_LAMBDA_EXCITATION:
ics->lambdaEx[channel] = value;
ics->lambdaExState[channel] = state;
break;
case ICS_SENSOR_LAMBDA_EMISSION:
ics->lambdaEm[channel] = value;
ics->lambdaEmState[channel] = state;
break;
case ICS_SENSOR_PHOTON_COUNT:
ics->exPhotonCnt[channel] = (int)value;
ics->exPhotonCntState[channel] = state;
break;
case ICS_SENSOR_INTERFACE_PRIMARY:
ics->interfacePrimary = value;
ics->interfacePrimaryState = state;
break;
case ICS_SENSOR_INTERFACE_SECONDARY:
ics->interfaceSecondary = value;
ics->interfaceSecondaryState = state;
break;
case ICS_SENSOR_DETECTOR_MAGN:
ics->detectorMagn[channel] = value;
ics->detectorMagnState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_PPU:
ics->detectorPPU[channel] = value;
ics->detectorPPUState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_BASELINE:
ics->detectorBaseline[channel] = value;
ics->detectorBaselineState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_LINE_AVG_COUNT:
ics->detectorLineAvgCnt[channel] = value;
ics->detectorLineAvgCntState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_NOISE_GAIN:
ics->detectorNoiseGain[channel] = value;
ics->detectorNoiseGainState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_SCALE:
ics->detectorScale[channel] = value;
ics->detectorScaleState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_STRETCH:
ics->detectorStretch[channel] = value;
ics->detectorStretchState[channel] = state;
break;
case ICS_SENSOR_DETECTOR_ROT:
ics->detectorRot[channel] = value;
ics->detectorRotState[channel] = state;
break;
case ICS_SENSOR_STED_LAMBDA:
ics->stedLambda[channel] = value;
ics->stedLambdaState[channel] = state;
break;
case ICS_SENSOR_STED_SATURATION_FACTOR:
ics->stedSatFactor[channel] = value;
ics->stedSatFactorState[channel] = state;
break;
case ICS_SENSOR_STED_IMM_FRACTION:
ics->stedImmFraction[channel] = value;
ics->stedImmFractionState[channel] = state;
break;
case ICS_SENSOR_STED_VPPM:
ics->stedVPPM[channel] = value;
ics->stedVPPMState[channel] = state;
break;
case ICS_SENSOR_SPIM_FILL_FACTOR:
ics->spimFillFactor[channel] = value;
ics->spimFillFactorState[channel] = state;
break;
case ICS_SENSOR_SPIM_PLANE_NA:
ics->spimPlaneNA[channel] = value;
ics->spimPlaneNAState[channel] = state;
break;
case ICS_SENSOR_SPIM_PLANE_GAUSS_WIDTH:
ics->spimPlaneGaussWidth[channel] = value;
ics->spimPlaneGaussWidthState[channel] = state;
break;
case ICS_SENSOR_SPIM_PLANE_CENTER_OFF:
ics->spimPlaneCenterOff[channel] = value;
ics->spimPlaneCenterOffState[channel] = state;
break;
case ICS_SENSOR_SPIM_PLANE_FOCUS_OFF:
ics->spimPlaneFocusOff[channel] = value;
ics->spimPlaneFocusOffState[channel] = state;
break;
case ICS_SENSOR_SCATTER_FREE_PATH:
ics->scatterFreePath[channel] = value;
ics->scatterFreePathState[channel] = state;
break;
case ICS_SENSOR_SCATTER_REL_CONTRIB:
ics->scatterRelContrib[channel] = value;
ics->scatterRelContribState[channel] = state;
break;
case ICS_SENSOR_SCATTER_BLURRING:
ics->scatterBlurring[channel] = value;
ics->scatterBlurringState[channel] = state;
break;
default:
return IcsErr_NotValidAction;
}