[med-svn] [Git][med-team/libics][upstream] New upstream version 1.6.2

Andreas Tille gitlab at salsa.debian.org
Wed May 2 14:53:52 BST 2018


Andreas Tille pushed to branch upstream at Debian Med / libics


Commits:
05af19a6 by Andreas Tille at 2017-12-02T08:14:00+01:00
New upstream version 1.6.2
- - - - -


10 changed files:

- CMakeLists.txt
- configure.ac
- libics.h
- libics_data.c
- libics_intern.h
- libics_read.c
- libics_sensor.c
- libics_util.c
- libics_write.c
- test_strides3.c


Changes:

=====================================
CMakeLists.txt
=====================================
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@
 ##############################################################################
 cmake_minimum_required(VERSION 3.0)
 
-project(libics VERSION 1.6.1)
+project(libics VERSION 1.6.2)
 
 # Note: the version number above is not yet used anywhere.
 # TODO: rewrite the header file with this version number.
@@ -44,7 +44,7 @@ if(USE_ZLIB)
 endif()
 
 # ICS
-configure_file(libics_conf.h.in ${CMAKE_SOURCE_DIR}/libics_conf.h COPYONLY)
+configure_file(libics_conf.h.in ${PROJECT_SOURCE_DIR}/libics_conf.h COPYONLY)
 set(SOURCES
       libics_binary.c
       libics_compress.c
@@ -69,7 +69,7 @@ set(HEADERS
       libics_test.h
       )
 
-include_directories(${CMAKE_SOURCE_DIR})
+include_directories(${PROJECT_SOURCE_DIR})
 
 # Build a dll
 add_library(libics SHARED ${SOURCES} ${HEADERS})
@@ -123,22 +123,22 @@ add_custom_target(all_tests DEPENDS
       test_metadata
       test_history
       )
-add_test(ctest_build_test_code "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target all_tests)
-add_test(NAME test_ics1 COMMAND test_ics1 ${CMAKE_SOURCE_DIR}/test/testim.ics result_v1.ics)
+add_test(ctest_build_test_code "${CMAKE_COMMAND}" --build ${PROJECT_BINARY_DIR} --target all_tests)
+add_test(NAME test_ics1 COMMAND test_ics1 ${PROJECT_SOURCE_DIR}/test/testim.ics result_v1.ics)
 set_tests_properties(test_ics1 PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_ics2a COMMAND test_ics2a ${CMAKE_SOURCE_DIR}/test/testim.ics result_v2a.ics)
+add_test(NAME test_ics2a COMMAND test_ics2a ${PROJECT_SOURCE_DIR}/test/testim.ics result_v2a.ics)
 set_tests_properties(test_ics2a PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_ics2b COMMAND test_ics2b ${CMAKE_SOURCE_DIR}/test/testim.ics result_v2b.ics)
+add_test(NAME test_ics2b COMMAND test_ics2b ${PROJECT_SOURCE_DIR}/test/testim.ics result_v2b.ics)
 set_tests_properties(test_ics2b PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_gzip COMMAND test_gzip ${CMAKE_SOURCE_DIR}/test/testim.ics result_v2z.ics)
+add_test(NAME test_gzip COMMAND test_gzip ${PROJECT_SOURCE_DIR}/test/testim.ics result_v2z.ics)
 set_tests_properties(test_gzip PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_compress COMMAND test_compress ${CMAKE_SOURCE_DIR}/test/testim.ics ${CMAKE_SOURCE_DIR}/test/testim_c.ics)
+add_test(NAME test_compress COMMAND test_compress ${PROJECT_SOURCE_DIR}/test/testim.ics ${PROJECT_SOURCE_DIR}/test/testim_c.ics)
 set_tests_properties(test_compress PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_strides COMMAND test_strides ${CMAKE_SOURCE_DIR}/test/testim.ics result_s.ics)
+add_test(NAME test_strides COMMAND test_strides ${PROJECT_SOURCE_DIR}/test/testim.ics result_s.ics)
 set_tests_properties(test_strides PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_strides2 COMMAND test_strides2 ${CMAKE_SOURCE_DIR}/test/testim.ics result_s2.ics)
+add_test(NAME test_strides2 COMMAND test_strides2 ${PROJECT_SOURCE_DIR}/test/testim.ics result_s2.ics)
 set_tests_properties(test_strides2 PROPERTIES DEPENDS ctest_build_test_code)
-add_test(NAME test_strides3 COMMAND test_strides3 ${CMAKE_SOURCE_DIR}/test/testim.ics result_s3.ics)
+add_test(NAME test_strides3 COMMAND test_strides3 ${PROJECT_SOURCE_DIR}/test/testim.ics result_s3.ics)
 set_tests_properties(test_strides3 PROPERTIES DEPENDS ctest_build_test_code)
 add_test(NAME test_metadata1 COMMAND test_metadata result_v1.ics)
 set_tests_properties(test_metadata1 PROPERTIES DEPENDS test_ics1)


=====================================
configure.ac
=====================================
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@ dnl Written by Peter Verveer, Cris Luengo
 dnl
 
 dnl Library version number (make sure to also change it in 'libics.h'):
-AC_INIT([libics], [1.6.1])
+AC_INIT([libics], [1.6.2])
 AC_CONFIG_SRCDIR([libics.h])
 AC_CONFIG_HEADERS([config.h libics_conf.h])
 AC_CONFIG_MACRO_DIR([m4])


=====================================
libics.h
=====================================
--- a/libics.h
+++ b/libics.h
@@ -50,7 +50,7 @@ extern "C" {
 #endif
 
 /* Library versioning is in the form major, minor, patch: */
-#define ICSLIB_VERSION "1.6.1" /* also defined in configure.ac */
+#define ICSLIB_VERSION "1.6.2" /* also defined in configure.ac */
 
 #if defined(__WIN32__) && !defined(WIN32)
 #define WIN32
@@ -156,19 +156,32 @@ typedef struct {
 /* A list of sensor parameters that are also equiped with a state. */
 typedef enum {
     ICS_SENSOR_FIRST,
-    ICS_SENSOR_PINHOLE_RADIUS,
-    ICS_SENSOR_LAMBDA_EXCITATION,
-    ICS_SENSOR_LAMBDA_EMISSION,
-    ICS_SENSOR_PHOTON_COUNT,
-    ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX,
+    ICS_SENSOR_IMAGING_DIRECTION,
     ICS_SENSOR_NUMERICAL_APERTURE,
+    ICS_SENSOR_OBJECTIVE_QUALITY,
+    ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX,
     ICS_SENSOR_LENS_REFRACTIVE_INDEX,
+    ICS_SENSOR_PINHOLE_RADIUS,
+    ICS_SENSOR_ILL_PINHOLE_RADIUS,
     ICS_SENSOR_PINHOLE_SPACING,
+    ICS_SENSOR_EXCITATION_BEAM_FILL,
+    ICS_SENSOR_LAMBDA_EXCITATION,
+    ICS_SENSOR_LAMBDA_EMISSION,    
+    ICS_SENSOR_PHOTON_COUNT,
+    ICS_SENSOR_INTERFACE_PRIMARY,
+    ICS_SENSOR_INTERFACE_SECONDARY,
+    
+    ICS_SENSOR_DETECTOR_MAGN,
+    ICS_SENSOR_DETECTOR_PPU,
+    ICS_SENSOR_DETECTOR_BASELINE,
+    ICS_SENSOR_DETECTOR_LINE_AVG_COUNT,
+
     ICS_SENSOR_STED_DEPLETION_MODE,
     ICS_SENSOR_STED_LAMBDA,
     ICS_SENSOR_STED_SATURATION_FACTOR,
     ICS_SENSOR_STED_IMM_FRACTION,
     ICS_SENSOR_STED_VPPM,
+    
     ICS_SENSOR_SPIM_EXCITATION_TYPE,
     ICS_SENSOR_SPIM_FILL_FACTOR,
     ICS_SENSOR_SPIM_PLANE_NA,
@@ -176,13 +189,11 @@ typedef enum {
     ICS_SENSOR_SPIM_PLANE_PROP_DIR,
     ICS_SENSOR_SPIM_PLANE_CENTER_OFF,
     ICS_SENSOR_SPIM_PLANE_FOCUS_OFF,
+    
     ICS_SENSOR_SCATTER_MODEL,
     ICS_SENSOR_SCATTER_FREE_PATH,
     ICS_SENSOR_SCATTER_REL_CONTRIB,
-    ICS_SENSOR_SCATTER_BLURRING,
-    ICS_SENSOR_DETECTOR_PPU,
-    ICS_SENSOR_DETECTOR_BASELINE,
-    ICS_SENSOR_DETECTOR_LINE_AVG_COUNT,
+    ICS_SENSOR_SCATTER_BLURRING,    
     ICS_SENSOR_LAST
 } Ics_SensorParameter;
 
@@ -242,9 +253,33 @@ typedef struct _ICS {
     char                    model[ICS_STRLEN_OTHER];
         /* Number of channels: */
     int                     sensorChannels;
-        /* Backprojected microns: */
+        /* Imaging direction: */
+    char                    imagingDirection[ICS_MAX_LAMBDA][ICS_STRLEN_TOKEN];
+    Ics_SensorState         imagingDirectionState[ICS_MAX_LAMBDA];
+        /* Numerical Aperture: */
+    double                  numAperture;
+    Ics_SensorState         numApertureState;
+        /* Objective quality: */
+    int                     objectiveQuality[ICS_MAX_LAMBDA];
+    Ics_SensorState         objectiveQualityState[ICS_MAX_LAMBDA];
+        /* Refractive index of embedding medium: */
+    double                  refrInxMedium;
+    Ics_SensorState         refrInxMediumState;
+        /* Refractive index of design medium: */
+    double                  refrInxLensMedium;
+    Ics_SensorState         refrInxLensMediumState;
+        /* Detection pinhole in microns: */
     double                  pinholeRadius[ICS_MAX_LAMBDA];
     Ics_SensorState         pinholeRadiusState[ICS_MAX_LAMBDA];
+        /* Illumination pinhole in microns: */
+    double                  illPinholeRadius[ICS_MAX_LAMBDA];
+    Ics_SensorState         illPinholeRadiusState[ICS_MAX_LAMBDA];
+        /* Nipkow Disk pinhole spacing: */
+    double                  pinholeSpacing;
+    Ics_SensorState         pinholeSpacingState;
+        /* Excitation beam fill factor: */
+    double                  excitationBeamFill[ICS_MAX_LAMBDA];
+    Ics_SensorState         excitationBeamFillState[ICS_MAX_LAMBDA];
         /* Excitation wavelength in nanometers: */
     double                  lambdaEx[ICS_MAX_LAMBDA];
     Ics_SensorState         lambdaExState[ICS_MAX_LAMBDA];
@@ -254,18 +289,24 @@ typedef struct _ICS {
         /* Number of excitation photons: */
     int                     exPhotonCnt[ICS_MAX_LAMBDA];
     Ics_SensorState         exPhotonCntState[ICS_MAX_LAMBDA];
-        /* Refractive index of embedding medium: */
-    double                  refrInxMedium;
-    Ics_SensorState         refrInxMediumState;
-        /* Numerical Aperture: */
-    double                  numAperture;
-    Ics_SensorState         numApertureState;
-        /* Refractive index of design medium: */
-    double                  refrInxLensMedium;
-    Ics_SensorState         refrInxLensMediumState;
-        /* Nipkow Disk pinhole spacing: */
-    double                  pinholeSpacing;
-    Ics_SensorState         pinholeSpacingState;
+        /* Emission wavelength in nm: */
+    double                  interfacePrimary;
+    Ics_SensorState         interfacePrimaryState;
+        /* Emission wavelength in nm: */
+    double                  interfaceSecondary;
+    Ics_SensorState         interfaceSecondaryState;
+        /* Excitation beam fill factor: */
+    double                  detectorMagn[ICS_MAX_LAMBDA];
+    Ics_SensorState         detectorMagnState[ICS_MAX_LAMBDA];
+        /* Detector photons per unit: */
+    double                  detectorPPU[ICS_MAX_LAMBDA];
+    Ics_SensorState         detectorPPUState[ICS_MAX_LAMBDA];
+        /* Detector Baseline: */
+    double                  detectorBaseline[ICS_MAX_LAMBDA];
+    Ics_SensorState         detectorBaselineState[ICS_MAX_LAMBDA];
+        /* Averaging line count */
+    double                  detectorLineAvgCnt[ICS_MAX_LAMBDA];
+    Ics_SensorState         detectorLineAvgCntState[ICS_MAX_LAMBDA];
         /* STED depletion mode: */
     char                    stedDepletionMode[ICS_MAX_LAMBDA][ICS_STRLEN_TOKEN];
     Ics_SensorState         stedDepletionModeState[ICS_MAX_LAMBDA];
@@ -314,20 +355,12 @@ typedef struct _ICS {
         /* Scatter blurring: */
     double                  scatterBlurring[ICS_MAX_LAMBDA];
     Ics_SensorState         scatterBlurringState[ICS_MAX_LAMBDA];
-        /* Detector photons per unit: */
-    double                  detectorPPU[ICS_MAX_LAMBDA];
-    Ics_SensorState         detectorPPUState[ICS_MAX_LAMBDA];
-        /* Detector Baseline: */
-    double                  detectorBaseline[ICS_MAX_LAMBDA];
-    Ics_SensorState         detectorBaselineState[ICS_MAX_LAMBDA];
-        /* Averaging line count */
-    double                  detectorLineAvgCnt[ICS_MAX_LAMBDA];
-    Ics_SensorState         detectorLineAvgCntState[ICS_MAX_LAMBDA];
 
         /* SCIL_Image compatibility parameter: */
     char                    scilType[ICS_STRLEN_TOKEN];
 } ICS;
 
+
 /* The  error codes. */
 typedef enum {
         /* No error. */


=====================================
libics_data.c
=====================================
--- a/libics_data.c
+++ b/libics_data.c
@@ -82,14 +82,24 @@ Ics_Symbol G_SubCatSymbols[] =
 Ics_Symbol G_SubSubCatSymbols[] =
 {
     {"Channels",            ICSTOK_CHANS},
+    {"ImagingDirection",    ICSTOK_IMDIR},
+    {"NumAperture",         ICSTOK_NUMAPER},
+    {"ObjectiveQuality",    ICSTOK_OBJQ},
+    {"RefrInxMedium",       ICSTOK_REFRIME},
+    {"RefrInxLensMedium",   ICSTOK_REFRILM},
     {"PinholeRadius",       ICSTOK_PINHRAD},
+    {"IllPinholeRadius",    ICSTOK_ILLPINHRAD},
+    {"PinholeSpacing",      ICSTOK_PINHSPA},
+    {"ExcitationBeamFill",  ICSTOK_EXBFILL},
     {"LambdaEx",            ICSTOK_LAMBDEX},
     {"LambdaEm",            ICSTOK_LAMBDEM},
     {"ExPhotonCnt",         ICSTOK_PHOTCNT},
-    {"RefrInxMedium",       ICSTOK_REFRIME},
-    {"NumAperture",         ICSTOK_NUMAPER},
-    {"RefrInxLensMedium",   ICSTOK_REFRILM},
-    {"PinholeSpacing",      ICSTOK_PINHSPA},
+    {"InterFacePrimary",    ICSTOK_IFACE1},
+    {"InterFaceSecondary",  ICSTOK_IFACE2},
+    {"DetectorMagnif",      ICSTOK_DETMAG},
+    {"DetectorPPU",         ICSTOK_DETPPU},
+    {"DetectorBaseline",    ICSTOK_DETBASELINE},
+    {"DetectorLineAvgCnt",  ICSTOK_DETLNAVGCNT},
     {"STEDDeplMode",        ICSTOK_STEDDEPLMODE},
     {"STEDLambda",          ICSTOK_STEDLAMBDA},
     {"STEDSatFactor",       ICSTOK_STEDSATFACTOR},
@@ -105,10 +115,7 @@ Ics_Symbol G_SubSubCatSymbols[] =
     {"ScatterModel",        ICSTOK_SCATTERMODEL},
     {"ScatterFreePath",     ICSTOK_SCATTERFREEPATH},
     {"ScatterRelContrib",   ICSTOK_SCATTERRELCONTRIB},
-    {"ScatterBlurring",     ICSTOK_SCATTERBLURRING},
-    {"DetectorPPU",         ICSTOK_DETPPU},
-    {"DetectorBaseline",    ICSTOK_DETBASELINE},
-    {"DetectorLineAvgCnt",  ICSTOK_DETLNAVGCNT}
+    {"ScatterBlurring",     ICSTOK_SCATTERBLURRING}
 };
 
 


=====================================
libics_intern.h
=====================================
--- a/libics_intern.h
+++ b/libics_intern.h
@@ -107,14 +107,24 @@ typedef enum {
         /* SubsubCategory tokens: */
     ICSTOK_FIRSTSUBSUB,
     ICSTOK_CHANS,
+    ICSTOK_IMDIR,
+    ICSTOK_NUMAPER,
+    ICSTOK_OBJQ,
+    ICSTOK_REFRIME,
+    ICSTOK_REFRILM,
     ICSTOK_PINHRAD,
+    ICSTOK_ILLPINHRAD,
+    ICSTOK_PINHSPA,
+    ICSTOK_EXBFILL,
     ICSTOK_LAMBDEX,
     ICSTOK_LAMBDEM,
     ICSTOK_PHOTCNT,
-    ICSTOK_REFRIME,
-    ICSTOK_NUMAPER,
-    ICSTOK_REFRILM,
-    ICSTOK_PINHSPA,
+    ICSTOK_IFACE1,
+    ICSTOK_IFACE2,
+    ICSTOK_DETMAG,
+    ICSTOK_DETPPU,
+    ICSTOK_DETBASELINE,
+    ICSTOK_DETLNAVGCNT,
     ICSTOK_STEDDEPLMODE,
     ICSTOK_STEDLAMBDA,
     ICSTOK_STEDSATFACTOR,
@@ -131,9 +141,6 @@ typedef enum {
     ICSTOK_SCATTERFREEPATH,
     ICSTOK_SCATTERRELCONTRIB,
     ICSTOK_SCATTERBLURRING,
-    ICSTOK_DETPPU,
-    ICSTOK_DETBASELINE,
-    ICSTOK_DETLNAVGCNT,
     ICSTOK_LASTSUBSUB,
 
         /* Value tokens: */


=====================================
libics_read.c
=====================================
--- a/libics_read.c
+++ b/libics_read.c
@@ -296,6 +296,61 @@ static Ics_Error getIcsSensorState(char            *str,
 }
 
 
+#define ICS_SET_SENSOR_STRING(FIELD)            \
+do {                                            \
+    while (ptr != NULL && i < ICS_MAX_LAMBDA) { \
+        IcsStrCpy(icsStruct->FIELD[i++],        \
+                  ptr, ICS_STRLEN_TOKEN);       \
+        ptr = strtok(NULL, seps);               \
+    }                                           \
+} while (0)
+
+
+#define ICS_SET_SENSOR_DOUBLE_ONE(FIELD)        \
+do {                                            \
+    if (ptr != NULL) {                          \
+        icsStruct->FIELD = atof(ptr);           \
+    }                                           \
+} while (0)
+
+
+#define ICS_SET_SENSOR_INT(FIELD)               \
+do {                                            \
+    while (ptr != NULL && i < ICS_MAX_LAMBDA) { \
+        icsStruct->FIELD[i++] = atoi(ptr);      \
+        ptr = strtok(NULL, seps);               \
+    }                                           \
+} while (0)
+
+
+#define ICS_SET_SENSOR_DOUBLE(FIELD)            \
+do {                                            \
+    while (ptr != NULL && i < ICS_MAX_LAMBDA) { \
+        icsStruct->FIELD[i++] = atof(ptr);      \
+        ptr = strtok(NULL, seps);               \
+    }                                           \
+} while (0)
+
+
+#define ICS_SET_SENSOR_STATE(FIELD)             \
+do {                                            \
+    while (ptr != NULL && i < ICS_MAX_LAMBDA) { \
+        error = getIcsSensorState(ptr, &state); \
+        icsStruct->FIELD ## State[i++] = state; \
+        ptr = strtok(NULL, seps);               \
+    }                                           \
+} while(0)
+
+    
+#define ICS_SET_SENSOR_STATE_ONE(FIELD)         \
+do {                                            \
+    if (ptr != NULL) {                          \
+        error = getIcsSensorState(ptr, &state); \
+        icsStruct->FIELD ## State = state;      \
+    }                                           \
+} while(0)
+
+
 Ics_Error IcsReadIcs(Ics_Header *icsStruct,
                      const char *filename,
                      int         forceName,
@@ -559,106 +614,86 @@ Ics_Error IcsReadIcs(Ics_Header *icsStruct,
                                     }
                                 }
                                 break;
+                            case ICSTOK_IMDIR:
+                                ICS_SET_SENSOR_STRING(imagingDirection);
+                                break;
+                            case ICSTOK_NUMAPER:
+                                ICS_SET_SENSOR_DOUBLE_ONE(numAperture);
+                                break;
+                            case ICSTOK_OBJQ:
+                                ICS_SET_SENSOR_INT(objectiveQuality);
+                                break;
+                            case ICSTOK_REFRIME:
+                                ICS_SET_SENSOR_DOUBLE_ONE(refrInxMedium);
+                                break;
+                            case ICSTOK_REFRILM:
+                                ICS_SET_SENSOR_DOUBLE_ONE(refrInxLensMedium);
+                                break;
                             case ICSTOK_PINHRAD:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->pinholeRadius[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(pinholeRadius);
+                                break;
+                            case ICSTOK_ILLPINHRAD:
+                                ICS_SET_SENSOR_DOUBLE(illPinholeRadius);
+                                break;
+                            case ICSTOK_PINHSPA:
+                                ICS_SET_SENSOR_DOUBLE_ONE(pinholeSpacing);
+                                break;
+                            case ICSTOK_EXBFILL:
+                                ICS_SET_SENSOR_DOUBLE(excitationBeamFill);
                                 break;
                             case ICSTOK_LAMBDEX:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->lambdaEx[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(lambdaEx);
                                 break;
                             case ICSTOK_LAMBDEM:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->lambdaEm[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(lambdaEm);
                                 break;
                             case ICSTOK_PHOTCNT:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->exPhotonCnt[i++] = atoi(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_INT(exPhotonCnt);
                                 break;
-                            case ICSTOK_REFRIME:
-                                if (ptr != NULL) {
-                                    icsStruct->refrInxMedium = atof(ptr);
-                                }
+                            case ICSTOK_IFACE1:
+                                ICS_SET_SENSOR_DOUBLE_ONE(interfacePrimary);
                                 break;
-                            case ICSTOK_NUMAPER:
-                                if (ptr != NULL) {
-                                    icsStruct->numAperture = atof(ptr);
-                                }
+                            case ICSTOK_IFACE2:
+                                ICS_SET_SENSOR_DOUBLE_ONE(interfaceSecondary);
                                 break;
-                            case ICSTOK_REFRILM:
-                                if (ptr != NULL) {
-                                    icsStruct->refrInxLensMedium = atof(ptr);
-                                }
+                            case ICSTOK_DETMAG:
+                                ICS_SET_SENSOR_DOUBLE(detectorMagn);
                                 break;
-                            case ICSTOK_PINHSPA:
-                                if (ptr != NULL) {
-                                    icsStruct->pinholeSpacing = atof(ptr);
-                                }
+                            case ICSTOK_DETPPU:
+                                ICS_SET_SENSOR_DOUBLE(detectorPPU);
+                                break;
+                            case ICSTOK_DETBASELINE:
+                                ICS_SET_SENSOR_DOUBLE(detectorBaseline);
+                                break;
+                            case ICSTOK_DETLNAVGCNT:
+                                ICS_SET_SENSOR_DOUBLE(detectorLineAvgCnt);
                                 break;
                             case ICSTOK_STEDDEPLMODE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    IcsStrCpy(icsStruct->stedDepletionMode[i++],
-                                              ptr, ICS_STRLEN_TOKEN);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STRING(stedDepletionMode);
                                 break;
                             case ICSTOK_STEDLAMBDA:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->stedLambda[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(stedLambda);
                                 break;
                             case ICSTOK_STEDSATFACTOR:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->stedSatFactor[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(stedSatFactor);
                                 break;
                             case ICSTOK_STEDIMMFRACTION:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->stedImmFraction[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(stedImmFraction);
                                 break;
                             case ICSTOK_STEDVPPM:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->stedVPPM[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(stedVPPM);
                                 break;
                             case ICSTOK_SPIMEXCTYPE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    IcsStrCpy(icsStruct->spimExcType[i++],
-                                              ptr, ICS_STRLEN_TOKEN);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STRING(spimExcType);
                                 break;
                             case ICSTOK_SPIMFILLFACTOR:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->spimFillFactor[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(spimFillFactor);
                                 break;
                             case ICSTOK_SPIMPLANENA:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->spimPlaneNA[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(spimPlaneNA);
                                 break;
                             case ICSTOK_SPIMPLANEGAUSSWIDTH:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->spimPlaneGaussWidth[i++] =
-                                        atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(spimPlaneGaussWidth);
                                 break;
                             case ICSTOK_SPIMPLANEPROPDIR:
                                 while (ptr != NULL && i < ICS_MAX_LAMBDA) {
@@ -682,65 +717,22 @@ Ics_Error IcsReadIcs(Ics_Header *icsStruct,
                                 }
                                 break;
                             case ICSTOK_SPIMPLANECENTEROFF:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->spimPlaneCenterOff[i++] =
-                                        atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(spimPlaneCenterOff);
                                 break;
                             case ICSTOK_SPIMPLANEFOCUSOF:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->spimPlaneFocusOff[i++] =
-                                        atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(spimPlaneFocusOff);
                                 break;
                             case ICSTOK_SCATTERMODEL:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    IcsStrCpy(icsStruct->scatterModel[i++],
-                                              ptr, ICS_STRLEN_TOKEN);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STRING(scatterModel);
                                 break;
                             case ICSTOK_SCATTERFREEPATH:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->scatterFreePath[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(scatterFreePath);
                                 break;
                             case ICSTOK_SCATTERRELCONTRIB:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->scatterRelContrib[i++]
-                                        = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(scatterRelContrib);
                                 break;
                             case ICSTOK_SCATTERBLURRING:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->scatterBlurring[i++] =
-                                        atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETPPU:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    icsStruct->detectorPPU[i++] = atof(ptr);
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETBASELINE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    double v = atof(ptr);
-                                    icsStruct->detectorBaseline[i++] = v;
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETLNAVGCNT:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    double v = atof(ptr);
-                                    icsStruct->detectorLineAvgCnt[i++] = v;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_DOUBLE(scatterBlurring);
                                 break;
                             default:
                                 error = IcsErr_MissSensorSubSubCat;
@@ -748,199 +740,107 @@ Ics_Error IcsReadIcs(Ics_Header *icsStruct,
                         break;
                     case ICSTOK_SSTATES:
                         switch (subSubCat) {
+                            case ICSTOK_IMDIR:
+                                ICS_SET_SENSOR_STATE(imagingDirection);
+                                break;
+                            case ICSTOK_NUMAPER:
+                                ICS_SET_SENSOR_STATE_ONE(numAperture);
+                                break;
+                            case ICSTOK_OBJQ:
+                                ICS_SET_SENSOR_STATE(objectiveQuality);
+                                break;
+                            case ICSTOK_REFRIME:
+                                ICS_SET_SENSOR_STATE_ONE(refrInxMedium);
+                                break;
+                            case ICSTOK_REFRILM:
+                                ICS_SET_SENSOR_STATE_ONE(refrInxLensMedium);
+                                break;
                             case ICSTOK_PINHRAD:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->pinholeRadiusState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(pinholeRadius);
+                                break;
+                            case ICSTOK_ILLPINHRAD:
+                                ICS_SET_SENSOR_STATE(illPinholeRadius);
+                                break;
+                            case ICSTOK_PINHSPA:
+                                ICS_SET_SENSOR_STATE_ONE(pinholeSpacing);
+                                break;
+                            case ICSTOK_EXBFILL:
+                                ICS_SET_SENSOR_STATE(excitationBeamFill);
                                 break;
                             case ICSTOK_LAMBDEX:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->lambdaExState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(lambdaEx);
                                 break;
                             case ICSTOK_LAMBDEM:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->lambdaEmState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(lambdaEm);
                                 break;
                             case ICSTOK_PHOTCNT:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->exPhotonCntState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(exPhotonCnt);
                                 break;
-                            case ICSTOK_REFRIME:
-                                if (ptr != NULL) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->refrInxMediumState = state;
-                                }
+                            case ICSTOK_IFACE1:
+                                ICS_SET_SENSOR_STATE_ONE(interfacePrimary);
                                 break;
-                            case ICSTOK_NUMAPER:
-                                if (ptr != NULL) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->numApertureState = state;
-                                }
+                            case ICSTOK_IFACE2:
+                                ICS_SET_SENSOR_STATE_ONE(interfaceSecondary);
                                 break;
-                            case ICSTOK_REFRILM:
-                                if (ptr != NULL) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->refrInxLensMediumState = state;
-                                }
+                            case ICSTOK_DETMAG:
+                                ICS_SET_SENSOR_STATE(detectorMagn);
                                 break;
-                            case ICSTOK_PINHSPA:
-                                if (ptr != NULL) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->pinholeSpacingState = state;
-                                }
+                            case ICSTOK_DETPPU:
+                                ICS_SET_SENSOR_STATE(detectorPPU);
+                                break;
+                            case ICSTOK_DETBASELINE:
+                                ICS_SET_SENSOR_STATE(detectorBaseline);
+                                break;
+                            case ICSTOK_DETLNAVGCNT:
+                                ICS_SET_SENSOR_STATE(detectorLineAvgCnt);
                                 break;
                             case ICSTOK_STEDDEPLMODE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->stedDepletionModeState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(stedDepletionMode);
                                 break;
                             case ICSTOK_STEDLAMBDA:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->stedLambdaState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(stedLambda);
                                 break;
                             case ICSTOK_STEDSATFACTOR:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->stedSatFactorState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(stedSatFactor);
                                 break;
                             case ICSTOK_STEDIMMFRACTION:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->stedImmFraction[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(stedImmFraction);
                                 break;
                             case ICSTOK_STEDVPPM:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->stedVPPMState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(stedVPPM);
                                 break;
                             case ICSTOK_SPIMEXCTYPE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimExcTypeState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimExcType);
                                 break;
                             case ICSTOK_SPIMFILLFACTOR:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimFillFactorState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimFillFactor);
                                 break;
                             case ICSTOK_SPIMPLANENA:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimPlaneNAState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimPlaneNA);
                                 break;
                             case ICSTOK_SPIMPLANEGAUSSWIDTH:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimPlaneGaussWidthState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimPlaneGaussWidth);
                                 break;
                             case ICSTOK_SPIMPLANEPROPDIR:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimPlanePropDirState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimPlanePropDir);
                                 break;
                             case ICSTOK_SPIMPLANECENTEROFF:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimPlaneCenterOffState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimPlaneCenterOff);
                                 break;
                             case ICSTOK_SPIMPLANEFOCUSOF:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->spimPlaneFocusOffState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(spimPlaneFocusOff);
                                 break;
                             case ICSTOK_SCATTERMODEL:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->scatterModelState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(scatterModel);
                                 break;
                             case ICSTOK_SCATTERFREEPATH:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->scatterFreePathState[i++]
-                                        = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(scatterFreePath);
                                 break;
                             case ICSTOK_SCATTERRELCONTRIB:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->scatterRelContribState[i++]
-                                        = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(scatterRelContrib);
                                 break;
                             case ICSTOK_SCATTERBLURRING:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->scatterBlurringState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETPPU:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->detectorPPUState[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETBASELINE:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->detectorBaselineState[i++] =
-                                        state;
-                                    ptr = strtok(NULL, seps);
-                                }
-                                break;
-                            case ICSTOK_DETLNAVGCNT:
-                                while (ptr != NULL && i < ICS_MAX_LAMBDA) {
-                                    error = getIcsSensorState(ptr, &state);
-                                    icsStruct->detectorLineAvgCnt[i++] = state;
-                                    ptr = strtok(NULL, seps);
-                                }
+                                ICS_SET_SENSOR_STATE(scatterBlurring);
                                 break;
                             default:
                                 error = IcsErr_MissSensorSubSubCat;


=====================================
libics_sensor.c
=====================================
--- a/libics_sensor.c
+++ b/libics_sensor.c
@@ -550,10 +550,34 @@ Ics_Error IcsGetSensorParameter(const ICS           *ics,
         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];
@@ -566,21 +590,29 @@ Ics_Error IcsGetSensorParameter(const ICS           *ics,
             *value = ics->exPhotonCnt[channel];
             *state = ics->exPhotonCntState[channel];
             break;
-        case ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX:
-            *value = ics->refrInxMedium;
-            *state = ics->refrInxMediumState;
+        case ICS_SENSOR_INTERFACE_PRIMARY:
+            *value = ics->interfacePrimary;
+            *state = ics->interfacePrimaryState;
             break;
-        case ICS_SENSOR_NUMERICAL_APERTURE:
-            *value = ics->numAperture;
-            *state = ics->numApertureState;
+        case ICS_SENSOR_INTERFACE_SECONDARY:
+            *value = ics->interfaceSecondary;
+            *state = ics->interfaceSecondaryState;
             break;
-        case ICS_SENSOR_LENS_REFRACTIVE_INDEX:
-            *value = ics->refrInxLensMedium;
-            *state = ics->refrInxLensMediumState;
+         case ICS_SENSOR_DETECTOR_MAGN:
+            *value = ics->detectorMagn[channel];
+            *state = ics->detectorMagnState[channel];
             break;
-        case ICS_SENSOR_PINHOLE_SPACING:
-            *value = ics->pinholeSpacing;
-            *state = ics->pinholeSpacingState;
+         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_STED_LAMBDA:
             *value = ics->stedLambda[channel];
@@ -630,18 +662,6 @@ Ics_Error IcsGetSensorParameter(const ICS           *ics,
             *value = ics->scatterBlurring[channel];
             *state = ics->scatterBlurringState[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;
         default:
             *value = 0;
             *state = IcsSensorState_default;
@@ -692,6 +712,10 @@ Ics_Error IcsGetSensorParameterInt(const ICS           *ics,
 
 
     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];
@@ -718,6 +742,10 @@ Ics_Error IcsGetSensorParameterString(const ICS            *ics,
 
 
     switch (parameter) {
+        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];
@@ -754,10 +782,34 @@ Ics_Error IcsSetSensorParameter(ICS                 *ics,
         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;
@@ -770,21 +822,29 @@ Ics_Error IcsSetSensorParameter(ICS                 *ics,
             ics->exPhotonCnt[channel] = value;
             ics->exPhotonCntState[channel] = state;
             break;
-        case ICS_SENSOR_MEDIUM_REFRACTIVE_INDEX:
-            ics->refrInxMedium = value;
-            ics->refrInxMediumState = state;
+        case ICS_SENSOR_INTERFACE_PRIMARY:
+            ics->interfacePrimary = value;
+            ics->interfacePrimaryState = state;
             break;
-        case ICS_SENSOR_NUMERICAL_APERTURE:
-            ics->numAperture = value;
-            ics->numApertureState = state;
+        case ICS_SENSOR_INTERFACE_SECONDARY:
+            ics->interfaceSecondary = value;
+            ics->interfaceSecondaryState = state;
             break;
-        case ICS_SENSOR_LENS_REFRACTIVE_INDEX:
-            ics->refrInxLensMedium = value;
-            ics->refrInxLensMediumState = state;
+        case ICS_SENSOR_DETECTOR_MAGN:
+            ics->detectorMagn[channel] = value;
+            ics->detectorMagnState[channel] = state;
             break;
-        case ICS_SENSOR_PINHOLE_SPACING:
-            ics->pinholeSpacing = value;
-            ics->pinholeSpacingState = state;
+        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_STED_LAMBDA:
             ics->stedLambda[channel] = value;
@@ -834,18 +894,6 @@ Ics_Error IcsSetSensorParameter(ICS                 *ics,
             ics->scatterBlurring[channel] = value;
             ics->scatterBlurringState[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;
         default:
             return IcsErr_NotValidAction;
     }
@@ -900,6 +948,10 @@ Ics_Error IcsSetSensorParameterInt(ICS                 *ics,
         return IcsErr_NotValidAction;
 
     switch (parameter) {
+        case ICS_SENSOR_OBJECTIVE_QUALITY:
+            ics->objectiveQuality[channel] = value;
+            ics->objectiveQualityState[channel] = state;
+            break;
         case ICS_SENSOR_PHOTON_COUNT:
             ics->exPhotonCnt[channel] = value;
             ics->exPhotonCntState[channel] = state;
@@ -926,6 +978,10 @@ Ics_Error IcsSetSensorParameterString(ICS                 *ics,
         return IcsErr_NotValidAction;
 
     switch (parameter) {
+        case ICS_SENSOR_IMAGING_DIRECTION:
+            IcsStrCpy(ics->imagingDirection[channel], value, ICS_STRLEN_TOKEN);
+            ics->imagingDirectionState[channel] = state;
+            break;
         case ICS_SENSOR_STED_DEPLETION_MODE:
             IcsStrCpy(ics->stedDepletionMode[channel], value, ICS_STRLEN_TOKEN);
             ics->stedDepletionModeState[channel] = state;


=====================================
libics_util.c
=====================================
--- a/libics_util.c
+++ b/libics_util.c
@@ -356,25 +356,45 @@ void IcsInit(Ics_Header *icsStruct)
     icsStruct->writeSensor = 0;
     icsStruct->writeSensorStates = 0;
     icsStruct->model[0]= '\0';
-    icsStruct->refrInxMedium = 0.0;
-    icsStruct->refrInxMediumState = IcsSensorState_default;
     icsStruct->numAperture = 0.0;
     icsStruct->numApertureState = IcsSensorState_default;
+    icsStruct->refrInxMedium = 0.0;
+    icsStruct->refrInxMediumState = IcsSensorState_default;
     icsStruct->refrInxLensMedium = 0.0;
     icsStruct->refrInxLensMediumState = IcsSensorState_default;
     icsStruct->pinholeSpacing = 0.0;
     icsStruct->pinholeSpacingState = IcsSensorState_default;
+    icsStruct->interfacePrimary = 0.0;
+    icsStruct->interfacePrimaryState = IcsSensorState_default;
+    icsStruct->interfaceSecondary = 0.0;
+    icsStruct->interfaceSecondaryState = IcsSensorState_default;
     icsStruct->sensorChannels = 0;
     for (i = 0; i < ICS_MAX_LAMBDA; i++) {
         icsStruct->type[i][0] = '\0';
+        icsStruct->imagingDirection[i][0] = '\0';
+        icsStruct->imagingDirectionState[i] = IcsSensorState_default;
+        icsStruct->objectiveQuality[i] = 0;
+        icsStruct->objectiveQualityState[i] = IcsSensorState_default;
         icsStruct->pinholeRadius[i] = 0.0;
         icsStruct->pinholeRadiusState[i] = IcsSensorState_default;
+        icsStruct->illPinholeRadius[i] = 0.0;
+        icsStruct->illPinholeRadiusState[i] = IcsSensorState_default;
+        icsStruct->excitationBeamFill[i] = 0.0;
+        icsStruct->excitationBeamFillState[i] = IcsSensorState_default;
         icsStruct->lambdaEx[i] = 0.0;
         icsStruct->lambdaExState[i] = IcsSensorState_default;
         icsStruct->lambdaEm[i] = 0.0;
         icsStruct->lambdaEmState[i] = IcsSensorState_default;
         icsStruct->exPhotonCnt[i] = 1;
         icsStruct->exPhotonCntState[i] = IcsSensorState_default;
+        icsStruct->detectorMagn[i] = 1.0;
+        icsStruct->detectorMagnState[i] = IcsSensorState_default;
+        icsStruct->detectorPPU[i] = 1.0;
+        icsStruct->detectorPPUState[i] = IcsSensorState_default;
+        icsStruct->detectorBaseline[i] = 0.0;
+        icsStruct->detectorBaselineState[i] = IcsSensorState_default;
+        icsStruct->detectorLineAvgCnt[i] = 1.0;
+        icsStruct->detectorLineAvgCntState[i] = IcsSensorState_default;
         icsStruct->stedDepletionMode[i][0] = '\0';
         icsStruct->stedDepletionModeState[i] = IcsSensorState_default;
         icsStruct->stedLambda[i] = 0.0;
@@ -409,12 +429,6 @@ void IcsInit(Ics_Header *icsStruct)
         icsStruct->scatterRelContribState[i] = IcsSensorState_default;
         icsStruct->scatterBlurring[i] = 0.0;
         icsStruct->scatterBlurringState[i] = IcsSensorState_default;
-        icsStruct->detectorPPU[i] = 1.0;
-        icsStruct->detectorPPUState[i] = IcsSensorState_default;
-        icsStruct->detectorBaseline[i] = 0.0;
-        icsStruct->detectorBaselineState[i] = IcsSensorState_default;
-        icsStruct->detectorLineAvgCnt[i] = 1.0;
-        icsStruct->detectorLineAvgCntState[i] = IcsSensorState_default;
     }
     icsStruct->scilType[0] = '\0';
 }


=====================================
libics_write.c
=====================================
--- a/libics_write.c
+++ b/libics_write.c
@@ -635,6 +635,83 @@ static Ics_Error writeIcsParam(Ics_Header *icsStruct,
 }
 
 
+#define ICS_ADD_SENSOR_DOUBLE(TOKEN, FIELD)                         \
+do {                                                                \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);                   \
+    problem |= icsAddToken(line, ICSTOK_SPARAMS);                   \
+    problem |= icsAddToken(line, TOKEN);                            \
+    for (i = 0; i < chans - 1; i++) {                               \
+        problem |= icsAddDouble(line, icsStruct->FIELD[i]);         \
+    }                                                               \
+    problem |= icsAddLastDouble(line, icsStruct->FIELD[chans - 1]); \
+    if (!problem) {                                                 \
+        error = icsAddLine(line, fp);                               \
+        if (error) return error;                                    \
+    }                                                               \
+} while (0)
+
+
+#define ICS_ADD_SENSOR_DOUBLE_ONE(TOKEN, FIELD)             \
+do {                                                        \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);           \
+    problem |= icsAddToken(line, ICSTOK_SPARAMS);           \
+    problem |= icsAddToken(line, TOKEN);                    \
+    problem |= icsAddLastDouble(line, icsStruct->FIELD);    \
+    if (!problem) {                                         \
+        error = icsAddLine(line, fp);                       \
+        if (error) return error;                            \
+    }                                                       \
+} while (0)
+
+
+#define ICS_ADD_SENSOR_DOUBLE_INDEX(TOKEN, FIELD, TAG, IDX)             \
+do {                                                                    \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);                       \
+    problem |= icsAddToken(line, ICSTOK_SPARAMS);                       \
+    problem |= icsAddTokenWithIndex(line, TOKEN, TAG);                  \
+    for (i = 0; i < chans - 1; i++) {                                   \
+        problem |= icsAddDouble(line, icsStruct->FIELD[i][IDX]);        \
+    }                                                                   \
+    problem |= icsAddLastDouble(line, icsStruct->FIELD[chans - 1][IDX]); \
+    if (!problem) {                                                     \
+        error = icsAddLine(line, fp);                                   \
+        if (error) return error;                                        \
+    }                                                                   \
+} while (0)
+
+
+#define ICS_ADD_SENSOR_INT(TOKEN, FIELD)                            \
+do {                                                                \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);                   \
+    problem |= icsAddToken(line, ICSTOK_SPARAMS);                   \
+    problem |= icsAddToken(line, TOKEN);                            \
+    for (i = 0; i < chans - 1; i++) {                               \
+        problem |= icsAddInt(line, icsStruct->FIELD[i]);            \
+    }                                                               \
+    problem |= icsAddLastInt(line, icsStruct->FIELD[chans - 1]);    \
+    if (!problem) {                                                 \
+        error = icsAddLine(line, fp);                               \
+        if (error) return error;                                    \
+    }                                                               \
+} while (0)
+
+
+#define ICS_ADD_SENSOR_STRING(TOKEN, FIELD)                 \
+do {                                                        \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);           \
+    problem |= icsAddToken(line, ICSTOK_SPARAMS);           \
+    problem |= icsAddToken(line, TOKEN);                    \
+    for (i = 0; i < chans - 1; i++) {                       \
+        problem |= icsAddText(line, icsStruct->FIELD[i]);   \
+    }                                                       \
+    problem |= icsAddLastText(line, icsStruct->FIELD[i]);   \
+    if (!problem) {                                         \
+        error = icsAddLine(line, fp);                       \
+        if (error) return error;                            \
+    }                                                       \
+} while (0)
+
+
 static Ics_Error writeIcsSensorData(Ics_Header *icsStruct,
                                     FILE       *fp)
 {
@@ -676,365 +753,86 @@ static Ics_Error writeIcsSensorData(Ics_Header *icsStruct,
             if (error) return error;
         }
 
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_PINHRAD);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->pinholeRadius[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->pinholeRadius[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_LAMBDEX);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->lambdaEx[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->lambdaEx[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_LAMBDEM);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->lambdaEm[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->lambdaEm[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_PHOTCNT);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddInt(line, icsStruct->exPhotonCnt[i]);
-        }
-        problem |= icsAddLastInt(line, icsStruct->exPhotonCnt[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_REFRIME);
-        problem |= icsAddLastDouble(line, icsStruct->refrInxMedium);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_NUMAPER);
-        problem |= icsAddLastDouble(line, icsStruct->numAperture);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_REFRILM);
-        problem |= icsAddLastDouble(line, icsStruct->refrInxLensMedium);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_PINHSPA);
-        problem |= icsAddLastDouble(line, icsStruct->pinholeSpacing);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add STED parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_STEDDEPLMODE);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddText(line, icsStruct->stedDepletionMode[i]);
-        }
-        problem |= icsAddLastText(line, icsStruct->stedDepletionMode[i]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_STEDLAMBDA);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->stedLambda[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->stedLambda[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_STEDSATFACTOR);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->stedSatFactor[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->stedSatFactor[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_STEDIMMFRACTION);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->stedImmFraction[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->stedImmFraction[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_STEDVPPM);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->stedVPPM[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->stedVPPM[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add  SPIM parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMEXCTYPE);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddText(line, icsStruct->spimExcType[i]);
-        }
-        problem |= icsAddLastText(line, icsStruct->spimExcType[i]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANENA);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlaneNA[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->spimPlaneNA[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMFILLFACTOR);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimFillFactor[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->spimFillFactor[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANEGAUSSWIDTH);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlaneGaussWidth[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlaneGaussWidth[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddTokenWithIndex(line, ICSTOK_SPIMPLANEPROPDIR, "X");
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlanePropDir[i][0]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlanePropDir[chans - 1][0]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddTokenWithIndex(line, ICSTOK_SPIMPLANEPROPDIR, "Y");
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlanePropDir[i][1]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlanePropDir[chans - 1][1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddTokenWithIndex(line, ICSTOK_SPIMPLANEPROPDIR, "Z");
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlanePropDir[i][2]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlanePropDir[chans - 1][2]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANECENTEROFF);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlaneCenterOff[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlaneCenterOff[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANEFOCUSOF);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->spimPlaneFocusOff[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->spimPlaneFocusOff[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add  Scatter parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SCATTERMODEL);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddText(line, icsStruct->scatterModel[i]);
-        }
-        problem |= icsAddLastText(line, icsStruct->scatterModel[i]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SCATTERFREEPATH);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->scatterFreePath[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->scatterFreePath[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SCATTERRELCONTRIB);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->scatterRelContrib[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->scatterRelContrib[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_SCATTERBLURRING);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->scatterBlurring[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->scatterBlurring[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add detector parameters. */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_DETPPU);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->detectorPPU[i]);
-        }
-        problem |= icsAddLastDouble(line, icsStruct->detectorPPU[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_DETBASELINE);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->detectorBaseline[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->detectorBaseline[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SPARAMS);
-        problem |= icsAddToken(line, ICSTOK_DETLNAVGCNT);
-        for (i = 0; i < chans - 1; i++) {
-            problem |= icsAddDouble(line, icsStruct->detectorLineAvgCnt[i]);
-        }
-        problem |= icsAddLastDouble(line,
-                                    icsStruct->detectorLineAvgCnt[chans - 1]);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-
+        ICS_ADD_SENSOR_STRING(ICSTOK_IMDIR, imagingDirection);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_NUMAPER, numAperture);
+        ICS_ADD_SENSOR_INT(ICSTOK_OBJQ, objectiveQuality);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_REFRIME, refrInxMedium);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_REFRILM, refrInxLensMedium);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_PINHRAD, pinholeRadius);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_ILLPINHRAD, illPinholeRadius);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_PINHSPA, pinholeSpacing);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_EXBFILL, excitationBeamFill);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_LAMBDEX, lambdaEx);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_LAMBDEM, lambdaEm);
+        ICS_ADD_SENSOR_INT(ICSTOK_PHOTCNT, exPhotonCnt);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_IFACE1, interfacePrimary);
+        ICS_ADD_SENSOR_DOUBLE_ONE(ICSTOK_IFACE2, interfaceSecondary);
+        
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_DETMAG, detectorMagn);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_DETPPU, detectorPPU);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_DETBASELINE, detectorBaseline);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_DETLNAVGCNT, detectorLineAvgCnt);
+
+        ICS_ADD_SENSOR_STRING(ICSTOK_STEDDEPLMODE, stedDepletionMode);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_STEDLAMBDA, stedLambda);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_STEDSATFACTOR, stedSatFactor);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_STEDIMMFRACTION, stedImmFraction);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_STEDVPPM, stedVPPM);
+        
+        ICS_ADD_SENSOR_STRING(ICSTOK_SPIMEXCTYPE, spimExcType);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SPIMPLANENA, spimPlaneNA);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SPIMFILLFACTOR, spimFillFactor);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SPIMPLANEGAUSSWIDTH, spimPlaneGaussWidth);
+        ICS_ADD_SENSOR_DOUBLE_INDEX(ICSTOK_SPIMPLANEPROPDIR, spimPlanePropDir,
+                                    "X", 0);
+        ICS_ADD_SENSOR_DOUBLE_INDEX(ICSTOK_SPIMPLANEPROPDIR, spimPlanePropDir,
+                                    "Y", 1);
+        ICS_ADD_SENSOR_DOUBLE_INDEX(ICSTOK_SPIMPLANEPROPDIR, spimPlanePropDir,
+                                    "Z", 2);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SPIMPLANECENTEROFF, spimPlaneCenterOff);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SPIMPLANEFOCUSOF, spimPlaneFocusOff);
+
+        ICS_ADD_SENSOR_STRING(ICSTOK_SCATTERMODEL, scatterModel);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SCATTERFREEPATH, scatterFreePath);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SCATTERRELCONTRIB, scatterRelContrib);
+        ICS_ADD_SENSOR_DOUBLE(ICSTOK_SCATTERBLURRING, scatterBlurring);
     }
 
     return error;
 }
 
 
+#define ICS_ADD_SENSOR_STATE(TOKEN, FIELD)          \
+do {                                                \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);   \
+    problem |= icsAddToken(line, ICSTOK_SSTATES);   \
+    problem |= icsAddToken(line, TOKEN);            \
+    for (i = 0; i < chans - 1; i++) {               \
+        state = icsStruct->FIELD ## State[i];       \
+        problem |= icsAddSensorState(line, state);  \
+    }                                               \
+    state = icsStruct->FIELD ## State[chans - 1];   \
+    problem |= icsAddLastSensorState(line, state);  \
+    if (!problem) {                                 \
+        error = icsAddLine(line, fp);               \
+        if (error) return error;                    \
+    }                                               \
+} while (0)
+
+
+#define ICS_ADD_SENSOR_STATE_ONE(TOKEN, FIELD)                          \
+do {                                                                    \
+    problem = icsFirstToken(line, ICSTOK_SENSOR);                       \
+    problem |= icsAddToken(line, ICSTOK_SSTATES);                       \
+    problem |= icsAddToken(line, TOKEN);                                \
+    problem |= icsAddLastSensorState(line, icsStruct->FIELD ## State);  \
+    if (!problem) {                                                     \
+        error = icsAddLine(line, fp);                                   \
+        if (error) return error;                                        \
+    }                                                                   \
+} while (0)
+
+
 static Ics_Error writeIcsSensorStates(Ics_Header *icsStruct,
                                       FILE       *fp)
 {
@@ -1048,354 +846,44 @@ static Ics_Error writeIcsSensorStates(Ics_Header *icsStruct,
         chans = icsStruct->sensorChannels;
         if (chans > ICS_MAX_LAMBDA) return IcsErr_TooManyChans;
 
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_PINHRAD);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->pinholeRadiusState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->pinholeRadiusState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_LAMBDEX);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->lambdaExState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->lambdaExState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_LAMBDEM);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->lambdaEmState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->lambdaEmState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_PHOTCNT);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->exPhotonCntState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->exPhotonCntState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_REFRIME);
-        problem |= icsAddLastSensorState(line, icsStruct->refrInxMediumState);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_NUMAPER);
-        problem |= icsAddLastSensorState(line, icsStruct->numApertureState);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_REFRILM);
-        problem |= icsAddLastSensorState(line,
-                                         icsStruct->refrInxLensMediumState);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_PINHSPA);
-        problem |= icsAddLastSensorState(line, icsStruct->pinholeSpacingState);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add STED parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_STEDDEPLMODE);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->stedDepletionModeState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->stedDepletionModeState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_STEDLAMBDA);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->stedLambdaState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->stedLambdaState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_STEDSATFACTOR);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->stedSatFactorState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->stedSatFactorState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_STEDIMMFRACTION);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->stedImmFractionState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->stedImmFractionState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_STEDVPPM);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->stedVPPMState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->stedVPPMState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add SPIM parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMEXCTYPE);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimExcTypeState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimExcTypeState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANENA);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimPlaneNAState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimPlaneNAState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMFILLFACTOR);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimFillFactorState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimFillFactorState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANEGAUSSWIDTH);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimPlaneGaussWidthState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimPlaneGaussWidthState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANEPROPDIR);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimPlanePropDirState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimPlanePropDirState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANECENTEROFF);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimPlaneCenterOffState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimPlaneCenterOffState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SPIMPLANEFOCUSOF);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->spimPlaneFocusOffState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->spimPlaneFocusOffState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add Scatter parameters */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SCATTERMODEL);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->scatterModelState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->scatterModelState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SCATTERRELCONTRIB);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->scatterRelContribState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->scatterRelContribState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_SCATTERBLURRING);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->scatterBlurring[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->scatterBlurring[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-            /* Add detector parameters. */
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_DETPPU);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->detectorPPUState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->detectorPPUState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_DETBASELINE);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->detectorBaselineState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->detectorBaselineState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
-
-        problem = icsFirstToken(line, ICSTOK_SENSOR);
-        problem |= icsAddToken(line, ICSTOK_SSTATES);
-        problem |= icsAddToken(line, ICSTOK_DETLNAVGCNT);
-        for (i = 0; i < chans - 1; i++) {
-            state = icsStruct->detectorLineAvgCntState[i];
-            problem |= icsAddSensorState(line, state);
-        }
-        state = icsStruct->detectorLineAvgCntState[chans - 1];
-        problem |= icsAddLastSensorState(line, state);
-        if (!problem) {
-            error = icsAddLine(line, fp);
-            if (error) return error;
-        }
+        ICS_ADD_SENSOR_STATE(ICSTOK_IMDIR, imagingDirection);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_NUMAPER, numAperture);
+        ICS_ADD_SENSOR_STATE(ICSTOK_OBJQ, objectiveQuality);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_REFRIME, refrInxMedium);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_REFRILM, refrInxLensMedium);
+        ICS_ADD_SENSOR_STATE(ICSTOK_PINHRAD, pinholeRadius);
+        ICS_ADD_SENSOR_STATE(ICSTOK_ILLPINHRAD, illPinholeRadius);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_PINHSPA, pinholeSpacing);
+        ICS_ADD_SENSOR_STATE(ICSTOK_EXBFILL, excitationBeamFill);
+        ICS_ADD_SENSOR_STATE(ICSTOK_LAMBDEX, lambdaEx);
+        ICS_ADD_SENSOR_STATE(ICSTOK_LAMBDEM, lambdaEm);
+        ICS_ADD_SENSOR_STATE(ICSTOK_PHOTCNT, exPhotonCnt);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_IFACE1, interfacePrimary);
+        ICS_ADD_SENSOR_STATE_ONE(ICSTOK_IFACE2, interfaceSecondary);
+        
+        ICS_ADD_SENSOR_STATE(ICSTOK_DETMAG, detectorMagn);
+        ICS_ADD_SENSOR_STATE(ICSTOK_DETPPU, detectorPPU);
+        ICS_ADD_SENSOR_STATE(ICSTOK_DETBASELINE, detectorBaseline);
+        ICS_ADD_SENSOR_STATE(ICSTOK_DETLNAVGCNT, detectorLineAvgCnt);
+
+        ICS_ADD_SENSOR_STATE(ICSTOK_STEDDEPLMODE, stedDepletionMode);
+        ICS_ADD_SENSOR_STATE(ICSTOK_STEDLAMBDA, stedLambda);
+        ICS_ADD_SENSOR_STATE(ICSTOK_STEDSATFACTOR, stedSatFactor);
+        ICS_ADD_SENSOR_STATE(ICSTOK_STEDIMMFRACTION, stedImmFraction);
+        ICS_ADD_SENSOR_STATE(ICSTOK_STEDVPPM, stedVPPM);
+        
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMEXCTYPE, spimExcType);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMPLANENA, spimPlaneNA);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMFILLFACTOR, spimFillFactor);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMPLANEGAUSSWIDTH, spimPlaneGaussWidth);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMPLANEPROPDIR, spimPlanePropDir);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMPLANECENTEROFF, spimPlaneCenterOff);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SPIMPLANEFOCUSOF, spimPlaneFocusOff);
+
+        ICS_ADD_SENSOR_STATE(ICSTOK_SCATTERMODEL, scatterModel);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SCATTERFREEPATH, scatterFreePath);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SCATTERRELCONTRIB, scatterRelContrib);
+        ICS_ADD_SENSOR_STATE(ICSTOK_SCATTERBLURRING, scatterBlurring);
 
     }
 


=====================================
test_strides3.c
=====================================
--- a/test_strides3.c
+++ b/test_strides3.c
@@ -8,6 +8,7 @@ int main(int argc, const char* argv[]) {
    Ics_DataType dt;
    int          ndims;
    size_t       dims[ICS_MAXDIM];
+   size_t       imelsize;
    size_t       bufsize;
    ptrdiff_t    strides[3];
    void*        buf1;
@@ -30,8 +31,9 @@ int main(int argc, const char* argv[]) {
    }
    IcsGetLayout(ip, &dt, &ndims, dims);
    strides[0] = -1;
-   strides[1] = -(ptrdiff_t)(dims[0]*dims[2]);
-   strides[2] = -(ptrdiff_t)dims[0];
+   strides[1] = -(ptrdiff_t)dims[0];
+strides[2] = -(ptrdiff_t)(dims[0]*dims[1]);
+   imelsize = IcsGetImelSize(ip);
    bufsize = IcsGetDataSize(ip);
    buf1 = malloc(bufsize);
    if (buf1 == NULL) {
@@ -49,7 +51,7 @@ int main(int argc, const char* argv[]) {
       fprintf(stderr, "Could not allocate memory.\n");
       exit(-1);
    }
-   retval = IcsGetDataWithStrides(ip, buf3 + bufsize - 1, 0, strides, 3);
+   retval = IcsGetDataWithStrides(ip, buf3 + bufsize - imelsize, 0, strides, 3);
    if (retval != IcsErr_Ok) {
       fprintf(stderr, "Could not read input image data using strides: %s\n",
               IcsGetErrorText(retval));
@@ -70,7 +72,7 @@ int main(int argc, const char* argv[]) {
       exit(-1);
    }
    IcsSetLayout(ip, dt, ndims, dims);
-   IcsSetDataWithStrides(ip, buf3 + bufsize - 1, bufsize, strides, 3);
+   IcsSetDataWithStrides(ip, buf3 + bufsize - imelsize, bufsize, strides, 3);
    IcsSetCompression(ip, IcsCompr_gzip, 6);
    retval = IcsClose(ip);
    if (retval != IcsErr_Ok) {



View it on GitLab: https://salsa.debian.org/med-team/libics/commit/05af19a6daab404660498d440982192ab731416d

---
View it on GitLab: https://salsa.debian.org/med-team/libics/commit/05af19a6daab404660498d440982192ab731416d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20180502/fee65f4e/attachment-0001.html>


More information about the debian-med-commit mailing list