From a237f3e7b52f296eac314f7fa2a9df5a4d4cd687 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 5 Nov 2015 16:56:53 -0600 Subject: [PATCH 01/55] wip: orion_multiscaleLaplacianFilter: implement multiscale processing TODO: fix the FFT to treat data for ifftn as conjugate symmetric. This will fix the code for finding the maximum response. --- .../multiscaleLaplacianFilter.c | 92 ++++++++++++++++--- .../multiscaleLaplacianFilter.h | 6 +- .../multiscaleLaplacianFilter.c | 4 +- 3 files changed, 86 insertions(+), 16 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 9657a0c..cf19d92 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -7,6 +7,7 @@ #include "util/util.h" #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.h" +#include "ndarray/ndarray3_fft.h" #define ORION_LAPLACIAN_HDAF_APPROX_DEGREE 60 @@ -52,23 +53,59 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( int n = ORION_LAPLACIAN_HDAF_APPROX_DEGREE; /* Fourier transform the input image */ - ndarray3* v_fft = ndarray3_fftn(input_volume); + ndarray3_complex* v_fft = ndarray3_fftn_r2c(input_volume); + /*[>DEBUG<]ndarray3_complex_printf(v_fft, "v", "%8.3f", "%8.3f");*/ + /*[>REMOVE DEBUG<]{ + ndarray3* back = + ndarray3_ifftn_c2r( v_fft ); + + complex double ss = 0; + float64 sss = 0; + float64 inf_norm = -INFINITY; + for( int i = 0; i < ndarray3_complex_elems(v_fft); i++ ) { + sss += input_volume->p[i]; + ss += v_fft->p[i]; + + float64 d = fabs(input_volume->p[i] + - back->p[i]); + if( d > inf_norm ) { + [> find max <] + inf_norm = d; + } + } + printf("sss %f; sum = %g + %gi\n", sss, creal(ss), cimag(ss)); + complex_pixel_type zz000 = ndarray3_complex_get(v_fft, 0,0,0); + printf("zz(0,0,0) %f + %fi\n", creal(zz000), cimag(zz000)); + complex_pixel_type zz111 = ndarray3_complex_get(v_fft, 1,1,1); + printf("zz(1,1,1) %f + %fi\n", creal(zz111), cimag(zz111)); + printf("norm_∞: %f\n", inf_norm); + + ndarray3_free(back); + }*/ output->laplacian - = ndarray3_new_with_size_from_ndarray3(input_volume); + = ndarray3_complex_new( + input_volume->sz[0], + input_volume->sz[1], + input_volume->sz[2] ); output->max_response_at_scale_idx = ndarray3_new_with_size_from_ndarray3(input_volume); int nx = v_fft->sz[0], ny = v_fft->sz[1], nz = v_fft->sz[2]; /* used to hold the Laplacian for a given scale */ - ndarray3* cur_scale_laplacian = - ndarray3_new_with_size_from_ndarray3(input_volume); + ndarray3_complex* cur_scale_laplacian = + ndarray3_complex_new( + input_volume->sz[0], + input_volume->sz[1], + input_volume->sz[2] + ); size_t lap_scale_len = array_length_float(laplacian_scales); bool recorded_maximum_scale = false; for( int lap_idx = 0; lap_idx < lap_scale_len; lap_idx++ ) { + /* compute the Laplacian for each scale */ float laplacian_scale_factor = array_get_float( laplacian_scales, lap_idx ); float64 norm_const = _orion_ConstantToNormalizeFilter(laplacian_scale_factor); @@ -77,16 +114,24 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( NDARRAY3_LOOP_OVER_START( filt, i,j,k) { - /* normalise the generated Laplacian filter */ + /* normalise the generated Laplacian filter + * + * filt /= norm_const; + */ ndarray3_set(filt, i,j,k, ndarray3_get(filt, i,j,k) / norm_const ); /* Apply the filter to the input volume using pointwise - * multiplication in the Fourier domain. */ - ndarray3_set(cur_scale_laplacian, i,j,k, - ndarray3_get(v_fft, i,j,k) + * multiplication in the Fourier domain. + * + * cur_scale_laplacian = v_fft .* filt; + * + * NOTE: This is a complex multiplied by a scalar. + */ + ndarray3_complex_set(cur_scale_laplacian, i,j,k, + ndarray3_complex_get(v_fft, i,j,k) * ndarray3_get(filt, i,j,k) ); } NDARRAY3_LOOP_OVER_END; @@ -94,12 +139,12 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( /* Now apply the inverse Fourier transform to bring the * filtered volume back to the spatial domain */ ndarray3* cur_scale_filt_vol = - ndarray3_ifftn_symmetric( cur_scale_laplacian ); + ndarray3_ifftn_c2r( cur_scale_laplacian ); /* check for maximum response across all scales */ if( !recorded_maximum_scale ) { NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { - ndarray3_set( output->laplacian, i,j,k, + ndarray3_complex_set( output->laplacian, i,j,k, ndarray3_get(cur_scale_laplacian, i,j,k) ); ndarray3_set( output->max_response_at_scale_idx, i,j,k, @@ -110,13 +155,34 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( recorded_maximum_scale = true; } else { if( p->multiscale ) { - WARN_UNIMPLEMENTED; + /* Multiscale approach */ + NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { + complex_pixel_type* cur = &ndarray3_get(cur_scale_laplacian, i,j,k); + complex_pixel_type* lap = &ndarray3_get(output->laplacian, i,j,k); + if( cabsf(*cur) >= cabsf(*lap) ) { + /* the current scale is recorded as the maximum at this point */ + *lap = *cur; + ndarray3_set( output->scales, i,j,k, lap_idx); + } + } NDARRAY3_LOOP_OVER_END; } else { - WARN_UNIMPLEMENTED; + /* ISBI 2014 */ + NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { + complex_pixel_type* cur = &ndarray3_get(cur_scale_laplacian, i,j,k); + complex_pixel_type* lap = &ndarray3_get(output->laplacian, i,j,k); + if( *cur > *lap ) { + *lap = *cur; + } + } NDARRAY3_LOOP_OVER_END; } } + + ndarray3_free(cur_scale_filt_vol); + ndarray3_free(filt); } - ndarray3_free(cur_scale_laplacian); + + ndarray3_complex_free(cur_scale_laplacian); + ndarray3_complex_free(v_fft); return output; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h index bab702b..dbf05d1 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h @@ -7,6 +7,7 @@ /* local headers */ #include "ndarray/ndarray3.h" +#include "ndarray/ndarray3_complex.h" #include "container/array.h" #include "param/segmentation.h" @@ -15,7 +16,7 @@ typedef struct { /* each element contains the maximum response of the Laplacian over the * scales in `laplacian_scales`. */ - ndarray3* laplacian; + ndarray3_complex* laplacian; /* each element of scale_for_max_response contains the index of the * scale in `laplacian_scales` for which the response is maximised @@ -33,6 +34,9 @@ extern orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( array_float* laplacian_scales, orion_segmentation_param* p ); +extern orion_multiscale_laplacian_output* orion_multiscale_laplacian_output_new(); +extern void orion_multiscale_laplacian_output_free(orion_multiscale_laplacian_output* r); + #ifdef __cplusplus }; #endif /* __cplusplus */ diff --git a/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 79ec054..8ab6cbd 100644 --- a/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -37,8 +37,7 @@ int main(void) { orion_segmentation_param_new(); orion_settingDefaultParameters(p); - ok(1, "stub for orion_multiscaleLaplacianFilter"); /* TODO stub: remove later */ -#if 0 /* stub */ +#if 1 /* stub */ orion_multiscale_laplacian_output* r = orion_multiscaleLaplacianFilter( n, lap_scales, p ); @@ -46,6 +45,7 @@ int main(void) { is_double(1199656.000000, ndarray3_sum_over_all_float64( r->laplacian ), eps, "sum of Laplacian response is as expected" ); #endif + orion_multiscale_laplacian_output_free(r); orion_segmentation_param_free(p); array_free_float(lap_scales); ndarray3_free(n); From ac96bd841fe9fb83489df8c27017dc1de8f0caba Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 1 Jan 2016 23:08:52 -0600 Subject: [PATCH 02/55] add notes on the construction of the Laplacian in the Fourier domain --- .../multiscaleLaplacianFilter.c | 44 ++++++++++--------- .../multiscaleLaplacianFilter.h | 6 ++- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index cf19d92..ca953e9 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -85,16 +85,15 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( }*/ output->laplacian - = ndarray3_complex_new( - input_volume->sz[0], - input_volume->sz[1], - input_volume->sz[2] ); + = ndarray3_new_with_size_from_ndarray3(input_volume); output->max_response_at_scale_idx = ndarray3_new_with_size_from_ndarray3(input_volume); int nx = v_fft->sz[0], ny = v_fft->sz[1], nz = v_fft->sz[2]; - /* used to hold the Laplacian for a given scale */ + /* used to hold the Laplacian response in the Fourier domain for a + * given scale + */ ndarray3_complex* cur_scale_laplacian = ndarray3_complex_new( input_volume->sz[0], @@ -137,15 +136,20 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( } NDARRAY3_LOOP_OVER_END; /* Now apply the inverse Fourier transform to bring the - * filtered volume back to the spatial domain */ + * filtered volume back to the spatial domain. + * + * Again, note that the response is real because the input data + * is real and we treat the data in `cur_scale_laplacian` after + * applying the filter as conjugate symmetric. + * */ ndarray3* cur_scale_filt_vol = ndarray3_ifftn_c2r( cur_scale_laplacian ); /* check for maximum response across all scales */ if( !recorded_maximum_scale ) { - NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { - ndarray3_complex_set( output->laplacian, i,j,k, - ndarray3_get(cur_scale_laplacian, i,j,k) + NDARRAY3_LOOP_OVER_START( cur_scale_filt_vol, i,j,k) { + ndarray3_set( output->laplacian, i,j,k, + ndarray3_get(cur_scale_filt_vol, i,j,k) ); ndarray3_set( output->max_response_at_scale_idx, i,j,k, lap_idx @@ -156,22 +160,22 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( } else { if( p->multiscale ) { /* Multiscale approach */ - NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { - complex_pixel_type* cur = &ndarray3_get(cur_scale_laplacian, i,j,k); - complex_pixel_type* lap = &ndarray3_get(output->laplacian, i,j,k); - if( cabsf(*cur) >= cabsf(*lap) ) { + NDARRAY3_LOOP_OVER_START( cur_scale_filt_vol, i,j,k) { + pixel_type cur = ndarray3_get(cur_scale_filt_vol, i,j,k); + pixel_type lap = ndarray3_get(output->laplacian, i,j,k); + if( fabs(cur) >= fabs(lap) ) { /* the current scale is recorded as the maximum at this point */ - *lap = *cur; - ndarray3_set( output->scales, i,j,k, lap_idx); + ndarray3_set(output->laplacian, i,j,k, lap); + ndarray3_set(output->max_response_at_scale_idx, i,j,k, lap_idx); } } NDARRAY3_LOOP_OVER_END; } else { /* ISBI 2014 */ - NDARRAY3_LOOP_OVER_START( cur_scale_laplacian, i,j,k) { - complex_pixel_type* cur = &ndarray3_get(cur_scale_laplacian, i,j,k); - complex_pixel_type* lap = &ndarray3_get(output->laplacian, i,j,k); - if( *cur > *lap ) { - *lap = *cur; + NDARRAY3_LOOP_OVER_START( cur_scale_filt_vol, i,j,k) { + pixel_type cur = ndarray3_get(cur_scale_filt_vol, i,j,k); + pixel_type lap = ndarray3_get(output->laplacian, i,j,k); + if( cur > lap ) { + ndarray3_set(output->laplacian, i,j,k, cur); } } NDARRAY3_LOOP_OVER_END; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h index dbf05d1..873486e 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h @@ -15,8 +15,12 @@ typedef struct { /* each element contains the maximum response of the Laplacian over the * scales in `laplacian_scales`. + * + * The elements of this are not complex because we are operating on + * only real-data and this means that the Fourier domain values are + * conjugate symmetric. */ - ndarray3_complex* laplacian; + ndarray3* laplacian; /* each element of scale_for_max_response contains the index of the * scale in `laplacian_scales` for which the response is maximised From 04664d4c99c5aa6343435a98c7770126dcf0048e Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 21 Jan 2016 12:41:08 -0600 Subject: [PATCH 03/55] WIP: stub out multiscale Laplacian filter --- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 8ab6cbd..42fdebd 100644 --- a/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/t/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -37,15 +37,17 @@ int main(void) { orion_segmentation_param_new(); orion_settingDefaultParameters(p); -#if 1 /* stub */ +#if 0 /* stub */ orion_multiscale_laplacian_output* r = orion_multiscaleLaplacianFilter( n, lap_scales, p ); /* value take from MATLAB code above */ is_double(1199656.000000, ndarray3_sum_over_all_float64( r->laplacian ), eps, "sum of Laplacian response is as expected" ); -#endif orion_multiscale_laplacian_output_free(r); +#else + ok(1, "stubbed out"); +#endif orion_segmentation_param_free(p); array_free_float(lap_scales); ndarray3_free(n); From 9b5c7fa798b3c20e2af2bb175539c015bb55555f Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 18 Mar 2016 11:36:29 -0500 Subject: [PATCH 04/55] Rename volume parameter for orion_readNegativeSamples --- .../dendrites_main/DetectTrainingSet/readNegativeSamples.c | 2 +- .../dendrites_main/DetectTrainingSet/readNegativeSamples.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index 5861a7f..78da3b4 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -6,7 +6,7 @@ */ void orion_readNegativeSamples( orion_segmentation_param* param, - ndarray3* input_volume ) { + ndarray3* vol ) { WARN_UNIMPLEMENTED; LOG_INFO("%s", "Detecting training set of background samples..."); diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h index 1a5b8fc..15f4fa0 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h @@ -24,7 +24,7 @@ extern "C" { /* Function prototypes */ extern void orion_readNegativeSamples( orion_segmentation_param* param, - ndarray3* input_volume ); + ndarray3* vol ); #ifdef __cplusplus }; From cd7ace1edd041e983be1fa20dec954122ce3dfb9 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sun, 27 Mar 2016 23:10:40 -0500 Subject: [PATCH 05/55] Finalise the multiscale Laplacian filter --- .../multiscaleLaplacianFilter.c | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index ca953e9..22142e1 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -6,6 +6,7 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" #include "util/util.h" +#include "simple-log/simplelog.h" #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.h" #include "ndarray/ndarray3_fft.h" @@ -54,36 +55,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( /* Fourier transform the input image */ ndarray3_complex* v_fft = ndarray3_fftn_r2c(input_volume); - /*[>DEBUG<]ndarray3_complex_printf(v_fft, "v", "%8.3f", "%8.3f");*/ - /*[>REMOVE DEBUG<]{ - ndarray3* back = - ndarray3_ifftn_c2r( v_fft ); - - complex double ss = 0; - float64 sss = 0; - float64 inf_norm = -INFINITY; - for( int i = 0; i < ndarray3_complex_elems(v_fft); i++ ) { - sss += input_volume->p[i]; - ss += v_fft->p[i]; - - float64 d = fabs(input_volume->p[i] - - back->p[i]); - if( d > inf_norm ) { - [> find max <] - inf_norm = d; - } - } - printf("sss %f; sum = %g + %gi\n", sss, creal(ss), cimag(ss)); - complex_pixel_type zz000 = ndarray3_complex_get(v_fft, 0,0,0); - printf("zz(0,0,0) %f + %fi\n", creal(zz000), cimag(zz000)); - complex_pixel_type zz111 = ndarray3_complex_get(v_fft, 1,1,1); - printf("zz(1,1,1) %f + %fi\n", creal(zz111), cimag(zz111)); - printf("norm_∞: %f\n", inf_norm); - - ndarray3_free(back); - - }*/ output->laplacian = ndarray3_new_with_size_from_ndarray3(input_volume); output->max_response_at_scale_idx @@ -106,12 +78,12 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( for( int lap_idx = 0; lap_idx < lap_scale_len; lap_idx++ ) { /* compute the Laplacian for each scale */ float laplacian_scale_factor = array_get_float( laplacian_scales, lap_idx ); + LOG_INFO("Computing Laplacian using scale: %f", laplacian_scale_factor); float64 norm_const = _orion_ConstantToNormalizeFilter(laplacian_scale_factor); ndarray3* filt = orion_Makefilter( nx,ny,nz, n, laplacian_scale_factor, orion_Makefilter_FLAG_A); - NDARRAY3_LOOP_OVER_START( filt, i,j,k) { /* normalise the generated Laplacian filter * @@ -130,8 +102,8 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( * NOTE: This is a complex multiplied by a scalar. */ ndarray3_complex_set(cur_scale_laplacian, i,j,k, - ndarray3_complex_get(v_fft, i,j,k) - * ndarray3_get(filt, i,j,k) + ndarray3_complex_get(v_fft, i,j,k) + * ndarray3_get(filt, i,j,k) ); } NDARRAY3_LOOP_OVER_END; @@ -162,7 +134,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( /* Multiscale approach */ NDARRAY3_LOOP_OVER_START( cur_scale_filt_vol, i,j,k) { pixel_type cur = ndarray3_get(cur_scale_filt_vol, i,j,k); - pixel_type lap = ndarray3_get(output->laplacian, i,j,k); + pixel_type lap = ndarray3_get(output->laplacian, i,j,k); if( fabs(cur) >= fabs(lap) ) { /* the current scale is recorded as the maximum at this point */ ndarray3_set(output->laplacian, i,j,k, lap); @@ -171,6 +143,9 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( } NDARRAY3_LOOP_OVER_END; } else { /* ISBI 2014 */ + /* Check if the values themselves are larger + * than the current maximum + */ NDARRAY3_LOOP_OVER_START( cur_scale_filt_vol, i,j,k) { pixel_type cur = ndarray3_get(cur_scale_filt_vol, i,j,k); pixel_type lap = ndarray3_get(output->laplacian, i,j,k); From 8d5c47283e6d56f26eefc4aec8f381c788d8a45a Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sun, 27 Mar 2016 23:45:04 -0500 Subject: [PATCH 06/55] Implement readNegativeSamples --- .../DetectTrainingSet/readNegativeSamples.c | 23 ++++++++++++++++--- .../DetectTrainingSet/readNegativeSamples.h | 10 ++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index 78da3b4..8ba209e 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -4,11 +4,10 @@ * * Refactor: readNegativeSamples */ -void orion_readNegativeSamples( +orion_multiscale_laplacian_output* +orion_readNegativeSamples( orion_segmentation_param* param, ndarray3* vol ) { - WARN_UNIMPLEMENTED; - LOG_INFO("%s", "Detecting training set of background samples..."); /* @@ -17,4 +16,22 @@ void orion_readNegativeSamples( */ /*Lap = 0.5913./p.sigma;*/ /*Lap = 0.66./p.sigma;*/ + /*%n=60;Lap = sqrt(2.0*n+1)./(sqrt(2)*(3.6853*p.sigma - 2.1676)*pi);*/ + size_t n_scales = array_length_float( param->scales ); + array_float* Lap = array_new_float( n_scales ); + for( size_t Lap_idx = 0; Lap_idx < n_scales; Lap_idx++ ) { + array_set_float( Lap, Lap_idx, + 0.66 / array_get_float( param->scales, Lap_idx ) ); + } + + orion_multiscale_laplacian_output* lap_out = orion_multiscaleLaplacianFilter( vol, Lap, param ); + + + /* Only the positive values are background voxels */ + NDARRAY3_LOOP_OVER_START( lap_out->laplacian, i,j,k) { + ndarray3_set( lap_out->laplacian, i,j,k, + ndarray3_get( lap_out->laplacian, i,j,k) > 0 ); + } NDARRAY3_LOOP_OVER_END; + + return lap_out; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h index 15f4fa0..d2b5048 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h @@ -11,18 +11,16 @@ #include "ndarray/ndarray3.h" #include "simple-log/simplelog.h" -/* structs, enums */ -typedef struct { - bool multiscale; - vector_float spacing; -} orion_readNegativeSamples_param; +#include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Function prototypes */ -extern void orion_readNegativeSamples( +extern +orion_multiscale_laplacian_output* +orion_readNegativeSamples( orion_segmentation_param* param, ndarray3* vol ); From 9a7402765ce40362f0fef7473b704bfd806099b3 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 28 Mar 2016 12:05:16 -0500 Subject: [PATCH 07/55] Add comment about getFeatures function --- .../dendrites_main/ExtractFeatures/getFeatures.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c index cc4fab3..6b15699 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c @@ -1,4 +1,5 @@ -/* TODO +/* + * Get the Eigenvalues of the Hessian matrix as features. * * Refactor: getFeatures */ From 7df94714d3b37076465a83911e7e4131ee7c3367 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 28 Mar 2016 15:23:44 -0500 Subject: [PATCH 08/55] Remove TODO --- .../ExtractFeatures/computeEigenvaluesGaussianFilter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeEigenvaluesGaussianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeEigenvaluesGaussianFilter.c index 954a1ec..0f609ac 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeEigenvaluesGaussianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeEigenvaluesGaussianFilter.c @@ -28,8 +28,7 @@ array_orion_eig_feat_result* orion_computeEigenvaluesGaussianFilter( die("Please refactor and remove use of apply_log as it is orthogonal to the eigenvalue filtering ( apply_log == %c )", apply_log); } - /* TODO loop over all scales */ - + /* loop over all scales */ size_t n_scales = array_length_float(scales); array_orion_eig_feat_result* all_results = array_new_orion_eig_feat_result(n_scales); for( size_t scale_idx = 0; scale_idx < n_scales; scale_idx++ ) { From 55f3491c06d454b0cabd891631ee9025c80abe10 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 11:53:03 -0500 Subject: [PATCH 09/55] Add notes about the contents of the Laplacian response --- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 2 +- .../DetectTrainingSet/multiscaleLaplacianFilter.h | 3 +++ .../dendrites_main/DetectTrainingSet/readNegativeSamples.c | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 22142e1..6ee840d 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -75,7 +75,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( size_t lap_scale_len = array_length_float(laplacian_scales); bool recorded_maximum_scale = false; - for( int lap_idx = 0; lap_idx < lap_scale_len; lap_idx++ ) { + for( size_t lap_idx = 0; lap_idx < lap_scale_len; lap_idx++ ) { /* compute the Laplacian for each scale */ float laplacian_scale_factor = array_get_float( laplacian_scales, lap_idx ); LOG_INFO("Computing Laplacian using scale: %f", laplacian_scale_factor); diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h index 873486e..3154f6e 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h @@ -24,6 +24,9 @@ typedef struct { /* each element of scale_for_max_response contains the index of the * scale in `laplacian_scales` for which the response is maximised + * + * NOTE: Elements of this are of type `size_t`, but are stored in a + * `pixel_type` for convenience. */ ndarray3* max_response_at_scale_idx; } orion_multiscale_laplacian_output; diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index 8ba209e..d73024b 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -27,7 +27,11 @@ orion_readNegativeSamples( orion_multiscale_laplacian_output* lap_out = orion_multiscaleLaplacianFilter( vol, Lap, param ); - /* Only the positive values are background voxels */ + /* Only the positive values are background voxels. + * + * We set the `laplacian` member to 1.0 or 0.0 depending on if it is in + * the background. + */ NDARRAY3_LOOP_OVER_START( lap_out->laplacian, i,j,k) { ndarray3_set( lap_out->laplacian, i,j,k, ndarray3_get( lap_out->laplacian, i,j,k) > 0 ); From 73dc304bd4bf8b055a5e339db10a3d29bea3f8a1 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 11:57:31 -0500 Subject: [PATCH 10/55] Compute features with scales adjusted by the volume spacing --- .../ExtractFeatures/computeFeatures.c | 56 ++++++++++++++++++- .../ExtractFeatures/computeFeatures.h | 10 +++- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c index 9664709..7f21747 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c @@ -1,9 +1,59 @@ -/* TODO +/* Retrieve the feature vectors for the training instances. * * Refactor: computeFeatures */ #include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h" -vector_float* orion_computeFeatures( orion_segmentation_param* param, ndarray3* vol ) { - WARN_UNIMPLEMENTED; +#include "container/vector.h" +#include "container/array.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeEigenvaluesGaussianFilter.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h" + +orion_features* orion_computeFeatures( + orion_segmentation_param* param, + ndarray3* vol, + orion_multiscale_laplacian_output* laplacian_result) { + /* + * The features are the eigenvalues of the Hessian Matrix + * Set the parameters Low-pass filter that we want to use. + */ + bool filter_isotropic = false; + array_float* adjusted_scales; + orion_features* feat; + + pixel_type spacing_0dim = vol->has_spacing ? vol->spacing[0] : 1.0; + /* only use the first scale if not multiscale */ + size_t number_of_scales = param->multiscale + ? array_length_float( param->scales ) + : 1; + + /* adjust the scales by the spacing of the first dimension */ + adjusted_scales = array_new_float( number_of_scales ); + for( size_t s_idx = 0 ; s_idx < number_of_scales; s_idx++ ) { + array_set_float( adjusted_scales, s_idx, + spacing_0dim * array_get_float( param->scales, s_idx ) + ); + } + + array_orion_eig_feat_result* result; + /* compute the eigenvalues for the given scales */ + if( filter_isotropic ) { + /* compute the eigenvalues using the Isotropic Low pass filter */ + TODO(Dead code); + /* TODO Remove this + * orion_compute_SecondOrderDerivatives(vol, sigma, 60); + */ + } else { + /* compute the eigenvalues using the Gaussian filter */ + result = orion_computeEigenvaluesGaussianFilter( + vol, + EIG_FEAT_METHOD_SORT_FRANGI, + param->apply_log, + adjusted_scales ); + } + + /* Turn the result into feature vectors */ + feat = orion_readEigenvaluesGaussianFilter( result, laplacian_result ); + + return feat; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h index a439f8e..446664a 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h @@ -7,16 +7,20 @@ /* local headers */ #include "ndarray/ndarray3.h" -#include "container/vector.h" #include "param/segmentation.h" - +#include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" +#include "segmentation/orion_features.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Function prototypes */ -extern vector_float* orion_computeFeatures( orion_segmentation_param* param, ndarray3* vol ); +extern +orion_features* orion_computeFeatures( + orion_segmentation_param* param, + ndarray3* vol, + orion_multiscale_laplacian_output* laplacian_result); #ifdef __cplusplus }; From b58fe55916dd6cbb668545204dfd7ac135e5672e Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 11:58:23 -0500 Subject: [PATCH 11/55] Helper function to compute features --- .../dendrites_main/ExtractFeatures/getFeatures.c | 8 +++++--- .../dendrites_main/ExtractFeatures/getFeatures.h | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c index 6b15699..f3cbe6d 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.c @@ -6,11 +6,13 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h" #include "simple-log/simplelog.h" -#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h" -vector_float* orion_getFeatures( orion_segmentation_param* param, ndarray3* vol ) { +orion_features* orion_getFeatures( + orion_segmentation_param* param, + ndarray3* vol, + orion_multiscale_laplacian_output* laplacian_result ) { LOG_INFO("Computing Eigenvalues of Hessian Matrix..."); - vector_float* feat = orion_computeFeatures(param, vol); + orion_features* feat = orion_computeFeatures(param, vol, laplacian_result ); LOG_INFO("Done computing eigenvalues."); return feat; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h index a4d1343..8670461 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h @@ -9,13 +9,19 @@ #include "ndarray/ndarray3.h" #include "container/vector.h" #include "param/segmentation.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Function prototypes */ -extern vector_float* orion_getFeatures( orion_segmentation_param* param, ndarray3* vol ); +extern +orion_features* orion_getFeatures( + orion_segmentation_param* param, + ndarray3* vol, + orion_multiscale_laplacian_output* laplacian_result ); #ifdef __cplusplus }; From e2575b8b5534073ddde96d77863ee8e09b31c3ec Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 11:59:40 -0500 Subject: [PATCH 12/55] Translate the Gaussian response into feature vectors --- .../readEigenvaluesGaussianFilter.c | 59 +++++++++++++++++++ .../readEigenvaluesGaussianFilter.h | 27 +++++++++ lib/segmentation/orion_features.c | 18 ++++++ lib/segmentation/orion_features.h | 39 ++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h create mode 100644 lib/segmentation/orion_features.c create mode 100644 lib/segmentation/orion_features.h diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.c index 14a3b04..3f5eca1 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.c @@ -1,4 +1,63 @@ +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h" + +#include + /* TODO + * + * Returns a feature vector for every training instance. + * + * Uses the multiscale Laplacian response to choose the appropriate scale. + * + * Filters out NaN values in the feature vector. * * Refactor: readEigenvaluesGaussianFilter */ +orion_features* orion_readEigenvaluesGaussianFilter( + array_orion_eig_feat_result* eigen, + orion_multiscale_laplacian_output* laplacian_result ) { + + orion_features* feat; + + /* only keep the 2nd and 3rd eigenvalues */ + orion_eig_feat_result* result_first_scale + = array_get_orion_eig_feat_result( eigen, 0 ); + + ndarray3* result_first_scale_first_eig + = array_get_ndarray3( result_first_scale->eig_feat, 0 ); + + size_t feat_instances = ndarray3_elems(result_first_scale_first_eig); + + feat = orion_features_new( feat_instances ); + + /* Use the scale index in `laplacian_result` to create a length 2 + * feature vector for every training pixel. + * + * The features are the 2nd and 3rd eigenvalues at the maximal + * Laplacian response scale. + */ + for( int n_idx = 0; n_idx < feat_instances; n_idx++ ) { + size_t scale_idx = (size_t)( laplacian_result->max_response_at_scale_idx->p[n_idx] ); + + orion_eig_feat_result* scale_result + = array_get_orion_eig_feat_result( eigen, scale_idx ); + + /* get the 2nd eigenvalue (at index 1) */ + pixel_type eig_2nd = array_get_ndarray3( scale_result->eig_feat, 1 )->p[n_idx]; + + /* get the 3rd eigenvalue (at index 2) */ + pixel_type eig_3rd = array_get_ndarray3( scale_result->eig_feat, 2 )->p[n_idx]; + + /* If NaN, then replace with zero. + * + * This is to prevent NaN propagation in other calculations. + */ + if( isnan(eig_2nd) ) { eig_2nd = 0; } + if( isnan(eig_3rd) ) { eig_3rd = 0; } + + /* store in feature vector */ + vector_set_float( feat->features[0], n_idx, eig_2nd ); + vector_set_float( feat->features[1], n_idx, eig_3rd ); + } + + return feat; +} diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h new file mode 100644 index 0000000..ba21d6b --- /dev/null +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/readEigenvaluesGaussianFilter.h @@ -0,0 +1,27 @@ +#ifndef ORION_READ_EIGEN_GAUSS_H +#define ORION_READ_EIGEN_GAUSS_H 1 + +/* system headers */ +#include +#include + +/* local headers */ +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/array_eig_feat_result.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" +#include "segmentation/orion_features.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +orion_features* orion_readEigenvaluesGaussianFilter( + array_orion_eig_feat_result* eigen, + orion_multiscale_laplacian_output* laplacian_result ); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_READ_EIGEN_GAUSS_H */ diff --git a/lib/segmentation/orion_features.c b/lib/segmentation/orion_features.c new file mode 100644 index 0000000..21d498e --- /dev/null +++ b/lib/segmentation/orion_features.c @@ -0,0 +1,18 @@ +#include "segmentation/orion_features.h" + +orion_features* orion_features_new( size_t instances ) { + orion_features* f; + NEW( f, orion_features ); + f->number_of_features = ORION_NUMBER_OF_SEGMENTATION_FEATURES; + f->number_of_instances = instances; + for( size_t f_idx = 0; f_idx < f->number_of_features; f_idx++ ) { + f->features[f_idx] = vector_new_float( instances ); + } +} + +void orion_features_free( orion_features* f ) { + for( size_t f_idx = 0; f_idx < f->number_of_features; f_idx++ ) { + vector_free_float( f->features[f_idx] ); + f->features[f_idx] = NULL; + } +} diff --git a/lib/segmentation/orion_features.h b/lib/segmentation/orion_features.h new file mode 100644 index 0000000..6948d8f --- /dev/null +++ b/lib/segmentation/orion_features.h @@ -0,0 +1,39 @@ +#ifndef ORION_FEATURES_H +#define ORION_FEATURES_H 1 + +/* system headers */ +#include +#include + +/* local headers */ +#include "container/vector.h" + +/* structs, enums */ +#define ORION_NUMBER_OF_SEGMENTATION_FEATURES 2 + +typedef struct { + /* + * There are two features + * + * features[0]: The 2nd eigenvalue of the Gaussian filter. + * + * features[1]: The 3rd eigenvalue of the Gaussian filter. + */ + size_t number_of_features; + vector_float* features[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + size_t number_of_instances; +} orion_features; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern orion_features* orion_features_new( size_t instances ); +extern void orion_features_free( orion_features* f ); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_FEATURES_H */ From 9c975c7f18dba7a6dac1ce31640ca7d7aa5dc16a Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 12:00:18 -0500 Subject: [PATCH 13/55] ndarray3 function to compute minimum and maximum values --- lib/ndarray/ndarray3.c | 16 ++++++++++++++++ lib/ndarray/ndarray3.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/lib/ndarray/ndarray3.c b/lib/ndarray/ndarray3.c index 76be529..14e0c81 100644 --- a/lib/ndarray/ndarray3.c +++ b/lib/ndarray/ndarray3.c @@ -1,6 +1,7 @@ #include "ndarray/ndarray3.h" #include +#include #include "util/string.h" @@ -168,3 +169,18 @@ float64 ndarray3_sum_over_all_float64( const ndarray3* n ) { } return sum; } + +void ndarray3_minmax( ndarray3* n, pixel_type* min, pixel_type* max ) { + size_t nelem = ndarray3_elems( n ); + *min = FLT_MAX; + *max = -FLT_MAX; + for( size_t idx = 0; idx < nelem; idx++ ) { + if( n->p[idx] < *min ) { + *min = n->p[idx]; + } + + if( n->p[idx] > *max ) { + *max = n->p[idx]; + } + } +} diff --git a/lib/ndarray/ndarray3.h b/lib/ndarray/ndarray3.h index 81a90a6..6864242 100644 --- a/lib/ndarray/ndarray3.h +++ b/lib/ndarray/ndarray3.h @@ -67,6 +67,8 @@ extern void ndarray3_dump( ndarray3* n ); extern void ndarray3_printf( ndarray3* n, const char* variable_name, const char* format ); extern void ndarray3_printf_matlab( ndarray3* n, const char* variable_name, const char* format ); +/* TODO document */ +extern void ndarray3_minmax( ndarray3* n, pixel_type* min, pixel_type* max ); /* testing functions */ extern bool ndarray3_is_same_size( ndarray3* a, ndarray3* b ); From 9a4f5e93424e7c5be3213fedcbc632efb4878e14 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:37:28 -0500 Subject: [PATCH 14/55] build: fix for linking of binary with ITK dep --- Makefile | 1 + make/liborion-config.mk | 2 ++ make/liborion.mk | 4 ---- make/util-rules.mk | 14 ++++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 make/liborion-config.mk diff --git a/Makefile b/Makefile index 36b4bfa..0499cd2 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ include make/vaa3d-plugin-config.mk include make/test-config.mk include make/liborion3mat-config.mk include make/misc-config.mk +include make/liborion-config.mk ## Generate the targets LIB_OBJ:= $(call OBJ_PATHSUBST.c,$(LIB_SRC.c)) diff --git a/make/liborion-config.mk b/make/liborion-config.mk new file mode 100644 index 0000000..98f5e1e --- /dev/null +++ b/make/liborion-config.mk @@ -0,0 +1,2 @@ +ITK_INTEGRATION_OBJ := $(EIGEN_FRANGI_LIB_OBJ) $(EIGEN_SATO_LIB_OBJ) \ + $(ITK_INTEGRATION_LIB_OBJ) diff --git a/make/liborion.mk b/make/liborion.mk index 90c0af7..c6c51f5 100644 --- a/make/liborion.mk +++ b/make/liborion.mk @@ -1,7 +1,3 @@ -ITK_INTEGRATION_OBJ := $(EIGEN_FRANGI_LIB_OBJ) $(EIGEN_SATO_LIB_OBJ) \ - $(ITK_INTEGRATION_LIB_OBJ) - $(LIBORION.A): $(LIB_OBJ) $(ITK_INTEGRATION_OBJ) mkdir -p `dirname $@` $(AR) $(ARFLAGS) $@ $^ - diff --git a/make/util-rules.mk b/make/util-rules.mk index 87acdcb..cf93349 100644 --- a/make/util-rules.mk +++ b/make/util-rules.mk @@ -3,9 +3,11 @@ $(BINDIR)/subsample-volume/SubsampleVolume$(EXEEXT): $(SRCDIR)/subsample-volume/ $(CMAKE.generate) -B$(BINDIR)/subsample-volume -H$(SRCDIR)/subsample-volume $(MAKE) -C$(BINDIR)/subsample-volume -$(BINDIR)/segmentation/orion-segmentation$(EXEEXT): $(SRCDIR)/segmentation/orion-segmentation.c \ - $(BUILDDIR)/simple-log/simplelog.o \ - $(BUILDDIR)/util/util.o $(BUILDDIR)/util/string.o \ - $(BUILDDIR)/param/segmentation.o $(BUILDDIR)/param/io.o \ - $(BUILDDIR)/param/param.o \ - $(BUILDDIR)/container/array.o +BIN_ORION_SEGMENTATION := $(BINDIR)/segmentation/orion-segmentation$(EXEEXT) +$(BIN_ORION_SEGMENTATION): CPPFLAGS += $(ITK_CPPFLAGS) +$(BIN_ORION_SEGMENTATION): LDFLAGS += $(ITK_LDFLAGS) +$(BIN_ORION_SEGMENTATION): LDLIBS += $(ITK_LDLIBS) +$(BIN_ORION_SEGMENTATION): LDLIBS += -lstdc++ # needs to add C++ library to link +$(BIN_ORION_SEGMENTATION): \ + $(SRCDIR)/segmentation/orion-segmentation.c \ + $(LIBORION.A) From 4bd97ae255095d2886611defabb117fb5cefaab1 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:38:08 -0500 Subject: [PATCH 15/55] Add function to reset array container size to zero This allows for reusing a container. --- lib/container/array_impl.c | 5 +++++ lib/container/array_impl.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/container/array_impl.c b/lib/container/array_impl.c index 75a4074..27d1c5a 100644 --- a/lib/container/array_impl.c +++ b/lib/container/array_impl.c @@ -67,3 +67,8 @@ void TYPED_NAME(array_resize) ( TYPED_NAME(array)* array, size_t new_capacity ) RESIZE_COUNT(array->data, TYPE, new_capacity); array->capacity = new_capacity; } + +void TYPED_NAME(array_reset) ( TYPED_NAME(array)* array ) { + assert( array != NULL ); + array->length = 0; +} diff --git a/lib/container/array_impl.h b/lib/container/array_impl.h index 796c149..167a2ca 100644 --- a/lib/container/array_impl.h +++ b/lib/container/array_impl.h @@ -33,6 +33,8 @@ extern void TYPED_NAME(array_add) ( TYPED_NAME(array)* array, TYPE data ); /* ==== memory management ==== */ extern void TYPED_NAME(array_resize) ( TYPED_NAME(array)* array, size_t new_capacity ); +/* Resets the length of the array to zero. Does not free elements! */ +extern void TYPED_NAME(array_reset) ( TYPED_NAME(array)* array ); #ifdef __cplusplus }; From fce3af840fa6a713a02eb5be6312c3797ed5a87b Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:38:49 -0500 Subject: [PATCH 16/55] Export the filepath function for concatenating paths --- lib/io/path/path.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/io/path/path.h b/lib/io/path/path.h index 4cdae3e..0ff0bff 100644 --- a/lib/io/path/path.h +++ b/lib/io/path/path.h @@ -39,6 +39,7 @@ extern char* orion_filepath_to_string(orion_filepath* fp); extern orion_filepath* orion_filepath_base( orion_filepath* fp ); extern orion_filepath* orion_filepath_dir( orion_filepath* fp ); +extern orion_filepath* orion_filepath_cat( orion_filepath* fp1, orion_filepath* fp2 ); extern orion_filepath* orion_filepath_sibling( orion_filepath* base, orion_filepath* relative); #ifdef __cplusplus From 846be226a5af78ce27237d705840e9e55869c4f8 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:39:51 -0500 Subject: [PATCH 17/55] Add struct member for classifying background voxels by Laplacian response --- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 4 ++++ .../DetectTrainingSet/multiscaleLaplacianFilter.h | 7 +++++++ .../DetectTrainingSet/readNegativeSamples.c | 15 ++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 6ee840d..46227fc 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -27,6 +27,9 @@ void orion_multiscale_laplacian_output_free(orion_multiscale_laplacian_output* r if( r->max_response_at_scale_idx ) ndarray3_free( r->max_response_at_scale_idx ); + if( r->is_background ) + ndarray3_free( r->is_background ); + free(r); } @@ -35,6 +38,7 @@ orion_multiscale_laplacian_output* orion_multiscale_laplacian_output_new() { NEW(r, orion_multiscale_laplacian_output); r->laplacian = NULL; r->max_response_at_scale_idx = NULL; + r->is_background = NULL; return r; } diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h index 3154f6e..ab3d501 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h @@ -29,6 +29,13 @@ typedef struct { * `pixel_type` for convenience. */ ndarray3* max_response_at_scale_idx; + + /* Each element indicates if the Laplacian response at that voxel + * should be classified as in in the background. + * + * Element is either 0.0 or 1.0. + */ + ndarray3* is_background; } orion_multiscale_laplacian_output; #ifdef __cplusplus diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index d73024b..ec652bb 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -29,12 +29,17 @@ orion_readNegativeSamples( /* Only the positive values are background voxels. * - * We set the `laplacian` member to 1.0 or 0.0 depending on if it is in - * the background. + * We set the `is_background` member to 1.0 or 0.0 depending on if it is in + * the background based on the response in `laplacian`. + * + * We are working in-place to save memory, so we transfer the contents + * from `laplacian` to `is_background`. */ - NDARRAY3_LOOP_OVER_START( lap_out->laplacian, i,j,k) { - ndarray3_set( lap_out->laplacian, i,j,k, - ndarray3_get( lap_out->laplacian, i,j,k) > 0 ); + lap_out->is_background = lap_out->laplacian; + lap_out->laplacian = NULL; + NDARRAY3_LOOP_OVER_START( lap_out->is_background, i,j,k) { + ndarray3_set( lap_out->is_background, i,j,k, + ndarray3_get( lap_out->is_background, i,j,k) > 0 ); } NDARRAY3_LOOP_OVER_END; return lap_out; From 70b9321a31a0a2106126ba8941e24a6b3539ddae Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:41:39 -0500 Subject: [PATCH 18/55] Fix Laplacian adjusted scale creation --- .../dendrites_main/DetectTrainingSet/readNegativeSamples.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index ec652bb..62c729d 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -20,7 +20,7 @@ orion_readNegativeSamples( size_t n_scales = array_length_float( param->scales ); array_float* Lap = array_new_float( n_scales ); for( size_t Lap_idx = 0; Lap_idx < n_scales; Lap_idx++ ) { - array_set_float( Lap, Lap_idx, + array_add_float( Lap, 0.66 / array_get_float( param->scales, Lap_idx ) ); } From 90aa001c3177be70ea31d8b192e457ff7bf43cda Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:42:05 -0500 Subject: [PATCH 19/55] Add debug logging for multiscale Laplacian filter function --- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 46227fc..825ffd9 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -58,6 +58,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( int n = ORION_LAPLACIAN_HDAF_APPROX_DEGREE; /* Fourier transform the input image */ + LOG_DEBUG("Computing Fourier transform of input volume"); ndarray3_complex* v_fft = ndarray3_fftn_r2c(input_volume); output->laplacian @@ -88,6 +89,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( ndarray3* filt = orion_Makefilter( nx,ny,nz, n, laplacian_scale_factor, orion_Makefilter_FLAG_A); + LOG_DEBUG("Applying Laplacian filter"); NDARRAY3_LOOP_OVER_START( filt, i,j,k) { /* normalise the generated Laplacian filter * @@ -118,6 +120,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( * is real and we treat the data in `cur_scale_laplacian` after * applying the filter as conjugate symmetric. * */ + LOG_DEBUG("Inverse Fourier transform for scale %f", laplacian_scale_factor); ndarray3* cur_scale_filt_vol = ndarray3_ifftn_c2r( cur_scale_laplacian ); From ed05617464aa4849fcb5a4e0ab630b03cb8b0f18 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:43:40 -0500 Subject: [PATCH 20/55] Read ORION3 configuration format to set parameters for segmentation --- lib/param/io.c | 8 ++- lib/param/io.h | 2 + src/segmentation/orion-segmentation.c | 92 ++++++++++++++++++++++++++- 3 files changed, 99 insertions(+), 3 deletions(-) diff --git a/lib/param/io.c b/lib/param/io.c index 8034180..62c835c 100644 --- a/lib/param/io.c +++ b/lib/param/io.c @@ -5,12 +5,14 @@ orion_io_param* orion_io_param_new() { NEW( param, orion_io_param ); param->input_filename = NULL; param->output_filename = NULL; + param->orion3_config_filename = NULL; return param; } void orion_io_param_free(orion_io_param* param) { - free(param->input_filename); - free(param->output_filename); + if(param->input_filename) { free(param->input_filename); } + if(param->output_filename) { free(param->output_filename); } + if(param->orion3_config_filename) { free(param->orion3_config_filename); } free(param); } @@ -20,4 +22,6 @@ void orion_io_param_dump( orion_io_param* param ) { fprintf(stderr, "\tinput: %s\n", param->input_filename); if( param->output_filename ) fprintf(stderr, "\toutput: %s\n", param->output_filename); + if( param->orion3_config_filename ) + fprintf(stderr, "\torion3_config: %s\n", param->orion3_config_filename); } diff --git a/lib/param/io.h b/lib/param/io.h index 6c63631..d4d4c46 100644 --- a/lib/param/io.h +++ b/lib/param/io.h @@ -7,6 +7,8 @@ typedef struct { char* input_filename; char* output_filename; + + char* orion3_config_filename; } orion_io_param; #ifdef __cplusplus diff --git a/src/segmentation/orion-segmentation.c b/src/segmentation/orion-segmentation.c index 81fd52d..91307f2 100644 --- a/src/segmentation/orion-segmentation.c +++ b/src/segmentation/orion-segmentation.c @@ -5,6 +5,15 @@ #include "simple-log/simplelog.h" #include "param/param.h" #include "util/util.h" +#include "util/util.h" +#include "io/path/path.h" +#include "io/format/mhd.h" + +#include "kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.h" + +#include "orion3-config-parser/parser.h" + +#define ORION_METAINFO_FILE_FMT_SUFFIX ".mhd" typedef struct { orion_io_param* io; @@ -21,6 +30,9 @@ void usage(char* program_name) { --input _path_ : _path_ is the filename for the input volume\n\ \n\ --output _path_ : _path_ is the filename for the output volume\n\ +\n\ + --orion3-config _path_ : _path_ is the filename for the ORION3 configuration file\n\ +\n\ --help : show this information\n\ ", program_name @@ -48,6 +60,11 @@ void parse_arguments( int argc, char * argv[], param_parse* param ) { safe_malloc_and_strcpy(&(param->io->output_filename), argv[arg_idx+1]); else die("Missing argument to --output at %d", arg_idx + 1); + } else if( strcmp( argv[arg_idx], "--orion3-config" ) == 0 ) { + if( arg_idx+1 < argc ) + safe_malloc_and_strcpy(&(param->io->orion3_config_filename), argv[arg_idx+1]); + else + die("Missing argument to --orion3-config at %d", arg_idx + 1); } } @@ -58,6 +75,67 @@ void parse_param_dump(param_parse* param) { orion_segmentation_param_dump(param->segmentation); } +void orion3_config_set_parameters(param_parse* param) { + orion3_param* config_param = + orion3_param_read_input_file( param->io->orion3_config_filename ); + + /* copy the scales from the configuration */ + for( size_t scale_idx = 0; scale_idx < array_length_float(config_param->scales); scale_idx++ ) { + array_add_float( param->segmentation->scales, + array_get_float( config_param->scales, scale_idx ) ); + } + + /* copy the input volume from the configuration */ + size_t n_volumes = array_length_str(config_param->volume_names); + if( n_volumes > 0 ) { + if( n_volumes == 1 ) { + /* + * final path is: + * + * < path-to-volume-directory > / < volume-name > / < volume-name >.mhd + */ + orion_filepath* fp_base_dir = orion_filepath_new_from_string(config_param->path_to_volume_directory); + + char* vol_name = array_get_str( config_param->volume_names, 0 ); + size_t vol_name_len = strlen(vol_name); + + char* vol_name_suffix; + NEW_COUNT(vol_name_suffix, char, vol_name_len + strlen(ORION_METAINFO_FILE_FMT_SUFFIX) + 1 ); + + strncpy(vol_name_suffix, vol_name, vol_name_len), + + /* add MetaInfo suffix */ + strncpy(vol_name_suffix + vol_name_len, + ORION_METAINFO_FILE_FMT_SUFFIX, + strlen(ORION_METAINFO_FILE_FMT_SUFFIX) + 1); + + orion_filepath* fp_vol_dir = orion_filepath_new_from_string( vol_name ); + orion_filepath* fp_vol_filename = orion_filepath_new_from_string( vol_name_suffix ); + + orion_filepath* fp_vol_dir_file = orion_filepath_cat( fp_vol_dir, fp_vol_filename ); + + orion_filepath* fp_vol_full_path = orion_filepath_cat( fp_base_dir, fp_vol_dir_file ); + + safe_malloc_and_strcpy(&(param->io->input_filename), + orion_filepath_to_string(fp_vol_full_path) ); + + free(vol_name_suffix); + orion_filepath_free(fp_vol_full_path); + orion_filepath_free(fp_vol_dir_file); + orion_filepath_free(fp_vol_filename); + orion_filepath_free(fp_base_dir); + } else { + die("Can not handle multiple volumes in configuration %s", + param->io->orion3_config_filename); + } + } else { + die("No volumes files given in configuration %s", + param->io->orion3_config_filename); + } + + orion3_param_free( config_param ); +} + int main( int argc, char * argv[] ) { LOG_INFO("Starting %s", argv[0] ); @@ -68,8 +146,20 @@ int main( int argc, char * argv[] ) { parse_arguments(argc, argv, param); - parse_param_dump(param); + /* read in parameters from configuration file */ + if( param->io->orion3_config_filename ) { + orion3_config_set_parameters(param); + } + + /*DEBUG*/parse_param_dump(param); + + ndarray3* input_volume = orion_read_mhd( param->io->input_filename ); + + orion_ORION3_Dendrites( param->segmentation, input_volume ); + ndarray3_free(input_volume); + orion_io_param_free(param->io); + orion_segmentation_param_free( param->segmentation ); LOG_INFO("Stopping %s", argv[0] ); return EXIT_SUCCESS; } From f13e14530a48bf543c89f7f5dc96db076abd575a Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:44:14 -0500 Subject: [PATCH 21/55] Initialise multiscale segmentation to zero --- lib/param/segmentation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/param/segmentation.c b/lib/param/segmentation.c index 854029c..f71e031 100644 --- a/lib/param/segmentation.c +++ b/lib/param/segmentation.c @@ -6,6 +6,7 @@ orion_segmentation_param* orion_segmentation_param_new() { orion_segmentation_param* param; NEW( param, orion_segmentation_param ); param->scales = array_new_float( 10 ); + param->multiscale = 0; /* all attributes are unset at build */ #define ATTR( NAME, TYPE ) \ From 2c5fdb98fd4eec7732356c8e173c5a9da781c75e Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:44:43 -0500 Subject: [PATCH 22/55] Show usage when tool is not given any arguments --- src/segmentation/orion-segmentation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/segmentation/orion-segmentation.c b/src/segmentation/orion-segmentation.c index 91307f2..4f4f241 100644 --- a/src/segmentation/orion-segmentation.c +++ b/src/segmentation/orion-segmentation.c @@ -41,7 +41,11 @@ void usage(char* program_name) { void parse_arguments( int argc, char * argv[], param_parse* param ) { int arg_idx = 0; - for( arg_idx = 0; arg_idx < argc; arg_idx++ ) { + if( argc == 1 ) { + usage( argv[0] ); + exit(EXIT_SUCCESS); + } + for( arg_idx = 1; arg_idx < argc; arg_idx++ ) { if( strcmp( argv[arg_idx], "--help" ) == 0 ) { usage( argv[0] ); exit(EXIT_SUCCESS); From 7453e9d11672f949b4d4269799ab341bdfb341bc Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 31 Mar 2016 16:47:18 -0500 Subject: [PATCH 23/55] Add list of Debian packages required for building --- debian-packages | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 debian-packages diff --git a/debian-packages b/debian-packages new file mode 100644 index 0000000..3ab1309 --- /dev/null +++ b/debian-packages @@ -0,0 +1,2 @@ +cmake +libinsighttoolkit4-dev From 0079ec3201834eaa361509331031ee647bffef1f Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 1 Apr 2016 09:48:39 -0500 Subject: [PATCH 24/55] Use more general FFT that does not require even dimensions --- lib/ndarray/ndarray3_fft.c | 79 +++++++++++++++++++++++++++++++++++++- lib/ndarray/ndarray3_fft.h | 5 +++ 2 files changed, 82 insertions(+), 2 deletions(-) diff --git a/lib/ndarray/ndarray3_fft.c b/lib/ndarray/ndarray3_fft.c index 517e6c8..4b007a4 100644 --- a/lib/ndarray/ndarray3_fft.c +++ b/lib/ndarray/ndarray3_fft.c @@ -2,6 +2,7 @@ #include #include +#include ndarray3_complex* ndarray3_fftn_r2c( ndarray3* n ) { ndarray3_complex* freq_data = @@ -15,7 +16,7 @@ ndarray3_complex* ndarray3_fftn_r2c( ndarray3* n ) { kiss_fftndr_cfg fft = kiss_fftndr_alloc( dims, PIXEL_NDIMS, false , NULL, NULL); - kiss_fftndr(fft, (kiss_fft_scalar*)(n->p), freq_data->p ); + kiss_fftndr(fft, (kiss_fft_scalar*)(n->p), (kiss_fft_cpx *)(freq_data->p) ); free(dims); free(fft); @@ -36,7 +37,7 @@ ndarray3* ndarray3_ifftn_c2r( ndarray3_complex* n ) { kiss_fftndr_cfg ifft = kiss_fftndr_alloc( dims, PIXEL_NDIMS, true , NULL, NULL); - kiss_fftndri(ifft, n->p, spatial_data->p ); + kiss_fftndri(ifft, (kiss_fft_cpx *)(n->p), spatial_data->p ); size_t nelems = ndarray3_complex_elems( n ); for( int i = 0; i < nelems; i++ ) { @@ -48,3 +49,77 @@ ndarray3* ndarray3_ifftn_c2r( ndarray3_complex* n ) { return spatial_data; } + +ndarray3_complex* ndarray3_fftn_real( ndarray3* n ) { + ndarray3_complex* space_data = + ndarray3_complex_new(n->sz[0], n->sz[1], n->sz[2]); + NDARRAY3_LOOP_OVER_START( n, i,j,k ) { + ndarray3_complex_set( space_data, i,j,k, ndarray3_get(n, i,j,k) ); + } NDARRAY3_LOOP_OVER_END; + + ndarray3_complex* freq_data = + ndarray3_complex_new(n->sz[0], n->sz[1], n->sz[2]); + + int* dims; + NEW_COUNT( dims, int, PIXEL_NDIMS ); + dims[0] = n->sz[0]; + dims[1] = n->sz[1]; + dims[2] = n->sz[2]; + kiss_fftnd_cfg fft = + kiss_fftnd_alloc( dims, PIXEL_NDIMS, false , NULL, NULL); + /* ^ + * | + * +---- forward FFT + */ + + kiss_fftnd(fft, (kiss_fft_cpx *)(space_data->p), (kiss_fft_cpx *)(freq_data->p) ); + + ndarray3_complex_free(space_data); + free(dims); + free(fft); + + return freq_data; +} + +ndarray3* ndarray3_ifftn_real( ndarray3_complex* n ) { + ndarray3_complex* spatial_data_complex = + ndarray3_complex_new(n->sz[0], n->sz[1], n->sz[2]); + + ndarray3* spatial_data = + ndarray3_new(n->sz[0], n->sz[1], n->sz[2]); + + int* dims; + NEW_COUNT( dims, int, PIXEL_NDIMS ); + dims[0] = n->sz[0]; + dims[1] = n->sz[1]; + dims[2] = n->sz[2]; + + kiss_fftnd_cfg ifft = + kiss_fftnd_alloc( dims, PIXEL_NDIMS, true , NULL, NULL); + /* ^ + * | + * +---- inverse FFT + */ + + kiss_fftnd(ifft, (kiss_fft_cpx *)(n->p), (kiss_fft_cpx *)(spatial_data_complex->p) ); + + size_t nelems = ndarray3_complex_elems( n ); + for( int i = 0; i < nelems; i++ ) { + spatial_data->p[i] /= nelems; /* scaling */ + } + + /* keep real part of `spatial_data_complex` */ + NDARRAY3_LOOP_OVER_START( spatial_data_complex, i,j,k ) { + ndarray3_set( spatial_data, i,j,k, + crealf( ndarray3_complex_get( spatial_data_complex, i,j,k) ) + ); + } NDARRAY3_LOOP_OVER_END; + + ndarray3_complex_free(spatial_data_complex); + free(dims); + free(ifft); + + return spatial_data; +} + + diff --git a/lib/ndarray/ndarray3_fft.h b/lib/ndarray/ndarray3_fft.h index dd81632..349390b 100644 --- a/lib/ndarray/ndarray3_fft.h +++ b/lib/ndarray/ndarray3_fft.h @@ -29,6 +29,8 @@ extern "C" { * * modulo numerical errors. * + * The data must have even dimensions. + * * See also: * Kiss-FFT: * kiss_fftndr, kiss_fftndri @@ -39,6 +41,9 @@ extern "C" { extern ndarray3_complex* ndarray3_fftn_r2c( ndarray3* n ); extern ndarray3* ndarray3_ifftn_c2r( ndarray3_complex* n ); +/* These functions allocate memory, but do not require even dimensions */ +extern ndarray3_complex* ndarray3_fftn_real( ndarray3* n ); +extern ndarray3* ndarray3_ifftn_real( ndarray3_complex* n ); #ifdef __cplusplus }; From 85eea225e32f7c91a87a5a909f80366ffe9561bf Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 1 Apr 2016 09:56:04 -0500 Subject: [PATCH 25/55] Use more general n-d FFT functions when applying Laplacian filter --- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index 825ffd9..b1eabf2 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -59,7 +59,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( /* Fourier transform the input image */ LOG_DEBUG("Computing Fourier transform of input volume"); - ndarray3_complex* v_fft = ndarray3_fftn_r2c(input_volume); + ndarray3_complex* v_fft = ndarray3_fftn_real(input_volume); output->laplacian = ndarray3_new_with_size_from_ndarray3(input_volume); @@ -122,7 +122,7 @@ orion_multiscale_laplacian_output* orion_multiscaleLaplacianFilter( * */ LOG_DEBUG("Inverse Fourier transform for scale %f", laplacian_scale_factor); ndarray3* cur_scale_filt_vol = - ndarray3_ifftn_c2r( cur_scale_laplacian ); + ndarray3_ifftn_real( cur_scale_laplacian ); /* check for maximum response across all scales */ if( !recorded_maximum_scale ) { From 5f672767c67500a8027d816fe784ed08ce910549 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 1 Apr 2016 09:56:53 -0500 Subject: [PATCH 26/55] Fix two memory bugs - One function did not return the correct variable. - Another called a function before the container length was set. --- .../dendrites_main/ExtractFeatures/computeFeatures.c | 2 +- lib/segmentation/orion_features.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c index 7f21747..87c5fac 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/computeFeatures.c @@ -30,7 +30,7 @@ orion_features* orion_computeFeatures( /* adjust the scales by the spacing of the first dimension */ adjusted_scales = array_new_float( number_of_scales ); for( size_t s_idx = 0 ; s_idx < number_of_scales; s_idx++ ) { - array_set_float( adjusted_scales, s_idx, + array_add_float( adjusted_scales, spacing_0dim * array_get_float( param->scales, s_idx ) ); } diff --git a/lib/segmentation/orion_features.c b/lib/segmentation/orion_features.c index 21d498e..e6f52b3 100644 --- a/lib/segmentation/orion_features.c +++ b/lib/segmentation/orion_features.c @@ -8,6 +8,8 @@ orion_features* orion_features_new( size_t instances ) { for( size_t f_idx = 0; f_idx < f->number_of_features; f_idx++ ) { f->features[f_idx] = vector_new_float( instances ); } + + return f; } void orion_features_free( orion_features* f ) { From 4c3a94d14d8983d2647744c0082e5d58b8275d99 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Thu, 7 Apr 2016 15:26:31 -0500 Subject: [PATCH 27/55] Add PD KISS99 RNG code Taken from . --- lib/numeric/kiss99_rng.c | 201 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 lib/numeric/kiss99_rng.c diff --git a/lib/numeric/kiss99_rng.c b/lib/numeric/kiss99_rng.c new file mode 100644 index 0000000..d9d04e0 --- /dev/null +++ b/lib/numeric/kiss99_rng.c @@ -0,0 +1,201 @@ +#include +#define znew (z=36969*(z&65535)+(z>>16)) +#define wnew (w=18000*(w&65535)+(w>>16)) +#define MWC ((znew<<16)+wnew ) +#define SHR3 (jsr^=(jsr<<17), jsr^=(jsr>>13), jsr^=(jsr<<5)) +#define CONG (jcong=69069*jcong+1234567) +#define FIB ((b=a+b),(a=b-a)) +#define KISS ((MWC^CONG)+SHR3) +#define LFIB4 (c++,t[c]=t[c]+t[UC(c+58)]+t[UC(c+119)]+t[UC(c+178)]) +#define SWB (c++,bro=(x2^7700 and is highly + recommended. + Subtract-with-borrow has the same local behaviour + as lagged Fibonacci using +,-,xor---the borrow + merely provides a much longer period. + SWB fails the birthday spacings test, as do all + lagged Fibonacci and other generators that merely + combine two previous values by means of =,- or xor. + Those failures are for a particular case: m=512 + birthdays in a year of n=2^24 days. There are + choices of m and n for which lags >1000 will also + fail the test. A reasonable precaution is to always + combine a 2-lag Fibonacci or SWB generator with + another kind of generator, unless the generator uses + *, for which a very satisfactory sequence of odd + 32-bit integers results. + + + The classical Fibonacci sequence mod 2^32 from FIB + fails several tests. It is not suitable for use by + itself, but is quite suitable for combining with + other generators. + + + The last half of the bits of CONG are too regular, + and it fails tests for which those bits play a + significant role. CONG+FIB will also have too much + regularity in trailing bits, as each does. But keep + in mind that it is a rare application for which + the trailing bits play a significant role. CONG + is one of the most widely used generators of the + last 30 years, as it was the system generator for + VAX and was incorporated in several popular + software packages, all seemingly without complaint. + + + Finally, because many simulations call for uniform + random variables in 0 Date: Thu, 7 Apr 2016 16:19:41 -0500 Subject: [PATCH 28/55] Refactor the KISS99 RNG code Wrap all the seed values inside a struct --- lib/numeric/kiss99_rng.c | 98 +++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 32 deletions(-) diff --git a/lib/numeric/kiss99_rng.c b/lib/numeric/kiss99_rng.c index d9d04e0..96f3a86 100644 --- a/lib/numeric/kiss99_rng.c +++ b/lib/numeric/kiss99_rng.c @@ -1,40 +1,74 @@ #include -#define znew (z=36969*(z&65535)+(z>>16)) -#define wnew (w=18000*(w&65535)+(w>>16)) -#define MWC ((znew<<16)+wnew ) -#define SHR3 (jsr^=(jsr<<17), jsr^=(jsr>>13), jsr^=(jsr<<5)) -#define CONG (jcong=69069*jcong+1234567) -#define FIB ((b=a+b),(a=b-a)) -#define KISS ((MWC^CONG)+SHR3) -#define LFIB4 (c++,t[c]=t[c]+t[UC(c+58)]+t[UC(c+119)]+t[UC(c+178)]) -#define SWB (c++,bro=(x + +/* + * George Marsaglia's KISS99 PRNG. + * + * Taken from Usenet posting from 1999-01-21 .. + * + * Modified to keep state in struct. + */ + +#define kiss99_rng_znew(state) (state->z=36969*(state->z&65535)+(state->z>>16)) +#define kiss99_rng_wnew(state) (state->w=18000*(state->w&65535)+(state->w>>16)) +#define kiss99_rng_MWC(state) ((kiss99_rng_znew(state)<<16)+kiss99_rng_wnew(state) ) +#define kiss99_rng_SHR3(state) (state->jsr^=(state->jsr<<17), state->jsr^=(state->jsr>>13), state->jsr^=(state->jsr<<5)) +#define kiss99_rng_CONG(state) (state->jcong=69069*state->jcong+1234567) +#define kiss99_rng_FIB(state) ((state->b=state->a+state->b),(state->a=state->b-state->a)) +#define kiss99_rng_KISS(state) ((kiss99_rng_MWC(state)^kiss99_rng_CONG(state))+kiss99_rng_SHR3(state)) +#define kiss99_rng_LFIB4(state) (state->c++,state->t[state->c]=state->t[state->c]+state->t[kiss99_rng_UC(state->c+58)]+state->t[kiss99_rng_UC(state->c+119)]+state->t[kiss99_rng_UC(state->c+178)]) +#define kiss99_rng_SWB(state) (state->c++,state->bro=(state->xy),state->t[state->c]=(state->x=state->t[kiss99_rng_UC(state->c+34)])-(state->y=state->t[kiss99_rng_UC(state->c+19)]+state->bro)) +#define kiss99_rng_UNI(state) (kiss99_rng_KISS(state)*2.328306e-10) +#define kiss99_rng_VNI(state) ((long) kiss99_rng_KISS(state))*4.656613e-10 +#define kiss99_rng_UC (unsigned char) /*a cast operation*/ /* Global static variables: */ -static UL z=362436069, w=521288629, jsr=123456789, jcong=380116160; -static UL a=224466889, b=7584631, t[256]; +typedef struct { + /* seed values */ + uint32_t z/*=362436069*/; + uint32_t w/*=521288629*/; + uint32_t jsr/*=123456789*/; + uint32_t jcong/*=380116160*/; + uint32_t a/*=224466889*/; + uint32_t b/*=7584631*/; + /* state table */ + uint32_t t[256]; + + /* non-seed state: init to 0 */ + uint32_t x/*=0*/; + uint32_t y/*=0*/; + + /* temporary storage */ + uint32_t bro; + + /* counter: init to zero */ + unsigned char c/*=0*/; +} kiss99_rng_state; + /* Use random seeds to reset z,w,jsr,jcong,a,b, and the table -t[256]*/ -static UL x=0,y=0,bro; static unsigned char c=0; +*/ /* Example procedure to set the table, using KISS: */ -void settable(UL i1,UL i2,UL i3,UL i4,UL i5, UL i6) -{ int i; z=i1;w=i2,jsr=i3; jcong=i4; a=i5; b=i6; -for(i=0;i<256;i=i+1) t[i]=KISS; +void kiss99_rng_set_table(kiss99_rng_state* state, uint32_t i1,uint32_t i2,uint32_t i3,uint32_t i4,uint32_t i5,uint32_t i6) { + int i; + + /* init state */ + state->x = 0; state->y = 0; state->c = 0; + + state->z=i1;state->w=i2,state->jsr=i3; state->jcong=i4; state->a=i5; state->b=i6; + for(i=0;i<256;i=i+1) state->t[i]=kiss99_rng_KISS(state); } -/* This is a test main program. It should compile and print 7 -0's. */ -int main(void){ -int i; UL k; -settable(12345,65435,34221,12345,9983651,95746118); -for(i=1;i<1000001;i++){k=LFIB4;} printf("%u\n", k-1064612766U); -for(i=1;i<1000001;i++){k=SWB ;} printf("%u\n", k- 627749721U); -for(i=1;i<1000001;i++){k=KISS ;} printf("%u\n", k-1372460312U); -for(i=1;i<1000001;i++){k=CONG ;} printf("%u\n", k-1529210297U); -for(i=1;i<1000001;i++){k=SHR3 ;} printf("%u\n", k-2642725982U); -for(i=1;i<1000001;i++){k=MWC ;} printf("%u\n", k- 904977562U); -for(i=1;i<1000001;i++){k=FIB ;} printf("%u\n", k-3519793928U); +/* This is a test main program. It should compile and print 7 0's. */ +int main(void) { + int i; uint32_t k; + kiss99_rng_state s; + kiss99_rng_state* state = &s; + kiss99_rng_set_table(state, 12345,65435,34221,12345,9983651,95746118); + for(i=1;i<1000001;i++){k=kiss99_rng_LFIB4(state);} printf("%u\n", k-1064612766U); + for(i=1;i<1000001;i++){k=kiss99_rng_SWB(state) ;} printf("%u\n", k- 627749721U); + for(i=1;i<1000001;i++){k=kiss99_rng_KISS(state) ;} printf("%u\n", k-1372460312U); + for(i=1;i<1000001;i++){k=kiss99_rng_CONG(state) ;} printf("%u\n", k-1529210297U); + for(i=1;i<1000001;i++){k=kiss99_rng_SHR3(state) ;} printf("%u\n", k-2642725982U); + for(i=1;i<1000001;i++){k=kiss99_rng_MWC(state) ;} printf("%u\n", k- 904977562U); + for(i=1;i<1000001;i++){k=kiss99_rng_FIB(state) ;} printf("%u\n", k-3519793928U); } /*----------------------------------------------------- Write your own calling program and try one or more of From 1d8a42052fd698fa9bcb85580852e1b5f73f337d Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sun, 10 Apr 2016 22:20:26 -0500 Subject: [PATCH 29/55] Organise the KISS99 RNG headers and tests --- lib/numeric/kiss99_rng.c | 60 ++++++----------------------------- lib/numeric/kiss99_rng.h | 64 ++++++++++++++++++++++++++++++++++++++ lib/t/numeric/kiss99_rng.c | 24 ++++++++++++++ 3 files changed, 97 insertions(+), 51 deletions(-) create mode 100644 lib/numeric/kiss99_rng.h create mode 100644 lib/t/numeric/kiss99_rng.c diff --git a/lib/numeric/kiss99_rng.c b/lib/numeric/kiss99_rng.c index 96f3a86..873d766 100644 --- a/lib/numeric/kiss99_rng.c +++ b/lib/numeric/kiss99_rng.c @@ -1,49 +1,13 @@ -#include -#include +#include "numeric/kiss99_rng.h" /* * George Marsaglia's KISS99 PRNG. * - * Taken from Usenet posting from 1999-01-21 .. + * Taken from Usenet posting from 1999-01-21 . * * Modified to keep state in struct. */ -#define kiss99_rng_znew(state) (state->z=36969*(state->z&65535)+(state->z>>16)) -#define kiss99_rng_wnew(state) (state->w=18000*(state->w&65535)+(state->w>>16)) -#define kiss99_rng_MWC(state) ((kiss99_rng_znew(state)<<16)+kiss99_rng_wnew(state) ) -#define kiss99_rng_SHR3(state) (state->jsr^=(state->jsr<<17), state->jsr^=(state->jsr>>13), state->jsr^=(state->jsr<<5)) -#define kiss99_rng_CONG(state) (state->jcong=69069*state->jcong+1234567) -#define kiss99_rng_FIB(state) ((state->b=state->a+state->b),(state->a=state->b-state->a)) -#define kiss99_rng_KISS(state) ((kiss99_rng_MWC(state)^kiss99_rng_CONG(state))+kiss99_rng_SHR3(state)) -#define kiss99_rng_LFIB4(state) (state->c++,state->t[state->c]=state->t[state->c]+state->t[kiss99_rng_UC(state->c+58)]+state->t[kiss99_rng_UC(state->c+119)]+state->t[kiss99_rng_UC(state->c+178)]) -#define kiss99_rng_SWB(state) (state->c++,state->bro=(state->xy),state->t[state->c]=(state->x=state->t[kiss99_rng_UC(state->c+34)])-(state->y=state->t[kiss99_rng_UC(state->c+19)]+state->bro)) -#define kiss99_rng_UNI(state) (kiss99_rng_KISS(state)*2.328306e-10) -#define kiss99_rng_VNI(state) ((long) kiss99_rng_KISS(state))*4.656613e-10 -#define kiss99_rng_UC (unsigned char) /*a cast operation*/ -/* Global static variables: */ -typedef struct { - /* seed values */ - uint32_t z/*=362436069*/; - uint32_t w/*=521288629*/; - uint32_t jsr/*=123456789*/; - uint32_t jcong/*=380116160*/; - uint32_t a/*=224466889*/; - uint32_t b/*=7584631*/; - /* state table */ - uint32_t t[256]; - - /* non-seed state: init to 0 */ - uint32_t x/*=0*/; - uint32_t y/*=0*/; - - /* temporary storage */ - uint32_t bro; - - /* counter: init to zero */ - unsigned char c/*=0*/; -} kiss99_rng_state; - /* Use random seeds to reset z,w,jsr,jcong,a,b, and the table */ /* Example procedure to set the table, using KISS: */ @@ -56,20 +20,14 @@ void kiss99_rng_set_table(kiss99_rng_state* state, uint32_t i1,uint32_t i2,uint3 state->z=i1;state->w=i2,state->jsr=i3; state->jcong=i4; state->a=i5; state->b=i6; for(i=0;i<256;i=i+1) state->t[i]=kiss99_rng_KISS(state); } -/* This is a test main program. It should compile and print 7 0's. */ -int main(void) { - int i; uint32_t k; - kiss99_rng_state s; - kiss99_rng_state* state = &s; - kiss99_rng_set_table(state, 12345,65435,34221,12345,9983651,95746118); - for(i=1;i<1000001;i++){k=kiss99_rng_LFIB4(state);} printf("%u\n", k-1064612766U); - for(i=1;i<1000001;i++){k=kiss99_rng_SWB(state) ;} printf("%u\n", k- 627749721U); - for(i=1;i<1000001;i++){k=kiss99_rng_KISS(state) ;} printf("%u\n", k-1372460312U); - for(i=1;i<1000001;i++){k=kiss99_rng_CONG(state) ;} printf("%u\n", k-1529210297U); - for(i=1;i<1000001;i++){k=kiss99_rng_SHR3(state) ;} printf("%u\n", k-2642725982U); - for(i=1;i<1000001;i++){k=kiss99_rng_MWC(state) ;} printf("%u\n", k- 904977562U); - for(i=1;i<1000001;i++){k=kiss99_rng_FIB(state) ;} printf("%u\n", k-3519793928U); + +kiss99_rng_state* kiss99_rng_state_new() { + kiss99_rng_state* state; + NEW(state, kiss99_rng_state ); + + return state; } + /*----------------------------------------------------- Write your own calling program and try one or more of the above, singly or in combination, when you run a diff --git a/lib/numeric/kiss99_rng.h b/lib/numeric/kiss99_rng.h new file mode 100644 index 0000000..be700f1 --- /dev/null +++ b/lib/numeric/kiss99_rng.h @@ -0,0 +1,64 @@ +#ifndef NUMERIC_KISS99_RNG +#define NUMERIC_KISS99_RNG 1 + +/* system headers */ +#include +#include +#include + +/* local headers */ +#include "util/util.h" + +/* structs, enums */ +#define KISS99_RNG_RANDOM_MAX UINT32_MAX + +typedef struct { + /* seed values */ + uint32_t z/*=362436069*/; + uint32_t w/*=521288629*/; + uint32_t jsr/*=123456789*/; + uint32_t jcong/*=380116160*/; + uint32_t a/*=224466889*/; + uint32_t b/*=7584631*/; + /* state table */ + uint32_t t[256]; + + /* non-seed state: init to 0 */ + uint32_t x/*=0*/; + uint32_t y/*=0*/; + + /* temporary storage */ + uint32_t bro; + + /* counter: init to zero */ + unsigned char c/*=0*/; +} kiss99_rng_state; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Macros */ +#define kiss99_rng_znew(state) (state->z=36969*(state->z&65535)+(state->z>>16)) +#define kiss99_rng_wnew(state) (state->w=18000*(state->w&65535)+(state->w>>16)) +#define kiss99_rng_MWC(state) ((kiss99_rng_znew(state)<<16)+kiss99_rng_wnew(state) ) +#define kiss99_rng_SHR3(state) (state->jsr^=(state->jsr<<17), state->jsr^=(state->jsr>>13), state->jsr^=(state->jsr<<5)) +#define kiss99_rng_CONG(state) (state->jcong=69069*state->jcong+1234567) +#define kiss99_rng_FIB(state) ((state->b=state->a+state->b),(state->a=state->b-state->a)) +#define kiss99_rng_KISS(state) ((kiss99_rng_MWC(state)^kiss99_rng_CONG(state))+kiss99_rng_SHR3(state)) +#define kiss99_rng_LFIB4(state) (state->c++,state->t[state->c]=state->t[state->c]+state->t[kiss99_rng_UC(state->c+58)]+state->t[kiss99_rng_UC(state->c+119)]+state->t[kiss99_rng_UC(state->c+178)]) +#define kiss99_rng_SWB(state) (state->c++,state->bro=(state->xy),state->t[state->c]=(state->x=state->t[kiss99_rng_UC(state->c+34)])-(state->y=state->t[kiss99_rng_UC(state->c+19)]+state->bro)) +#define kiss99_rng_UNI(state) (kiss99_rng_KISS(state)*2.328306e-10) +#define kiss99_rng_VNI(state) ((int32_t) kiss99_rng_KISS(state))*4.656613e-10 +#define kiss99_rng_UC (unsigned char) /*a cast operation*/ + +/* Function prototypes */ +extern void kiss99_rng_set_table(kiss99_rng_state* state, uint32_t i1,uint32_t i2,uint32_t i3,uint32_t i4,uint32_t i5,uint32_t i6); +extern kiss99_rng_state* kiss99_rng_state_new(); + + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* NUMERIC_KISS99_RNG */ diff --git a/lib/t/numeric/kiss99_rng.c b/lib/t/numeric/kiss99_rng.c new file mode 100644 index 0000000..801260e --- /dev/null +++ b/lib/t/numeric/kiss99_rng.c @@ -0,0 +1,24 @@ +#include +#include + +#include "numeric/kiss99_rng.h" + +/* This is a test main program. It should compile and print 7 0's. */ +int main(int argc, char** argv) { + int i; uint32_t k; + + kiss99_rng_state* state = kiss99_rng_state_new(); + kiss99_rng_set_table(state, 12345,65435,34221,12345,9983651,95746118); + + plan(7); + + for(i=1;i<1000001;i++){k=kiss99_rng_LFIB4(state);} is_int(0, k-1064612766U, "LFIB4"); + for(i=1;i<1000001;i++){k=kiss99_rng_SWB(state) ;} is_int(0, k- 627749721U, "SWB"); + for(i=1;i<1000001;i++){k=kiss99_rng_KISS(state) ;} is_int(0, k-1372460312U, "KISS"); + for(i=1;i<1000001;i++){k=kiss99_rng_CONG(state) ;} is_int(0, k-1529210297U, "CONG"); + for(i=1;i<1000001;i++){k=kiss99_rng_SHR3(state) ;} is_int(0, k-2642725982U, "SHR3"); + for(i=1;i<1000001;i++){k=kiss99_rng_MWC(state) ;} is_int(0, k- 904977562U, "MWC"); + for(i=1;i<1000001;i++){k=kiss99_rng_FIB(state) ;} is_int(0, k-3519793928U, "FIB"); + + return EXIT_SUCCESS; +} From 811515f9a69f9d19f5de6dd9b0f077f8a4c36f1d Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 11 Apr 2016 13:14:40 -0500 Subject: [PATCH 30/55] Remove unused variable --- lib/io/path/path.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/io/path/path.c b/lib/io/path/path.c index 366d254..a82ea8a 100644 --- a/lib/io/path/path.c +++ b/lib/io/path/path.c @@ -21,7 +21,6 @@ orion_filepath* orion_filepath_new_from_string(const char* fp_string) { char* fp_string_norm; size_t fp_string_norm_len; safe_malloc_and_strcpy(&fp_string_norm, fp_string); - size_t fp_string_len = strlen( fp_string ); orion_filepath* fp = _orion_filepath_init(); From 953ecddf349aca02cfcdc5a88d0018bc642bf417 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 11 Apr 2016 13:15:37 -0500 Subject: [PATCH 31/55] Add structure member to segmentation parameters for RNG state --- .../01_Segmentation/dendrites_main/ORION3_Dendrites.c | 2 ++ lib/param/segmentation.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c index 6e2f813..9a32faa 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c @@ -20,6 +20,8 @@ void orion_ORION3_Dendrites(orion_segmentation_param* param, ndarray3* vol) { /* set the default parameters for the algorithm if none are set */ orion_settingDefaultParameters( param ); + TODO(intialise param->rng_state); + /*DEBUG*/orion_segmentation_param_dump( param ); /* diff --git a/lib/param/segmentation.h b/lib/param/segmentation.h index b65b89f..fc8f5c3 100644 --- a/lib/param/segmentation.h +++ b/lib/param/segmentation.h @@ -6,13 +6,15 @@ #include "container/array.h" #include "util/float.h" - +#include "numeric/random.h" typedef struct { array_float* scales; /* sigma */ bool multiscale; size_t number_of_stacks; /* length of volume_names */ + orion_rand_state_t* rng_state; + #define ATTR( NAME, TYPE ) \ bool has_ ## NAME; \ TYPE NAME; From f077520c525a8f3c3b82c41cdbaa3bdd04da4a8f Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sat, 16 Apr 2016 11:23:02 -0500 Subject: [PATCH 32/55] Add function to free RNG state --- lib/numeric/kiss99_rng.c | 4 ++++ lib/numeric/kiss99_rng.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/numeric/kiss99_rng.c b/lib/numeric/kiss99_rng.c index 873d766..3c42942 100644 --- a/lib/numeric/kiss99_rng.c +++ b/lib/numeric/kiss99_rng.c @@ -28,6 +28,10 @@ kiss99_rng_state* kiss99_rng_state_new() { return state; } +void kiss99_rng_state_free(kiss99_rng_state* state) { + free(state); +} + /*----------------------------------------------------- Write your own calling program and try one or more of the above, singly or in combination, when you run a diff --git a/lib/numeric/kiss99_rng.h b/lib/numeric/kiss99_rng.h index be700f1..052606b 100644 --- a/lib/numeric/kiss99_rng.h +++ b/lib/numeric/kiss99_rng.h @@ -55,7 +55,7 @@ extern "C" { /* Function prototypes */ extern void kiss99_rng_set_table(kiss99_rng_state* state, uint32_t i1,uint32_t i2,uint32_t i3,uint32_t i4,uint32_t i5,uint32_t i6); extern kiss99_rng_state* kiss99_rng_state_new(); - +extern void kiss99_rng_state_free(kiss99_rng_state* state); #ifdef __cplusplus }; From 0ca88ca39dba0a053bb9201bf2ae2a93edea41c0 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sat, 16 Apr 2016 12:07:57 -0500 Subject: [PATCH 33/55] initialise the RNG when starting the segmentation --- .../dendrites_main/ORION3_Dendrites.c | 9 +++- lib/numeric/random.c | 54 +++++++++++++++++++ lib/numeric/random.h | 29 ++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 lib/numeric/random.c create mode 100644 lib/numeric/random.h diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c index 9a32faa..c12b6dc 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c @@ -5,9 +5,14 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/getFeatures.h" +#include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h" #include "kitchen-sink/01_Segmentation/dendrites_main/settingDefaultParameters.h" +#include "segmentation/orion_discriminant.h" +#include "numeric/random.h" + /* * Segmentation process which computes the distribution of the eigenvalues of * the Hessian matrix and assigns a cost function to eliminate background @@ -20,7 +25,9 @@ void orion_ORION3_Dendrites(orion_segmentation_param* param, ndarray3* vol) { /* set the default parameters for the algorithm if none are set */ orion_settingDefaultParameters( param ); - TODO(intialise param->rng_state); + /* intialise PRNG */ + param->rng_state = kiss99_rng_state_new(); + kiss99_rng_init(param->rng_state); /*DEBUG*/orion_segmentation_param_dump( param ); diff --git a/lib/numeric/random.c b/lib/numeric/random.c new file mode 100644 index 0000000..41ccb21 --- /dev/null +++ b/lib/numeric/random.c @@ -0,0 +1,54 @@ +#include "config/config.h" + +#include "numeric/random.h" + +#if OS_UNIX + #include + #include + #include + #include +#endif + +float64 orion_rand_uniform_dist(orion_rand_state_t* state) { + return ( (float64) kiss99_rng_KISS( state ) ) / KISS99_RNG_RANDOM_MAX; +} + +uint32_t _orion_rand_seeds() { + uint32_t r; + +#if OS_UNIX + /* read from /dev/urandom */ + int fn; + fn = open("/dev/urandom", O_RDONLY); + if (fn == - 1) + exit( -1 ); + /* Failed ! */ + if ( read(fn, &r, 4) != 4) + exit( - 1) ; + /* Failed ! */ + close(fn); +#elif defined(_CRT_RAND_S) + rand_s( &r ); +#else + die("%s", "Random seeding not implemented on this platform"); +#endif + + return r; +} + +/* Based on the report "Good Practice in (Pseudo)Random Number Generation for + * Bioinformatics Applications" by David Jones. + * + */ +/* Initialise KISS generator using /dev/urandom */ +void kiss99_rng_init(kiss99_rng_state* state) { + state->x = _orion_rand_seeds(); + while (!( state->y = _orion_rand_seeds())); /* y must not be zero ! */ + state->z = _orion_rand_seeds() ; + /* We don’t really need to set c as well but + let's anyway + ... */ + /* NOTE: offset c by 1 to avoid z=c=0 */ + state->c = _orion_rand_seeds() % 698769068 + 1; /* Should be less than 698769069 */ +} + diff --git a/lib/numeric/random.h b/lib/numeric/random.h new file mode 100644 index 0000000..bac597f --- /dev/null +++ b/lib/numeric/random.h @@ -0,0 +1,29 @@ +#ifndef ORION_NUMERIC_RANDOM_H +#define ORION_NUMERIC_RANDOM_H 1 + +/* system headers */ +#include +#include +#include + +/* local headers */ +#include "util/util.h" +#include "numeric/kiss99_rng.h" + +/* structs, enums */ +typedef kiss99_rng_state orion_rand_state_t; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +float64 orion_rand_uniform_dist(orion_rand_state_t* state); +extern void kiss99_rng_init(kiss99_rng_state* state); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_NUMERIC_RANDOM_H */ From 39c203d7eb9ed344e6fcfb632f12441bb4ae2412 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sat, 16 Apr 2016 12:10:07 -0500 Subject: [PATCH 34/55] Project specific Vim settings with autocmd --- session.vim | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/session.vim b/session.vim index 2b0b805..d4a5cf8 100644 --- a/session.vim +++ b/session.vim @@ -1,4 +1,3 @@ -set path+=lib let g:syntastic_c_include_dirs = [ \ 'lib', \ 'external/c-tap-harness/c-tap-harness/tests', @@ -38,4 +37,18 @@ function! ORION_GotoCorresponding() endif endfunction -nmap ,gg :call ORION_GotoCorresponding() +augroup ORION_project + au! + exe "autocmd BufRead ". expand(":p:h")."/* call ORION_project_settings()" +augroup END + +function! ORION_project_settings() +setl path+=lib + +compiler gcc +let &l:makeprg='export CFLAGS="$CFLAGS -fPIC -Wall"; make PROD=1 BUILD_DEBUG=1 BUILD_ENABLE_ASAN=0 -j4' + +nmap :make +nmap ,gg :call ORION_GotoCorresponding() + +endfunction From 821a7d9b37372838625d00605fa9a85565ed52d8 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sat, 16 Apr 2016 12:13:54 -0500 Subject: [PATCH 35/55] Add algorithm for sampling without replacement --- lib/numeric/sample.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ lib/numeric/sample.h | 28 ++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 lib/numeric/sample.c create mode 100644 lib/numeric/sample.h diff --git a/lib/numeric/sample.c b/lib/numeric/sample.c new file mode 100644 index 0000000..2de7c8f --- /dev/null +++ b/lib/numeric/sample.c @@ -0,0 +1,63 @@ +#include "numeric/sample.h" + +#include + +/* Returns an array_int of length `sample_size` + * where each element is + * + * - in the range 0 to `population_size` - 1 and + * - sampled randomly without replacement. + * + * See Algorithm 3.4.2S of Knuth's book Seminumeric Algorithms: "Selection + * Sampling Technique". + */ +array_int* array_random_sample_int( + orion_rand_state_t* rng_state, + uint32_t sample_size, + uint32_t population_size) { + /* we can not sample more things than actually exist */ + assert( sample_size <= population_size ); + + array_int* samples = array_new_int( sample_size ); + + /* To select $ n $ records at random from a set of $ N $, where + * $ 0 < n ≤ N $ . */ + uint32_t n = sample_size; + uint32_t N = population_size; + + /* S1. [Initialise.] + ********************* + * - m: number of records selected so far + * - t: total number of input records we have dealt with */ + uint32_t m = 0; + uint32_t t = 0; + + while( m < n ) { + /* S2. [Generate $ U $.] + ************************* + * Generate a random number $ U $, from a uniform distribution + * $ uniform(0, 1) $. */ + float32 U = orion_rand_uniform_dist(rng_state); + /* S3. [Test.] + *************** + * If $ (N - t) U ≥ n - m $, go to step S5. */ + if( (N - t) * U >= n - m ) { + /* S5. [Skip.] + *************** + * Skip the next record (do not include it in the + * sample), increase t by 1, and go to step S2. */ + t++; + continue; + } else { + /* S4. [Select.] + ***************** + * Select the next record for the sample, and increase + * m and t by 1. If m < n, go to step S2; otherwise + * the sample is complete and the algorithm terminates. */ + array_add_int( samples, t ); /* set m-th element to t */ + m++; + t++; + } + + } +} diff --git a/lib/numeric/sample.h b/lib/numeric/sample.h new file mode 100644 index 0000000..51ee399 --- /dev/null +++ b/lib/numeric/sample.h @@ -0,0 +1,28 @@ +#ifndef NUMERIC_SAMPLE_H +#define NUMERIC_SAMPLE_H 1 + +/* system headers */ +#include +#include +#include + +/* local headers */ +#include "container/array.h" +#include "numeric/random.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +array_int* array_random_sample_int( + orion_rand_state_t* rng_state, + uint32_t sample_size, + uint32_t population_size); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* NUMERIC_SAMPLE_H */ From 11469a860948cc99ed90600806fc80c92576c8d7 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sat, 16 Apr 2016 12:14:29 -0500 Subject: [PATCH 36/55] Add test for uniform RNG (mean and variance) --- lib/t/numeric/random.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/t/numeric/random.c diff --git a/lib/t/numeric/random.c b/lib/t/numeric/random.c new file mode 100644 index 0000000..5c39dbf --- /dev/null +++ b/lib/t/numeric/random.c @@ -0,0 +1,42 @@ +#include +#include + +#include +#include +#include +#include + +#include "numeric/random.h" +#include "util/util.h" + +int main(int argc, char** argv) { + plan(2); + + + kiss99_rng_state* state = kiss99_rng_state_new(); + kiss99_rng_init( state ); + + const size_t number_of_samples = 1E7; + /* theoretical mean and variance of + * uniform distribution U(0,1) */ + const float64 uniform_dist_mean = 0.5; + const float64 uniform_dist_var = 1.0/12.0; + + float64 sum = 0.0; + float64 sum_of_sq = 0.0; + for( int i = 0; i < number_of_samples; i++ ) { + float64 sample = orion_rand_uniform_dist( state ); + + sum += sample; + sum_of_sq += SQUARED( sample - uniform_dist_mean ); + } + + float64 mean = sum / number_of_samples; + float64 var = sum_of_sq / number_of_samples; + + /* 2 tests */ + is_double( uniform_dist_mean, mean, 1E-3, "Mean of U(0,1) = 1/2" ); + is_double( uniform_dist_var, var, 1E-3, "Variance of U(0,1) = 1/12" ); + + return EXIT_SUCCESS; +} From 3f4f73150b217bcef0e82eca9b61f82e046b059f Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Sun, 17 Apr 2016 14:53:15 -0500 Subject: [PATCH 37/55] Return the sample array --- lib/numeric/sample.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/numeric/sample.c b/lib/numeric/sample.c index 2de7c8f..ee2e6ad 100644 --- a/lib/numeric/sample.c +++ b/lib/numeric/sample.c @@ -60,4 +60,6 @@ array_int* array_random_sample_int( } } + + return samples; } From e4087babb8e5e1251047f70db8de01efea7de8d7 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 13:42:40 -0500 Subject: [PATCH 38/55] Update the discriminant function code --- .../compute2D_DiscrimantFunction.c | 152 ++++++++++++++++++ .../compute2D_DiscrimantFunction.h | 33 ++++ .../removeIsolatedResponses.c | 110 +++++++++++++ .../removeIsolatedResponses.h | 34 ++++ .../dendrites_main/ORION3_Dendrites.c | 47 +++++- lib/segmentation/orion_discriminant.h | 42 +++++ 6 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h create mode 100644 lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h create mode 100644 lib/segmentation/orion_discriminant.h diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c index b516beb..d7855a6 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c @@ -1,4 +1,156 @@ +#include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h" + +#include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h" + /* TODO * * Refactor: compute2D_DiscrimantFunction */ + +#define MAX_NUMBER_OF_HISTOGRAM_SAMPLES 1E6 + +#include "numeric/sample.h" +#include +#include +#include + +/* Private prototypes */ +void orion_hist3( + orion_segmentation_param* param, + orion_features* features, + array_int* indices, + orion_discriminant_function* discrim + ); + +void orion_normaliseHistogram( + orion_segmentation_param* param, + orion_discriminant_function* discrim + ); + +void orion_compute2D_DiscrimantFunction( + orion_segmentation_param* param, + orion_features* features, + array_int* instance_indices, + orion_discriminant_function* discrim + ) { + + size_t n_samples = array_length_int( instance_indices ); + array_int* sample_instance_indices; + array_int* non_isolated_instance_indices; + + if( n_samples > MAX_NUMBER_OF_HISTOGRAM_SAMPLES ) { + /* only process at most MAX_NUMBER_OF_HISTOGRAM_SAMPLES features */ + sample_instance_indices = + array_random_sample_int(param->rng_state, n_samples, MAX_NUMBER_OF_HISTOGRAM_SAMPLES); + n_samples = MAX_NUMBER_OF_HISTOGRAM_SAMPLES; + } else { + /* we take it all */ + sample_instance_indices = + array_new_int(n_samples); + for( size_t sample_idx = 0; sample_idx < n_samples; sample_idx++ ) { + array_add_int( sample_instance_indices, sample_idx ); + } + } + + /* remove noisy points and select instances outside a threshold */ + orion_removeIsolatedResponses( + param, + features, + discrim, + sample_instance_indices, + &non_isolated_instance_indices ); + + n_samples = array_length_int( non_isolated_instance_indices ); + + /* set the binning parameters */ + for( size_t feat_idx = 0; feat_idx < features->number_of_features; feat_idx++ ) { + discrim->min_value[feat_idx] = FLT_MAX; + discrim->max_value[feat_idx] = -FLT_MAX; + } + for( size_t sample_idx = 0; sample_idx < n_samples; sample_idx++ ) { + size_t actual_sample_idx = + array_get_int(non_isolated_instance_indices, sample_idx); + for( size_t feat_idx = 0; feat_idx < features->number_of_features; feat_idx++ ) { + pixel_type cur_feature = vector_get_float( + features->features[feat_idx], + actual_sample_idx); + if( cur_feature < discrim->min_value[feat_idx] ) { + discrim->min_value[feat_idx] = cur_feature; + } + if( cur_feature > discrim->max_value[feat_idx] ) { + discrim->max_value[feat_idx] = cur_feature; + } + } + } + for( size_t feat_idx = 0; feat_idx < features->number_of_features; feat_idx++ ) { + discrim->step_size[feat_idx] = + ( discrim->max_value[feat_idx] - discrim->min_value[feat_idx] ) + / ( param->bins ); + /*[>DEBUG<]LOG_DEBUG( "feat: %d ; min: %f ; max: %f ; bins: %u ; step_size: %e", + feat_idx, + discrim->min_value[feat_idx], + discrim->max_value[feat_idx], + param->bins, + discrim->step_size[feat_idx] + );*/ + } + + /* compute the 2D histogram for edges */ + orion_hist3(param, features, non_isolated_instance_indices, discrim); + + /* normalise the histogram in order to compute the cost function */ + orion_normaliseHistogram(param, discrim); + + array_free_int( non_isolated_instance_indices ); + array_free_int( sample_instance_indices ); +} + +/* Creates a 2D histogram + * + * TODO + * + * See also: MATLAB's hist3 function + */ +void orion_hist3( + orion_segmentation_param* param, + orion_features* features, + array_int* indices, + orion_discriminant_function* discrim + ) { + /* we only support 2 features because this is a 2D histogram */ + assert( 2 == features->number_of_features ); + size_t indices_sz = array_length_int(indices); + size_t* feat_bin_idx; + NEW_COUNT( feat_bin_idx, size_t, features->number_of_features ); + + /* NOTE: histogram is allocated here: if the size of the bins change + * for each dimension, then this will need to change */ + discrim->histogram = ndarray3_new( param->bins, param->bins, 1); + NDARRAY3_LOOP_OVER_START( discrim->histogram, i,j,k ) { + ndarray3_set( discrim->histogram, i,j,k, 0.0 ); + } NDARRAY3_LOOP_OVER_END; + + for( int indices_idx = 0; indices_idx < indices_sz; indices_idx++ ) { + size_t feat_instance_idx = array_get_int( indices, indices_idx ); + for( size_t feat_idx = 0; feat_idx < features->number_of_features; feat_idx++ ) { + pixel_type cur_feature = vector_get_float( + features->features[feat_idx], + feat_instance_idx); + feat_bin_idx[feat_idx] = floorf( + ( cur_feature - discrim->min_value[feat_idx] ) + / ( discrim->step_size[feat_idx] ) + ); + } + /* increment by 1 */ + ndarray3_set( discrim->histogram, feat_bin_idx[0], feat_bin_idx[1], 0, + 1.0 + ndarray3_get(discrim->histogram, feat_bin_idx[0], feat_bin_idx[1], 0) + ); + } +} + +void orion_normaliseHistogram( + orion_segmentation_param* param, + orion_discriminant_function* discrim + ) { + WARN_UNIMPLEMENTED; +} diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h new file mode 100644 index 0000000..e23373d --- /dev/null +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.h @@ -0,0 +1,33 @@ +#ifndef ORION_COMPUTE2D_DISCRIM_H +#define ORION_COMPUTE2D_DISCRIM_H 1 + +/* system headers */ +#include +#include + +/* local headers */ +#include "segmentation/orion_discriminant.h" +#include "container/array.h" +#include "segmentation/orion_features.h" +#include "param/segmentation.h" + +/* structs, enums */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +void orion_compute2D_DiscrimantFunction( + orion_segmentation_param* param, + orion_features* features, + array_int* instance_indices, + orion_discriminant_function* discrim + ); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_COMPUTE2D_DISCRIM_H */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c index 8f7706c..5edf1dc 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c @@ -1,4 +1,114 @@ +#include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h" /* TODO * * Refactor: removeIsolatedResponses */ + +#include "numeric/sample.h" +#include +#include "simple-log/simplelog.h" + +/* orion_removeIsolatedResponses + * + * Identify the indices of features that are non-isolated so that only features + * that are representative of a cluster are examined as part of the histogram. + */ +void orion_removeIsolatedResponses( + orion_segmentation_param* param, + orion_features* features, + orion_discriminant_function* discrim, + array_int* sample_instance_indices, + array_int** non_isolated_instance_indices + ) { + + pixel_type* min_bound; + pixel_type* max_bound; + + NEW_COUNT( min_bound, pixel_type, features->number_of_features ); + NEW_COUNT( max_bound, pixel_type, features->number_of_features ); + + size_t sample_instance_indices_size = array_length_int( sample_instance_indices ); + + uint32_t iterations = 200; + size_t samples_in_each_round = 200; + if( samples_in_each_round > sample_instance_indices_size ) { + samples_in_each_round = sample_instance_indices_size; + } + + *non_isolated_instance_indices = array_new_int( sample_instance_indices_size ); + + + for( int feat_idx = 0; feat_idx < features->number_of_features; feat_idx++ ) { + /* init bounds to zero */ + min_bound[feat_idx] = 0; + max_bound[feat_idx] = 0; + + /* sample each feature independently */ + for( uint32_t sample_round = 0; sample_round < iterations ; sample_round++ ) { + array_int* sample = array_random_sample_int( + param->rng_state, + samples_in_each_round, + sample_instance_indices_size ); + + pixel_type min_for_round = FLT_MAX, max_for_round = -FLT_MAX; + for( int sample_idx = 0; sample_idx < samples_in_each_round; sample_idx++ ) { + size_t sample_instance_idx = array_get_int( sample, sample_idx ); + size_t instance_idx = array_get_int( sample_instance_indices, sample_instance_idx ); + + pixel_type cur_feature = vector_get_float( + features->features[feat_idx], + instance_idx + ); + + if( min_for_round > cur_feature ) { min_for_round = cur_feature; } + if( max_for_round < cur_feature ) { max_for_round = cur_feature; } + } + + /* divide by iterations because we want the average of all the + * rounds */ + min_bound[feat_idx] += min_for_round / iterations; + max_bound[feat_idx] += max_for_round / iterations; + + array_free_int( sample ); + /*[>DEBUG<]LOG_DEBUG( "feat: %d ; min: %e ; max: %e", + feat_idx, + min_bound[feat_idx], + max_bound[feat_idx]);*/ + } + + pixel_type interval_size = max_bound[feat_idx] - min_bound[feat_idx]; + pixel_type mean = (max_bound[feat_idx] - min_bound[feat_idx]) / 2.0; + + /* re-assign to min and max bounds by creating region that is + * three times the interval size */ + min_bound[feat_idx] = mean - 2 * interval_size; + max_bound[feat_idx] = mean + 2 * interval_size; + /*[>DEBUG<]LOG_DEBUG( "feat: %d ; min: %e ; max: %e", + feat_idx, + min_bound[feat_idx], + max_bound[feat_idx]);*/ + } + + /* only keep values that are within both bounds */ + for( int i = 0; i < sample_instance_indices_size; i++ ) { + size_t current_sample_idx = array_get_int( sample_instance_indices, i ); + /* check if the feature is in the bounds for all features */ + bool in_bounds = true; + for( int feat_idx = 0; in_bounds && feat_idx < features->number_of_features; feat_idx++ ) { + pixel_type cur_feature = vector_get_float( + features->features[feat_idx], + current_sample_idx + ); + /*[>DEBUG<]LOG_DEBUG("cur feature: %f", cur_feature);*/ + in_bounds &= cur_feature >= min_bound[feat_idx] + && cur_feature <= max_bound[feat_idx]; + } + if( in_bounds ) { + array_add_int( *non_isolated_instance_indices, current_sample_idx ); + } + } + + + free( min_bound ); + free( max_bound ); +} diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h new file mode 100644 index 0000000..57be871 --- /dev/null +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h @@ -0,0 +1,34 @@ +#ifndef ORION_REMOVE_ISOLATED_REZ_H +#define ORION_REMOVE_ISOLATED_REZ_H 1 + +/* system headers */ +#include +#include + +/* local headers */ +#include "segmentation/orion_discriminant.h" +#include "container/array.h" +#include "segmentation/orion_features.h" +#include "param/segmentation.h" + +/* structs, enums */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +void orion_removeIsolatedResponses( + orion_segmentation_param* param, + orion_features* features, + orion_discriminant_function* discrim, + array_int* sample_instance_indices, + array_int** non_isolated_instance_indices + ); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_REMOVE_ISOLATED_REZ_H */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c index c12b6dc..4f8098e 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ORION3_Dendrites.c @@ -40,7 +40,52 @@ void orion_ORION3_Dendrites(orion_segmentation_param* param, ndarray3* vol) { * reading background samples using the Laplacian with the ISOTROPIC LOW * PASS FILTER */ - orion_readNegativeSamples(param, vol); + orion_multiscale_laplacian_output* + lap_output = orion_readNegativeSamples(param, vol); + + /* + * STEP 2 + * + * Compute the feature vector + */ + orion_features* features = orion_getFeatures( param, vol, lap_output ); + + /* STEP 3 + * + * Compute the discriminant functions and their response + */ + pixel_type min_scale, max_scale; + ndarray3_minmax(lap_output->max_response_at_scale_idx, + &min_scale, &max_scale ); + /* Compute the discriminant function for each scale. */ + orion_discriminant_function* discrim; + /* used to store the indices of the training instances */ + array_int* scale_instances = array_new_int(10); + for( int scale_idx = min_scale; scale_idx <= max_scale; scale_idx++ ) { + /* Training instances for current scale: + * Find all background features for this scale. + */ + array_reset_int(scale_instances); /* start the count over again */ + for( size_t f_idx = 0; f_idx < features->number_of_instances; f_idx++ ) { + bool feat_is_background = (bool)(lap_output->is_background->p[f_idx]); + size_t feat_scale = (size_t)(lap_output->max_response_at_scale_idx->p[f_idx]); + + if( feat_is_background && feat_scale == scale_idx ) { + array_add_int( scale_instances, f_idx ); + } + } + LOG_DEBUG("There are %d training samples for the scale %f [index: %d]", + array_length_int(scale_instances), + array_get_float( param->scales, scale_idx ), + scale_idx ); + + orion_compute2D_DiscrimantFunction(param, features, scale_instances, discrim); + } + array_free_int(scale_instances); WARN_UNIMPLEMENTED; + + orion_multiscale_laplacian_output_free( lap_output ); + orion_features_free(features); + kiss99_rng_state_free( param->rng_state ); } diff --git a/lib/segmentation/orion_discriminant.h b/lib/segmentation/orion_discriminant.h new file mode 100644 index 0000000..22c7240 --- /dev/null +++ b/lib/segmentation/orion_discriminant.h @@ -0,0 +1,42 @@ +#ifndef ORION_DISCRIMINANT_H +#define ORION_DISCRIMINANT_H 1 + +/* system headers */ +#include +#include + +/* local headers */ +#include "segmentation/orion_features.h" +#include "container/vector.h" +#include "ndarray/ndarray3.h" + +/* structs, enums */ +/*TODO(Define struct members)*/ +typedef struct { + + ndarray3* histogram; /* dimensions: [m, n, 1] */ + + + /* store the minimum and maximum value for each feature */ + pixel_type min_value[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + pixel_type max_value[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + /* for calculating the step size */ + pixel_type step_size[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + + /* location of bin edges for lookup */ + vector_float* edges[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; +} orion_discriminant_function; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ + + + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_DISCRIMINANT_H */ From f15e9829bffb3036506054d6c9fa6bbf59a7e74f Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 14:05:31 -0500 Subject: [PATCH 39/55] Use die() instead of exit() for failures in _orion_rand_seeds --- lib/numeric/random.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/numeric/random.c b/lib/numeric/random.c index 41ccb21..624892a 100644 --- a/lib/numeric/random.c +++ b/lib/numeric/random.c @@ -19,13 +19,14 @@ uint32_t _orion_rand_seeds() { #if OS_UNIX /* read from /dev/urandom */ int fn; - fn = open("/dev/urandom", O_RDONLY); + char random_device[] = "/dev/urandom"; + fn = open(random_device, O_RDONLY); if (fn == - 1) - exit( -1 ); - /* Failed ! */ + /* Failed ! */ + die("Could not open %s for seeding RNG", random_device); if ( read(fn, &r, 4) != 4) - exit( - 1) ; - /* Failed ! */ + /* Failed ! */ + die("Could not read %s for seeding RNG", random_device); close(fn); #elif defined(_CRT_RAND_S) rand_s( &r ); From 7ee10ec025ace4900b36747407223e9a0f3ce64d Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 15:16:51 -0500 Subject: [PATCH 40/55] Add platform-specific defines --- lib/config/platform.h | 41 +++++++++++++++++++++++++++++++++++++++ src/config/configurator.c | 8 +++----- 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 lib/config/platform.h diff --git a/lib/config/platform.h b/lib/config/platform.h new file mode 100644 index 0000000..5ac9700 --- /dev/null +++ b/lib/config/platform.h @@ -0,0 +1,41 @@ +#ifndef CONFIG_PLATFORM_H +#define CONFIG_PLATFORM_H 1 + +/* define OS_* macros */ +#if defined(_WIN32) + #define OS_WINDOWS 1 +#else + #define OS_UNIX 1 +#endif + + +/* Platform specific settings */ + +/* On Windows */ +#if OS_WINDOWS + #if _MSC_VER && !__INTEL_COMPILER + /* Microsoft compiler */ + + /* needed for the secure rand_s function */ + #define _CRT_RAND_S 1 + #include + + #endif + + /* the extension used for executables */ + #ifndef PLATFORM_EXE_EXT + #define PLATFORM_EXE_EXT ".exe" + #endif /* PLATFORM_EXE_EXT */ + +#endif /* OS_WINDOWS */ + +#if OS_UNIX + + /* the extension used for executables */ + #ifndef PLATFORM_EXE_EXT + #define PLATFORM_EXE_EXT "" + #endif /* PLATFORM_EXE_EXT */ + +#endif /* OS_UNIX */ + +#endif /* CONFIG_PLATFORM_H */ diff --git a/src/config/configurator.c b/src/config/configurator.c index 0eceada..036d9aa 100644 --- a/src/config/configurator.c +++ b/src/config/configurator.c @@ -1,3 +1,5 @@ +#include "config/platform.h" + #include #include #include @@ -9,11 +11,6 @@ #define COMMAND_LINE_BUFFER_LENGTH 16384 /* pow(2,14) */ -/* the extension used for executables */ -#ifndef PLATFORM_EXE_EXT -#define PLATFORM_EXE_EXT "" -#endif /* PLATFORM_EXE_EXT */ - #define DEFAULT_CC "cc" #define DEFAULT_CFLAGS "-g3 -ggdb -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition" @@ -24,6 +21,7 @@ #define CONFIG_HEADER_START \ "#ifndef CONFIG_H\n" \ "#define CONFIG_H 1\n\n" \ + "#include \"config/platform.h\"\n\n" \ #define CONFIG_HEADER_END \ "\n\n" \ From fb29a59110bcd425822bd232abc0136c5c32ebab Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 15:17:41 -0500 Subject: [PATCH 41/55] Configuration generator output needs warning about editing --- src/config/configurator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config/configurator.c b/src/config/configurator.c index 036d9aa..3a79e85 100644 --- a/src/config/configurator.c +++ b/src/config/configurator.c @@ -142,6 +142,10 @@ int main( int argc, char** argv ) { FILE* config_h_fh = stdout; /*= fopen(CONFIG_HEADER_FILENAME, "w");*/ + + /* warning to people that might want to edit the file */ + fprintf(config_h_fh, "/* Generated by %s. DO NOT EDIT! */\n\n", argv[0]); + fprintf(config_h_fh, CONFIG_HEADER_START); for(int test_idx = 0 ; test_idx < n_of_tests; test_idx++ ) { config_test* cur_test = &config_test_gen[test_idx]; From 9405b057fa66fdb99a42beacca9935edc6f6160e Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 15:18:24 -0500 Subject: [PATCH 42/55] Add NOECHO setting to decrease build output This helps avoid having to see the long series of compiler flags. --- make/00-implicit-rules.mk | 15 ++++++++++----- make/helper.mk | 3 +++ make/liborion.mk | 5 +++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/make/00-implicit-rules.mk b/make/00-implicit-rules.mk index ed8f4b6..18c54da 100644 --- a/make/00-implicit-rules.mk +++ b/make/00-implicit-rules.mk @@ -2,12 +2,14 @@ $(BUILDDIR)/%.o : $(LIBDIR)/%.c @$(MKDIR_DEPEND.c) @$(MKDIR_BUILD) - $(COMPILE.c) -o $@ $< + @echo " [ CC SRC $@ ]" + $(NOECHO)$(COMPILE.c) -o $@ $< $(BUILDTESTDIR)/%$(EXEEXT): $(TESTDIR)/%.c @$(MKDIR_DEPEND.c) @$(MKDIR_BUILDTESTDIR) - $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ + @echo " [ LINK TEST $@ ]" + $(NOECHO)$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ ifdef BUILD_GCOV # move the .gcno file to the directory with the executable mv `basename $@ $(EXEEXT)`.gcno `dirname $@` @@ -15,12 +17,14 @@ endif $(BUILDTESTDIR)/%$(EXEEXT): $(TESTDIR)/%.cxx mkdir -p `dirname $@` - $(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ + @echo " [ LINK TEST $@ ]" + $(NOECHO)$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ $(BINDIR)/%$(EXEEXT): $(SRCDIR)/%.c @$(MKDIR_DEPEND.c) @$(MKDIR_BIN) - $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ + @echo " [ LINK BINARY $@ ]" + $(NOECHO)$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ ifdef BUILD_GCOV # move the .gcno file to the directory with the executable mv `basename $@ $(EXEEXT)`.gcno `dirname $@` @@ -29,4 +33,5 @@ endif $(BINDIR)/%.o : $(SRCDIR)/%.c @$(MKDIR_DEPEND.c) @$(MKDIR_BIN) - $(COMPILE.c) -o $@ $< + @echo " [ CC SRC $@ ]" + $(NOECHO)$(COMPILE.c) -o $@ $< diff --git a/make/helper.mk b/make/helper.mk index 5abd4b3..184092e 100644 --- a/make/helper.mk +++ b/make/helper.mk @@ -1,3 +1,6 @@ +# set to empty in order to print commands +NOECHO := @ + MAKEFLAGS += --warn-undefined-variables SHELL := bash .SHELLFLAGS := -eu -o pipefail -c diff --git a/make/liborion.mk b/make/liborion.mk index c6c51f5..ef64337 100644 --- a/make/liborion.mk +++ b/make/liborion.mk @@ -1,3 +1,4 @@ $(LIBORION.A): $(LIB_OBJ) $(ITK_INTEGRATION_OBJ) - mkdir -p `dirname $@` - $(AR) $(ARFLAGS) $@ $^ + @mkdir -p `dirname $@` + @echo " [ AR $@ ]" + $(NOECHO)$(AR) $(ARFLAGS) $@ $^ From 8ccb0e4ff8a61bfb55afcd85d4106ff784478c5c Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 25 Apr 2016 15:54:45 -0500 Subject: [PATCH 43/55] Add a macro to increment ndarray3 elements --- lib/ndarray/ndarray3.h | 1 + lib/ndarray/ndarray3_generic.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/ndarray/ndarray3.h b/lib/ndarray/ndarray3.h index 6864242..f165e3d 100644 --- a/lib/ndarray/ndarray3.h +++ b/lib/ndarray/ndarray3.h @@ -78,6 +78,7 @@ extern float64 ndarray3_sum_over_all_float64( const ndarray3* n ); #define ndarray3_set ndarray3_generic_set #define ndarray3_get ndarray3_generic_get +#define ndarray3_increment ndarray3_generic_increment #define ndarray3_elems ndarray3_generic_elems #define NDARRAY3_LOOP_OVER_START NDARRAY3_GENERIC_LOOP_OVER_START #define NDARRAY3_LOOP_OVER_END NDARRAY3_GENERIC_LOOP_OVER_END diff --git a/lib/ndarray/ndarray3_generic.h b/lib/ndarray/ndarray3_generic.h index 4f24a28..4bb8e58 100644 --- a/lib/ndarray/ndarray3_generic.h +++ b/lib/ndarray/ndarray3_generic.h @@ -74,6 +74,30 @@ +/** TODO document + * + * ndarray3_increment( ndarray3* n, size_t i, size_t j, size_t k ) + */ +#define _real_ndarray3_generic_increment(_n, _n_i, _n_j, _n_k) \ + do { \ + ++( *_ndarray3_generic_index( (_n), (_n_i), (_n_j), (_n_k) ) ); \ + } while(0) +#ifdef NDARRAY3_ASSERT_BOUNDS_ACCESS + #define ndarray3_generic_increment(_n, _n_i, _n_j, _n_k) \ + do { \ + if( likely(_ndarray3_generic_assert_bounds(_n, _n_i, _n_j, _n_k)) ) { \ + _real_ndarray3_generic_increment(_n, _n_i, _n_j, _n_k); \ + } else { \ + die("ndarray3 (%p) access [%d,%d,%d]", _n, _n_i,_n_j,_n_k); \ + } \ + } while(0) +#else + #define ndarray3_generic_increment(_n, _n_i, _n_j, _n_k) \ + _real_ndarray3_generic_increment(_n, _n_i, _n_j, _n_k) +#endif /* NDARRAY3_ASSERT_BOUNDS_ACCESS */ + + + /** TODO document * NDARRAY3_GENERIC_LOOP_OVER_START( ndarray3* n, size_t i, size_t j, size_t k ) { * / * code body * / From b10251d77c0b60a469842ed9681a282e57d5de09 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Tue, 26 Apr 2016 17:15:08 -0500 Subject: [PATCH 44/55] Add functions to init and manipulate the 2D histogram --- .../compute2D_DiscrimantFunction.c | 9 ++------- lib/segmentation/orion_discriminant.c | 11 +++++++++++ lib/segmentation/orion_discriminant.h | 18 ++++++++++++++---- 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 lib/segmentation/orion_discriminant.c diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c index d7855a6..0004eb0 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c @@ -125,10 +125,7 @@ void orion_hist3( /* NOTE: histogram is allocated here: if the size of the bins change * for each dimension, then this will need to change */ - discrim->histogram = ndarray3_new( param->bins, param->bins, 1); - NDARRAY3_LOOP_OVER_START( discrim->histogram, i,j,k ) { - ndarray3_set( discrim->histogram, i,j,k, 0.0 ); - } NDARRAY3_LOOP_OVER_END; + orion_histogram_init( discrim, (param->bins + 1), (param->bins + 1) ); for( int indices_idx = 0; indices_idx < indices_sz; indices_idx++ ) { size_t feat_instance_idx = array_get_int( indices, indices_idx ); @@ -142,9 +139,7 @@ void orion_hist3( ); } /* increment by 1 */ - ndarray3_set( discrim->histogram, feat_bin_idx[0], feat_bin_idx[1], 0, - 1.0 + ndarray3_get(discrim->histogram, feat_bin_idx[0], feat_bin_idx[1], 0) - ); + orion_histogram_increment( discrim, feat_bin_idx[0], feat_bin_idx[1] ); } } diff --git a/lib/segmentation/orion_discriminant.c b/lib/segmentation/orion_discriminant.c new file mode 100644 index 0000000..8546881 --- /dev/null +++ b/lib/segmentation/orion_discriminant.c @@ -0,0 +1,11 @@ +#include "segmentation/orion_discriminant.h" + +void orion_histogram_init(orion_discriminant_function* discrim, size_t m, size_t n) { + discrim->m = m; + discrim->n = n; + + NEW_COUNT(discrim->histogram, size_t, discrim->m * discrim->n); + for( int hist_idx = 0; hist_idx < orion_histogram_elems(discrim); hist_idx++ ) { + discrim->histogram[hist_idx] = 0; + } +} diff --git a/lib/segmentation/orion_discriminant.h b/lib/segmentation/orion_discriminant.h index 22c7240..540f37b 100644 --- a/lib/segmentation/orion_discriminant.h +++ b/lib/segmentation/orion_discriminant.h @@ -12,9 +12,20 @@ /* structs, enums */ /*TODO(Define struct members)*/ -typedef struct { - ndarray3* histogram; /* dimensions: [m, n, 1] */ +/* TODO document */ +#define orion_histogram_elems( discrim ) ( discrim->m * discrim->n ) + +#define _orion_histogram_index(discrim, bin_m, bin_n) (bin_m * discrim->m + bin_n) + +/* TODO document */ +#define orion_histogram_increment(discrim, bin_m, bin_n) \ + ( ++( discrim->histogram[ _orion_histogram_index(discrim, bin_m, bin_n) ] ) ) + +typedef struct { + size_t m; /* number of bins in the first dimension */ + size_t n; /* number of bins in the second dimension */ + size_t* histogram; /* dimensions: [m, n] */ /* store the minimum and maximum value for each feature */ @@ -32,8 +43,7 @@ extern "C" { #endif /* __cplusplus */ /* Function prototypes */ - - +extern void orion_histogram_init(orion_discriminant_function* discrim, size_t m, size_t n); #ifdef __cplusplus }; From 79c0e10af9681ae2b087357a6073b4bda31bd2f3 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Tue, 26 Apr 2016 18:10:44 -0500 Subject: [PATCH 45/55] Improve indexing of histogram --- lib/segmentation/orion_discriminant.c | 6 +++--- lib/segmentation/orion_discriminant.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/segmentation/orion_discriminant.c b/lib/segmentation/orion_discriminant.c index 8546881..09a1bdf 100644 --- a/lib/segmentation/orion_discriminant.c +++ b/lib/segmentation/orion_discriminant.c @@ -1,10 +1,10 @@ #include "segmentation/orion_discriminant.h" void orion_histogram_init(orion_discriminant_function* discrim, size_t m, size_t n) { - discrim->m = m; - discrim->n = n; + discrim->bin_sz[0] = m; + discrim->bin_sz[1] = n; - NEW_COUNT(discrim->histogram, size_t, discrim->m * discrim->n); + NEW_COUNT(discrim->histogram, size_t, discrim->bin_sz[0] * discrim->bin_sz[1]); for( int hist_idx = 0; hist_idx < orion_histogram_elems(discrim); hist_idx++ ) { discrim->histogram[hist_idx] = 0; } diff --git a/lib/segmentation/orion_discriminant.h b/lib/segmentation/orion_discriminant.h index 540f37b..422a018 100644 --- a/lib/segmentation/orion_discriminant.h +++ b/lib/segmentation/orion_discriminant.h @@ -14,18 +14,18 @@ /*TODO(Define struct members)*/ /* TODO document */ -#define orion_histogram_elems( discrim ) ( discrim->m * discrim->n ) +#define orion_histogram_elems( discrim ) ( discrim->bin_sz[0] * discrim->bin_sz[1] ) -#define _orion_histogram_index(discrim, bin_m, bin_n) (bin_m * discrim->m + bin_n) +#define _orion_histogram_index(discrim, bin_row, bin_col) (bin_row * discrim->bin_sz[1] + bin_col) /* TODO document */ -#define orion_histogram_increment(discrim, bin_m, bin_n) \ - ( ++( discrim->histogram[ _orion_histogram_index(discrim, bin_m, bin_n) ] ) ) +#define orion_histogram_increment(discrim, bin_row, bin_col) \ + ( ++( discrim->histogram[ _orion_histogram_index(discrim, bin_row, bin_col) ] ) ) typedef struct { - size_t m; /* number of bins in the first dimension */ - size_t n; /* number of bins in the second dimension */ - size_t* histogram; /* dimensions: [m, n] */ + /* number of bins in each dimension */ + size_t bin_sz[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + size_t* histogram; /* dimensions: [bin_sz[0], bin_sz[1]] */ /* store the minimum and maximum value for each feature */ From 8a9b234801d62cee39a7ea934cfb2e3bdc424f7c Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Mon, 23 May 2016 19:20:13 -0500 Subject: [PATCH 46/55] VTK build configuration --- .gitignore | 1 + make/dep.mk | 1 + make/vtk-config.mk | 21 ++++++ make/vtk/CMakeLists.txt | 40 +++++++++++ make/vtk/ImageMapper.cxx | 102 ++++++++++++++++++++++++++++ tool/script/extract-linker-flags.pl | 2 +- 6 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 make/vtk-config.mk create mode 100644 make/vtk/CMakeLists.txt create mode 100644 make/vtk/ImageMapper.cxx diff --git a/.gitignore b/.gitignore index 0cec9cb..292b45c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ ITKIOFactoryRegistration cmake_install.cmake /make/itk/itk-config.mk.gen +/make/vtk/vtk-config.mk.gen /ComputeFrangi/Makefile /ComputeFrangi/ComputeEigenValue_Sorted_Frangi diff --git a/make/dep.mk b/make/dep.mk index 118e036..8acec66 100644 --- a/make/dep.mk +++ b/make/dep.mk @@ -3,3 +3,4 @@ include make/kiss-fft-config.mk include make/vaa3d-config.mk include make/matlab-runtime-config.mk include make/itk-config.mk +include make/vtk-config.mk diff --git a/make/vtk-config.mk b/make/vtk-config.mk new file mode 100644 index 0000000..d44eee3 --- /dev/null +++ b/make/vtk-config.mk @@ -0,0 +1,21 @@ +VTK_CONFIG_MK := make/vtk/vtk-config.mk.gen +include $(VTK_CONFIG_MK) + +BIN_VTK_IMAGE_MAPPER := $(BINDIR)/vtk-image-mapper/ImageMapper$(EXEEXT) +TEST_VTK_BUILD: $(BIN_VTK_IMAGE_MAPPER) + +$(BIN_VTK_IMAGE_MAPPER): CPPFLAGS += $(VTK_CPPFLAGS) +$(BIN_VTK_IMAGE_MAPPER): LDFLAGS += $(VTK_LDFLAGS) +$(BIN_VTK_IMAGE_MAPPER): LDLIBS += $(VTK_LDLIBS) +$(BIN_VTK_IMAGE_MAPPER): make/vtk/ImageMapper.cxx + mkdir -p `dirname $@` + @echo " [ LINK TEST $@ ]" + $(NOECHO)$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ + +$(VTK_CONFIG_MK): make/vtk/CMakeLists.txt \ + | $(BUILDDIR) + @$(MKDIR_BUILD) + $(CMAKE.generate) -B$(BUILDDIR)/.make/vtk -Hmake/vtk + echo "VTK_LDLIBS += `./tool/script/extract-linker-flags.pl < $(BUILDDIR)/.make/vtk/CMakeFiles/ImageMapper.dir/link.txt`" >> $@ + +VTK_LDFLAGS += -msse2 -rdynamic diff --git a/make/vtk/CMakeLists.txt b/make/vtk/CMakeLists.txt new file mode 100644 index 0000000..a01a106 --- /dev/null +++ b/make/vtk/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 2.8) + +PROJECT(ImageMapper) + +find_package(VTK REQUIRED) +include(${VTK_USE_FILE}) + +add_executable(ImageMapper MACOSX_BUNDLE ImageMapper) + +if(VTK_LIBRARIES) + target_link_libraries(ImageMapper ${VTK_LIBRARIES}) +else() + target_link_libraries(ImageMapper vtkHybrid vtkWidgets) +endif() + +message( ${VTK_LIBRARIES} ) + + +foreach (incdir ${VTK_INCLUDE_DIRS}) + set(VTK_CPPFLAGS "${VTK_CPPFLAGS} -I${incdir}") +endforeach() + +foreach (libdir ${VTK_LIBRARY_DIRS}) + set(VTK_LDFLAGS "${VTK_LDFLAGS} -L${libdir}") +endforeach() + +foreach (lib ${VTK_LIBRARIES}) + # this variable does not give the actual linker flags + #set(VTK_LDLIBS "${VTK_LDLIBS} -l${lib}") +endforeach() + +set(VTK_CONFIG_MK_GEN "vtk-config.mk.gen" ) +file(WRITE ${VTK_CONFIG_MK_GEN} "VTK_CPPFLAGS := ${VTK_CPPFLAGS}\n") +file(APPEND ${VTK_CONFIG_MK_GEN} "VTK_LDFLAGS := ${VTK_LDFLAGS}\n") +file(APPEND ${VTK_CONFIG_MK_GEN} "VTK_LDLIBS := ${VTK_LDLIBS}\n") + +#get_cmake_property(_variableNames VARIABLES) +#foreach (_variableName ${_variableNames}) + #message(STATUS "${_variableName}=${${_variableName}}") +#endforeach() diff --git a/make/vtk/ImageMapper.cxx b/make/vtk/ImageMapper.cxx new file mode 100644 index 0000000..121ffd5 --- /dev/null +++ b/make/vtk/ImageMapper.cxx @@ -0,0 +1,102 @@ +/* Need to initialise because we are building without CMake: + * + */ +#include +VTK_MODULE_INIT(vtkRenderingOpenGL); +VTK_MODULE_INIT(vtkInteractionStyle); +VTK_MODULE_INIT(vtkRenderingFreeType); +VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL); +VTK_MODULE_INIT(vtkRenderingVolumeOpenGL); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void CreateColorImage(vtkImageData*); + +int main(int, char *[]) +{ + vtkSmartPointer colorImage = vtkSmartPointer::New(); + CreateColorImage(colorImage); + + vtkSmartPointer imageMapper = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 + imageMapper->SetInputConnection(colorImage->GetProducerPort()); +#else + imageMapper->SetInputData(colorImage); +#endif + imageMapper->SetColorWindow(255); + imageMapper->SetColorLevel(127.5); + + vtkSmartPointer imageActor = vtkSmartPointer::New(); + imageActor->SetMapper(imageMapper); + imageActor->SetPosition(20, 20); + + // Setup renderers + vtkSmartPointer renderer = vtkSmartPointer::New(); + + // Setup render window + vtkSmartPointer renderWindow = vtkSmartPointer::New(); + + renderWindow->AddRenderer(renderer); + + // Setup render window interactor + vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New(); + + vtkSmartPointer style = vtkSmartPointer::New(); + + renderWindowInteractor->SetInteractorStyle(style); + + // Render and start interaction + renderWindowInteractor->SetRenderWindow(renderWindow); + + //renderer->AddViewProp(imageActor); + renderer->AddActor2D(imageActor); + + renderWindow->Render(); + renderWindowInteractor->Start(); + + return EXIT_SUCCESS; +} + +void CreateColorImage(vtkImageData* image) +{ + unsigned int dim = 20; + + image->SetDimensions(dim, dim, 1); +#if VTK_MAJOR_VERSION <= 5 + image->SetNumberOfScalarComponents(3); + image->SetScalarTypeToUnsignedChar(); + image->AllocateScalars(); +#else + image->AllocateScalars(VTK_UNSIGNED_CHAR,3); +#endif + for(unsigned int x = 0; x < dim; x++) + { + for(unsigned int y = 0; y < dim; y++) + { + unsigned char* pixel = static_cast(image->GetScalarPointer(x,y,0)); + if(x < dim/2) + { + pixel[0] = 255; + pixel[1] = 0; + } + else + { + pixel[0] = 0; + pixel[1] = 255; + } + + pixel[2] = 0; + } + } + + image->Modified(); +} diff --git a/tool/script/extract-linker-flags.pl b/tool/script/extract-linker-flags.pl index 968780f..22a561e 100755 --- a/tool/script/extract-linker-flags.pl +++ b/tool/script/extract-linker-flags.pl @@ -6,5 +6,5 @@ use Text::ParseWords; my @words = shellwords(<>); -my @ldlibs = grep { /(^-l)|\.a$/ } @words; +my @ldlibs = grep { /(^-l)|\.a$|\.so/ } @words; print "@ldlibs"; From 52ee36d5c07fec47595f33048d0cfef7f350af5b Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 10 Jun 2016 15:44:40 -0500 Subject: [PATCH 47/55] Move the generated ITK/VTK make configuration into the BUILDDIR This ensures that the configuration does not stay with the source code. --- .gitignore | 3 --- make/itk-config.mk | 2 +- make/itk/CMakeLists.txt | 2 +- make/vtk-config.mk | 2 +- make/vtk/CMakeLists.txt | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 292b45c..824f05c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ CMakeFiles ITKIOFactoryRegistration cmake_install.cmake -/make/itk/itk-config.mk.gen -/make/vtk/vtk-config.mk.gen - /ComputeFrangi/Makefile /ComputeFrangi/ComputeEigenValue_Sorted_Frangi diff --git a/make/itk-config.mk b/make/itk-config.mk index d263bc3..c4a5f6d 100644 --- a/make/itk-config.mk +++ b/make/itk-config.mk @@ -1,4 +1,4 @@ -ITK_CONFIG_MK := make/itk/itk-config.mk.gen +ITK_CONFIG_MK := $(BUILDDIR)/.make/itk/itk-config.mk.gen include $(ITK_CONFIG_MK) $(ITK_CONFIG_MK): make/itk/CMakeLists.txt \ diff --git a/make/itk/CMakeLists.txt b/make/itk/CMakeLists.txt index 89c4d8b..e4052cb 100644 --- a/make/itk/CMakeLists.txt +++ b/make/itk/CMakeLists.txt @@ -26,7 +26,7 @@ foreach (lib ${ITK_LIBRARIES}) #set(ITK_LDLIBS "${ITK_LDLIBS} -l${lib}-4.8") endforeach() -set(ITK_CONFIG_MK_GEN "itk-config.mk.gen" ) +set(ITK_CONFIG_MK_GEN "${CMAKE_BINARY_DIR}/itk-config.mk.gen" ) file(WRITE ${ITK_CONFIG_MK_GEN} "ITK_CPPFLAGS := ${ITK_CPPFLAGS}\n") file(APPEND ${ITK_CONFIG_MK_GEN} "ITK_LDFLAGS := ${ITK_LDFLAGS}\n") file(APPEND ${ITK_CONFIG_MK_GEN} "ITK_LDLIBS := ${ITK_LDLIBS}\n") diff --git a/make/vtk-config.mk b/make/vtk-config.mk index d44eee3..c8165e5 100644 --- a/make/vtk-config.mk +++ b/make/vtk-config.mk @@ -1,4 +1,4 @@ -VTK_CONFIG_MK := make/vtk/vtk-config.mk.gen +VTK_CONFIG_MK := $(BUILDDIR)/.make/vtk/vtk-config.mk.gen include $(VTK_CONFIG_MK) BIN_VTK_IMAGE_MAPPER := $(BINDIR)/vtk-image-mapper/ImageMapper$(EXEEXT) diff --git a/make/vtk/CMakeLists.txt b/make/vtk/CMakeLists.txt index a01a106..8b3695c 100644 --- a/make/vtk/CMakeLists.txt +++ b/make/vtk/CMakeLists.txt @@ -29,7 +29,7 @@ foreach (lib ${VTK_LIBRARIES}) #set(VTK_LDLIBS "${VTK_LDLIBS} -l${lib}") endforeach() -set(VTK_CONFIG_MK_GEN "vtk-config.mk.gen" ) +set(VTK_CONFIG_MK_GEN "${CMAKE_BINARY_DIR}/vtk-config.mk.gen" ) file(WRITE ${VTK_CONFIG_MK_GEN} "VTK_CPPFLAGS := ${VTK_CPPFLAGS}\n") file(APPEND ${VTK_CONFIG_MK_GEN} "VTK_LDFLAGS := ${VTK_LDFLAGS}\n") file(APPEND ${VTK_CONFIG_MK_GEN} "VTK_LDLIBS := ${VTK_LDLIBS}\n") From 3e17468913f046c93f7e10d6f502fc9818c12b99 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 10 Jun 2016 15:54:10 -0500 Subject: [PATCH 48/55] Travis-CI: Add libvtk5-dev to the list of packages --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ca7de46..8625d05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: c sudo: false +addons: + apt: + packages: + - libvtk5-dev env: - PROD=1 TEST_VERBOSE=1 - PROD=1 TEST_VERBOSE=1 COVERAGE=1 From 2dff9bbdcdacff9e695e30f786f73bb1d8c43c53 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 10 Jun 2016 23:03:12 -0500 Subject: [PATCH 49/55] Travis-CI: build in trusty environment --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8625d05..149aa11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: c -sudo: false +os: linux +dist: trusty +sudo: required addons: apt: packages: From de503eabf907efdcb6a86c098d8652ad010f8d67 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 10 Jun 2016 23:10:39 -0500 Subject: [PATCH 50/55] Travis-CI: install ITK/VTK version from trusty packages --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 149aa11..e4ad336 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ sudo: required addons: apt: packages: - - libvtk5-dev + - libvtk6-dev + - libinsighttoolkit4-dev env: - PROD=1 TEST_VERBOSE=1 - PROD=1 TEST_VERBOSE=1 COVERAGE=1 @@ -13,10 +14,6 @@ compiler: - gcc - clang before_install: - - mkdir build - - git clone https://github.com/CBL-ORION/ITK-builds.git external/ITK - # path for CMake to search for built ITK - - export ITK_DIR="`( cd external/ITK/usr/local/lib/cmake/ITK-4.9 && pwd )`" - if [ "$COVERAGE" = 1 ]; then pip install --user cpp-coveralls; fi script: # version of gcc on Travis-CI does not support ASAN flag From f9c5cf68bd3e2d9ff5691a861ae78f709f865fde Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 10 Jun 2016 23:53:50 -0500 Subject: [PATCH 51/55] build: Add support for VTK C++ compilation --- Makefile | 13 ++++++++++++- make/00-implicit-rules.mk | 8 +++++++- make/autodep.mk | 19 +++++++++++++------ make/filter-vesselness-rules.mk | 4 ++-- make/itk-config.mk | 2 +- make/misc-config.mk | 1 + make/misc-rules.mk | 8 +++++++- make/util-rules.mk | 6 +++--- make/vtk-config.mk | 2 +- 9 files changed, 47 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 0499cd2..a82317d 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,14 @@ BIN_SRC_CONFIG.c := $(SRCDIR)/config/configurator.c BIN_SRC.cc := $(SRCDIR)/compute-filter/ComputeFilter.cxx $(SRCDIR)/subsample-volume/SubsampleVolume.cxx #LIB_SRC.c := $(LIBDIR)/ndarray/ndarray3.c # $(LIBDIR)/filter/hdaf/Makefilter.c LIB_SRC.c := $(shell find $(LIBDIR) -path lib/t -prune -o -type f -name '*.c' \! -name '*_impl.c' -print) +LIB_SRC.cc := $(shell find $(LIBDIR) \ + -path lib/t -prune -o \ + -path lib/vaa3d-plugin -prune -o \ + -path lib/config -prune -o \ + -path lib/filter/vesselness -prune -o \ + -path lib/integration -prune -o \ + -type f -name '*.cxx' -print) +$(echo $(LIB_SRC.cc)) TEST.c := $(shell find $(TESTDIR) -path lib/t/liborion3mat -prune -o -type f -name "*.c" -print) ifdef FEAT_LIBORION3MAT TEST.c += $(TESTDIR)/liborion3mat/test.c @@ -16,11 +24,13 @@ include make/autodep.mk ## Target files OBJ_PATHSUBST.c = $(patsubst $(LIBDIR)/%.c,$(BUILDDIR)/%.o,$(1)) +OBJ_PATHSUBST.cc = $(patsubst $(LIBDIR)/%.cxx,$(BUILDDIR)/%.o,$(1)) TEST_PATHSUBST.c = $(patsubst $(TESTDIR)/%.c,$(BUILDTESTDIR)/%$(EXEEXT),$(1)) BIN_PATHSUBST.c = $(patsubst $(SRCDIR)/%.c,$(BINDIR)/%$(EXEEXT),$(1)) BIN_PATHSUBST.cc = $(patsubst $(SRCDIR)/%.cxx,$(BINDIR)/%$(EXEEXT),$(1)) -MKDIR_BUILD = mkdir -p `dirname $(call OBJ_PATHSUBST.c,$<)` +MKDIR_BUILD.c = mkdir -p `dirname $(call OBJ_PATHSUBST.c,$<)` +MKDIR_BUILD.cc = mkdir -p `dirname $(call OBJ_PATHSUBST.cc,$<)` MKDIR_BIN = mkdir -p `dirname $(call BIN_PATHSUBST.c,$<)` MKDIR_BUILDTESTDIR = mkdir -p `dirname $(call TEST_PATHSUBST.c,$<)` @@ -33,6 +43,7 @@ include make/liborion-config.mk ## Generate the targets LIB_OBJ:= $(call OBJ_PATHSUBST.c,$(LIB_SRC.c)) +LIB_OBJ+= $(call OBJ_PATHSUBST.cc,$(LIB_SRC.cc)) TEST_OBJ:= $(call TEST_PATHSUBST.c,$(TEST.c)) diff --git a/make/00-implicit-rules.mk b/make/00-implicit-rules.mk index 18c54da..ce550c9 100644 --- a/make/00-implicit-rules.mk +++ b/make/00-implicit-rules.mk @@ -1,10 +1,16 @@ ### Implict rules $(BUILDDIR)/%.o : $(LIBDIR)/%.c @$(MKDIR_DEPEND.c) - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.c) @echo " [ CC SRC $@ ]" $(NOECHO)$(COMPILE.c) -o $@ $< +$(BUILDDIR)/%.o : $(LIBDIR)/%.cxx + @$(MKDIR_DEPEND.cc) + @$(MKDIR_BUILD.cc) + @echo " [ CXX SRC $@ ]" + $(NOECHO)$(COMPILE.cc) -o $@ $< + $(BUILDTESTDIR)/%$(EXEEXT): $(TESTDIR)/%.c @$(MKDIR_DEPEND.c) @$(MKDIR_BUILDTESTDIR) diff --git a/make/autodep.mk b/make/autodep.mk index a6513d1..eac55aa 100644 --- a/make/autodep.mk +++ b/make/autodep.mk @@ -1,8 +1,15 @@ ## Dependency generation -MAKEDEPEND.c = gcc -MM $(CPPFLAGS) -o $(df).d $< -df = $(<:%.c=$(DEPDIR)/%) -MKDIR_DEPEND.c = mkdir -p `dirname $(df).d`; $(MAKEDEPEND.c); \ - $(CP) $(df).d $(df).P; \ +MAKEDEPEND.c = gcc -MM $(CPPFLAGS) -o $(df.c).d $< +MAKEDEPEND.cc = gcc -MM $(CXXFLAGS) $(CPPFLAGS) -o $(df.cc).d $< +df.c = $(<:%.c=$(DEPDIR)/%) +df.cc = $(<:%.cxx=$(DEPDIR)/%) +MKDIR_DEPEND.c = mkdir -p `dirname $(df.c).d`; $(MAKEDEPEND.c); \ + $(CP) $(df.c).d $(df.c).P; \ sed -e 's/$(HASHMARK).*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \ - $(RM) $(df).d + -e '/^$$/ d' -e 's/$$/ :/' < $(df.c).d >> $(df.c).P; \ + $(RM) $(df.c).d +MKDIR_DEPEND.cc = mkdir -p `dirname $(df.cc).d`; $(MAKEDEPEND.cc); \ + $(CP) $(df.cc).d $(df.cc).P; \ + sed -e 's/$(HASHMARK).*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ + -e '/^$$/ d' -e 's/$$/ :/' < $(df.cc).d >> $(df.cc).P; \ + $(RM) $(df.cc).d diff --git a/make/filter-vesselness-rules.mk b/make/filter-vesselness-rules.mk index 24dcd04..274909a 100644 --- a/make/filter-vesselness-rules.mk +++ b/make/filter-vesselness-rules.mk @@ -3,11 +3,11 @@ $(EIGEN_FRANGI_LIB_OBJ): $(FILTER_FRANGI_OBJ) $(EIGEN_SATO_LIB_OBJ): $(FILTER_SATO_OBJ) $(FILTER_FRANGI_OBJ): $(LIBDIR)/filter/vesselness/frangi/EigenFrangi.cxx - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.cc) $(CMAKE.generate) -B$(BUILDDIR)/filter/vesselness -H$(LIBDIR)/filter/vesselness $(MAKE) -C$(BUILDDIR)/filter/vesselness $(FILTER_SATO_OBJ): $(LIBDIR)/filter/vesselness/sato/EigenSato.cxx - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.cc) $(CMAKE.generate) -B$(BUILDDIR)/filter/vesselness -H$(LIBDIR)/filter/vesselness $(MAKE) -C$(BUILDDIR)/filter/vesselness diff --git a/make/itk-config.mk b/make/itk-config.mk index c4a5f6d..dbd7143 100644 --- a/make/itk-config.mk +++ b/make/itk-config.mk @@ -3,7 +3,7 @@ include $(ITK_CONFIG_MK) $(ITK_CONFIG_MK): make/itk/CMakeLists.txt \ | $(BUILDDIR) - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.c) $(CMAKE.generate) -B$(BUILDDIR)/.make/itk -Hmake/itk echo "ITK_LDLIBS += `./tool/script/extract-linker-flags.pl < $(BUILDDIR)/.make/itk/CMakeFiles/Pi.dir/link.txt`" >> $@ diff --git a/make/misc-config.mk b/make/misc-config.mk index 564166e..a516171 100644 --- a/make/misc-config.mk +++ b/make/misc-config.mk @@ -1 +1,2 @@ ITK_INTEGRATION_LIB_OBJ := $(BUILDDIR)/integration/itk/CMakeFiles/IntegrationITK.dir/itk.cxx.o +VTK_VIS_LIB_OBJ := $(BUILDDIR)/vis/vis.o diff --git a/make/misc-rules.mk b/make/misc-rules.mk index 1511dd7..82842e4 100644 --- a/make/misc-rules.mk +++ b/make/misc-rules.mk @@ -11,6 +11,12 @@ $(BUILDDIR)/integration/itk/libIntegrationITK.a: \ $(FILTER_OBJ) \ $(BUILDDIR)/ndarray/array_ndarray3.o \ $(BUILDDIR)/ndarray/ndarray3.o - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.cc) $(CMAKE.generate) -B$(BUILDDIR)/integration/itk -H$(LIBDIR)/integration/itk $(MAKE) -C$(BUILDDIR)/integration/itk + +$(VTK_VIS_LIB_OBJ): CPPFLAGS += $(VTK_CPPFLAGS) +$(VTK_VIS_LIB_OBJ): CXXFLAGS += -std=c++11 +$(VTK_VIS_LIB_OBJ): LDFLAGS += $(VTK_LDFLAGS) +$(VTK_VIS_LIB_OBJ): LDLIBS += $(VTK_LDLIBS) +$(VTK_VIS_LIB_OBJ): $(LIBDIR)/vis/vis.cxx diff --git a/make/util-rules.mk b/make/util-rules.mk index cf93349..e9c2ae6 100644 --- a/make/util-rules.mk +++ b/make/util-rules.mk @@ -4,9 +4,9 @@ $(BINDIR)/subsample-volume/SubsampleVolume$(EXEEXT): $(SRCDIR)/subsample-volume/ $(MAKE) -C$(BINDIR)/subsample-volume BIN_ORION_SEGMENTATION := $(BINDIR)/segmentation/orion-segmentation$(EXEEXT) -$(BIN_ORION_SEGMENTATION): CPPFLAGS += $(ITK_CPPFLAGS) -$(BIN_ORION_SEGMENTATION): LDFLAGS += $(ITK_LDFLAGS) -$(BIN_ORION_SEGMENTATION): LDLIBS += $(ITK_LDLIBS) +$(BIN_ORION_SEGMENTATION): CPPFLAGS += $(ITK_CPPFLAGS) $(VTK_CPPFLAGS) +$(BIN_ORION_SEGMENTATION): LDFLAGS += $(ITK_LDFLAGS) $(VTK_LDFLAGS) +$(BIN_ORION_SEGMENTATION): LDLIBS += $(ITK_LDLIBS) $(VTK_LDLIBS) $(BIN_ORION_SEGMENTATION): LDLIBS += -lstdc++ # needs to add C++ library to link $(BIN_ORION_SEGMENTATION): \ $(SRCDIR)/segmentation/orion-segmentation.c \ diff --git a/make/vtk-config.mk b/make/vtk-config.mk index c8165e5..e5e1d7c 100644 --- a/make/vtk-config.mk +++ b/make/vtk-config.mk @@ -14,7 +14,7 @@ $(BIN_VTK_IMAGE_MAPPER): make/vtk/ImageMapper.cxx $(VTK_CONFIG_MK): make/vtk/CMakeLists.txt \ | $(BUILDDIR) - @$(MKDIR_BUILD) + @$(MKDIR_BUILD.c) $(CMAKE.generate) -B$(BUILDDIR)/.make/vtk -Hmake/vtk echo "VTK_LDLIBS += `./tool/script/extract-linker-flags.pl < $(BUILDDIR)/.make/vtk/CMakeFiles/ImageMapper.dir/link.txt`" >> $@ From 9642be5d064c2030ecc3b5d1255278857be38dc5 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Wed, 29 Jun 2016 08:13:58 -0500 Subject: [PATCH 52/55] Identify TODO items --- .../How_sigma_relates_to_radii/testSigma.c | 4 +++- .../DetectTrainingSet/IsotropicFilter/Makefilter.c | 7 ++++--- .../DetectTrainingSet/IsotropicFilter/compute_LP.c | 2 +- .../IsotropicFilter/compute_Laplacian.c | 2 +- .../DetectTrainingSet/IsotropicFilter/hdaf.c | 5 ++--- .../DetectTrainingSet/multiscaleLaplacianFilter.c | 10 ++++------ .../DetectTrainingSet/readNegativeSamples.c | 6 +++--- .../compute2D_DiscrimantFunction.c | 12 ++++++------ .../getResponseToDiscriminantFunction.c | 2 +- .../DiscriminantFunction/removeIsolatedResponses.c | 6 ++---- .../dendrites_main/ExtractFeatures/sortEigenvalues.c | 2 ++ .../dendrites_main/Util/getInfoVolume.c | 2 +- .../dendrites_main/Util/remove_small_conComp3D.c | 2 +- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/How_sigma_relates_to_radii/testSigma.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/How_sigma_relates_to_radii/testSigma.c index 7dea82b..8c3b102 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/How_sigma_relates_to_radii/testSigma.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/How_sigma_relates_to_radii/testSigma.c @@ -1,4 +1,6 @@ -/* dead code +/* TODO turn into test * * Refactor testSigma + * + * external/orion3mat/01_Segmentation/dendrites_main/DetectTrainingSet/How_sigma_relates_to_radii/testSigma.m */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.c index f3827ac..55377f9 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.c @@ -1,6 +1,3 @@ -/* - * Refactor: Makefilter - */ #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/Makefilter.h" @@ -11,6 +8,10 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/hdaf.h" +/* MATLAB version: Makefilter */ + +/* TODO document + */ ndarray3* orion_Makefilter( size_t nx, size_t ny, size_t nz, int hdaf_approx_degree, diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_LP.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_LP.c index f50cf65..8984ce5 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_LP.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_LP.c @@ -1,4 +1,4 @@ -/* TODO +/* TODO: part of testing * * Refactor: compute_LP */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_Laplacian.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_Laplacian.c index 3331b73..7c8b105 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_Laplacian.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/compute_Laplacian.c @@ -1,4 +1,4 @@ -/* TODO +/* dead code * * Refactor: compute_Laplacian */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/hdaf.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/hdaf.c index 6ce8d66..56729ac 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/hdaf.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/IsotropicFilter/hdaf.c @@ -1,12 +1,11 @@ -/* - * Refactor: hdaf - */ #include "hdaf.h" #include #include "numeric/func.h" +/* MATLAB version: hdaf */ + /* * orion_hdaf( hdaf_approx_degree, scaling_constant, x) * diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c index b1eabf2..df091a9 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.c @@ -1,8 +1,3 @@ -/* TODO - * - * Refactor: multiscaleLaplacianFilter - */ - #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/multiscaleLaplacianFilter.h" #include "util/util.h" @@ -42,7 +37,10 @@ orion_multiscale_laplacian_output* orion_multiscale_laplacian_output_new() { return r; } -/* +/* MATLAB version: multiscaleLaplacianFilter */ + +/* TODO document better + * * function that allows to get the maximum reponse of the Laplacian * * laplacian_scales: scales to use for calculating the Laplacian. These are diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c index 62c729d..9734a7c 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.c @@ -1,8 +1,8 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DetectTrainingSet/readNegativeSamples.h" -/* TODO - * - * Refactor: readNegativeSamples +/* MATLAB version: Refactor: readNegativeSamples */ + +/* TODO document */ orion_multiscale_laplacian_output* orion_readNegativeSamples( diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c index 0004eb0..4710572 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c @@ -2,14 +2,11 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h" -/* TODO - * - * Refactor: compute2D_DiscrimantFunction - */ - #define MAX_NUMBER_OF_HISTOGRAM_SAMPLES 1E6 #include "numeric/sample.h" +#include "vis/vis.hxx" + #include #include #include @@ -27,6 +24,9 @@ void orion_normaliseHistogram( orion_discriminant_function* discrim ); +/* MATLAB version: compute2D_DiscrimantFunction */ + +/* TODO document */ void orion_compute2D_DiscrimantFunction( orion_segmentation_param* param, orion_features* features, @@ -107,7 +107,7 @@ void orion_compute2D_DiscrimantFunction( /* Creates a 2D histogram * - * TODO + * TODO document * * See also: MATLAB's hist3 function */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/getResponseToDiscriminantFunction.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/getResponseToDiscriminantFunction.c index 96a54bc..8a78647 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/getResponseToDiscriminantFunction.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/getResponseToDiscriminantFunction.c @@ -1,4 +1,4 @@ -/* TODO +/* TODO compare with the MATLAB code * * Refactor: getResponseToDiscriminantFunction */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c index 5edf1dc..7c62149 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.c @@ -1,13 +1,11 @@ #include "kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/removeIsolatedResponses.h" -/* TODO - * - * Refactor: removeIsolatedResponses - */ #include "numeric/sample.h" #include #include "simple-log/simplelog.h" +/* MATLAB version: removeIsolatedResponses */ + /* orion_removeIsolatedResponses * * Identify the indices of features that are non-isolated so that only features diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/sortEigenvalues.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/sortEigenvalues.c index 53a2d98..2229c95 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/sortEigenvalues.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/ExtractFeatures/sortEigenvalues.c @@ -1,4 +1,6 @@ /* TODO + * + * dead code via computeFeaturesIsotropicFilter * * Refactor: sortEigenvalues */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/getInfoVolume.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/getInfoVolume.c index 663f2dc..7b6c127 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/getInfoVolume.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/getInfoVolume.c @@ -1,4 +1,4 @@ -/* TODO +/* TODO remove this. Already available in mhd reading code * * Refactor: getInfoVolume */ diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/remove_small_conComp3D.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/remove_small_conComp3D.c index a2a5f88..aadcc3b 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/remove_small_conComp3D.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/Util/remove_small_conComp3D.c @@ -1,4 +1,4 @@ -/* TODO +/* TODO create test case for this * * Refactor: remove_small_conComp3D */ From 82fea6ac04993fc4139afcb85d7d5c4df6c885bd Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Wed, 29 Jun 2016 08:14:19 -0500 Subject: [PATCH 53/55] VTK linking and histogram normalisation work --- .../compute2D_DiscrimantFunction.c | 18 ++++- lib/segmentation/orion_discriminant.c | 2 + lib/segmentation/orion_discriminant.h | 4 ++ lib/vis/vis.cxx | 70 +++++++++++++++++++ lib/vis/vis.hxx | 47 +++++++++++++ 5 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 lib/vis/vis.cxx create mode 100644 lib/vis/vis.hxx diff --git a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c index 4710572..d5a5fc1 100644 --- a/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c +++ b/lib/kitchen-sink/01_Segmentation/dendrites_main/DiscriminantFunction/compute2D_DiscrimantFunction.c @@ -97,6 +97,7 @@ void orion_compute2D_DiscrimantFunction( /* compute the 2D histogram for edges */ orion_hist3(param, features, non_isolated_instance_indices, discrim); + orion_discriminant_function_display( discrim ); /* normalise the histogram in order to compute the cost function */ orion_normaliseHistogram(param, discrim); @@ -125,7 +126,7 @@ void orion_hist3( /* NOTE: histogram is allocated here: if the size of the bins change * for each dimension, then this will need to change */ - orion_histogram_init( discrim, (param->bins + 1), (param->bins + 1) ); + orion_histogram_init( discrim, param->bins, param->bins ); for( int indices_idx = 0; indices_idx < indices_sz; indices_idx++ ) { size_t feat_instance_idx = array_get_int( indices, indices_idx ); @@ -137,6 +138,10 @@ void orion_hist3( ( cur_feature - discrim->min_value[feat_idx] ) / ( discrim->step_size[feat_idx] ) ); + if( feat_bin_idx[feat_idx] >= discrim->bin_sz[feat_idx] ) { + /* max value goes in the last bin */ + feat_bin_idx[feat_idx] = discrim->bin_sz[feat_idx] - 1; + } } /* increment by 1 */ orion_histogram_increment( discrim, feat_bin_idx[0], feat_bin_idx[1] ); @@ -147,5 +152,14 @@ void orion_normaliseHistogram( orion_segmentation_param* param, orion_discriminant_function* discrim ) { - WARN_UNIMPLEMENTED; + /* parameter for the smoothing of the Histogram */ + pixel_type sigma = 5; + + /* Apply sigmoid function to normalize the volume. Just in case that we + * are not using the multiscale approach */ + for( int hist_idx = 0; hist_idx < orion_histogram_elems(discrim); hist_idx++) { + /* 1 / (1 + exp(-h)) */ + discrim->norm_histogram[hist_idx] = + 1.0 / ( 1.0 + expf( -(discrim->histogram[hist_idx]) ) ); + } } diff --git a/lib/segmentation/orion_discriminant.c b/lib/segmentation/orion_discriminant.c index 09a1bdf..86c509d 100644 --- a/lib/segmentation/orion_discriminant.c +++ b/lib/segmentation/orion_discriminant.c @@ -5,7 +5,9 @@ void orion_histogram_init(orion_discriminant_function* discrim, size_t m, size_t discrim->bin_sz[1] = n; NEW_COUNT(discrim->histogram, size_t, discrim->bin_sz[0] * discrim->bin_sz[1]); + NEW_COUNT(discrim->norm_histogram, pixel_type, discrim->bin_sz[0] * discrim->bin_sz[1]); for( int hist_idx = 0; hist_idx < orion_histogram_elems(discrim); hist_idx++ ) { discrim->histogram[hist_idx] = 0; + discrim->norm_histogram[hist_idx] = 0.0; } } diff --git a/lib/segmentation/orion_discriminant.h b/lib/segmentation/orion_discriminant.h index 422a018..ce48607 100644 --- a/lib/segmentation/orion_discriminant.h +++ b/lib/segmentation/orion_discriminant.h @@ -25,8 +25,12 @@ typedef struct { /* number of bins in each dimension */ size_t bin_sz[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; + /* stores count */ size_t* histogram; /* dimensions: [bin_sz[0], bin_sz[1]] */ + /* histogram after normalisation */ + pixel_type* norm_histogram; /* dimensions: [bin_sz[0], bin_sz[1]] */ + /* store the minimum and maximum value for each feature */ pixel_type min_value[ORION_NUMBER_OF_SEGMENTATION_FEATURES]; diff --git a/lib/vis/vis.cxx b/lib/vis/vis.cxx new file mode 100644 index 0000000..6463143 --- /dev/null +++ b/lib/vis/vis.cxx @@ -0,0 +1,70 @@ +#include "vis.hxx" + +#include + +void _orion_discriminant_function_to_vtkImageData( + orion_discriminant_function* discrim, + vtkImageData* image ) { + + image->SetDimensions(discrim->bin_sz[0], discrim->bin_sz[1], 1); + + uint32_t image_scalar_dim = 1; +#if VTK_MAJOR_VERSION <= 5 + image->SetNumberOfScalarComponents(image_scalar_dim); + image->SetScalarTypeToInt(); + image->AllocateScalars(); +#else + image->AllocateScalars(VTK_INT, image_scalar_dim); +#endif + int* vtkImagePixel = static_cast( image->GetScalarPointer(0,0,0) ); + size_t* orion_disc_bins = discrim->histogram; + size_t hist_nelems = orion_histogram_elems( discrim ); + for(size_t idx = 0; idx < hist_nelems; idx++, orion_disc_bins++, vtkImagePixel += image_scalar_dim ) { + vtkImagePixel[0] = *orion_disc_bins; + } +} + + +void orion_discriminant_function_display( orion_discriminant_function* discrim ) { + vtkSmartPointer colorImage = vtkSmartPointer::New(); + _orion_discriminant_function_to_vtkImageData(discrim, colorImage); + + vtkSmartPointer imageMapper = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 + imageMapper->SetInputConnection(colorImage->GetProducerPort()); +#else + imageMapper->SetInputData(colorImage); +#endif + imageMapper->SetColorWindow(255); + imageMapper->SetColorLevel(127.5); + + vtkSmartPointer imageActor = vtkSmartPointer::New(); + imageActor->SetMapper(imageMapper); + imageActor->SetPosition(20, 20); + + // Setup renderers + vtkSmartPointer renderer = vtkSmartPointer::New(); + + // Setup render window + vtkSmartPointer renderWindow = vtkSmartPointer::New(); + + renderWindow->AddRenderer(renderer); + + // Setup render window interactor + vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New(); + + vtkSmartPointer style = vtkSmartPointer::New(); + + renderWindowInteractor->SetInteractorStyle(style); + + // Render and start interaction + renderWindowInteractor->SetRenderWindow(renderWindow); + + //renderer->AddViewProp(imageActor); + renderer->AddActor2D(imageActor); + + renderWindow->Render(); + renderWindowInteractor->Start(); + + +} diff --git a/lib/vis/vis.hxx b/lib/vis/vis.hxx new file mode 100644 index 0000000..e89d833 --- /dev/null +++ b/lib/vis/vis.hxx @@ -0,0 +1,47 @@ +#ifndef ORION_VIS_H +#define ORION_VIS_H 1 + +/* system headers */ +#include +#include + +#ifdef __cplusplus + /* Need to initialise because we are building without CMake: + * + */ + #include + VTK_MODULE_INIT(vtkRenderingOpenGL); + VTK_MODULE_INIT(vtkInteractionStyle); + VTK_MODULE_INIT(vtkRenderingFreeType); + /*VTK_MODULE_INIT(vtkRenderingFreeTypeOpenGL);*/ + VTK_MODULE_INIT(vtkRenderingVolumeOpenGL); + + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif + +/* local headers */ +#include "segmentation/orion_discriminant.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Function prototypes */ +extern +void orion_discriminant_function_display( orion_discriminant_function* discrim ); + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* ORION_VIS_H */ From 94de3fef2bd0224b3c4960965a9da32e0bf785c1 Mon Sep 17 00:00:00 2001 From: Zakariyya Mughal Date: Fri, 23 Dec 2016 00:18:56 -0600 Subject: [PATCH 54/55] Set up Doxygen --- .gitignore | 1 + Makefile | 7 +- make/Doxyfile | 2489 ++++++++++++++++++++++++++++++++++++++++++++ make/config-dir.mk | 1 + 4 files changed, 2497 insertions(+), 1 deletion(-) create mode 100644 make/Doxyfile diff --git a/.gitignore b/.gitignore index 824f05c..45290a1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ ComputeFilter /.build /.deps /bin +/doxygen-doc *~ *.a diff --git a/Makefile b/Makefile index a82317d..9d1ac78 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ CONFIG_HEADER_FILE := $(LIBDIR)/config/config.h $(CONFIG_HEADER_FILE): $(BIN_BIN_CONFIG.c) $(BIN_BIN_CONFIG.c) > $@ -.PHONY: tags +.PHONY: tags $(DOXYGENDIR) ifdef PROD DEV_TARGETS := @@ -78,6 +78,7 @@ clean: -find . -type f -name '*.o' -delete -find . -type f \( -name '*.gcda' -o -name '*.gcno' -o -name '*.gcov' \) -delete -rm -Rf $(OUTPUT_DIRS) + -rm -Rf $(DOXYGENDIR) -rm -Rf $(ITK_CONFIG_MK) -rm -Rf $(GCOVDIR) $(LCOVDIR) -rm -Rf $(CONFIG_HEADER_FILE) @@ -90,6 +91,10 @@ include make/00-implicit-rules.mk -include $(LIB_SRC.c:$(LIBDIR)/%.c=$(DEPDIR)/$(LIBDIR)/%.P) -include $(TEST.c:$(TESTDIR)/%.c=$(DEPDIR)/$(TESTDIR)/%.P) +doc: $(DOXYGENDIR) + +$(DOXYGENDIR): make/Doxyfile + doxygen $< tags: ctags --exclude=external -R . # add the ORION 3 code to the tags so that it is easy to jump to the other codebase diff --git a/make/Doxyfile b/make/Doxyfile new file mode 100644 index 0000000..ad0ca80 --- /dev/null +++ b/make/Doxyfile @@ -0,0 +1,2489 @@ +# Doxyfile 1.8.12 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "My Project" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 0. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 0 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f \ + *.for \ + *.tcl \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /