Mercurial > hg > minc-tools
changeset 997:1631ee70f0d3
check_in_all
author | david <david> |
---|---|
date | Wed, 10 Apr 1996 17:19:37 +0000 |
parents | cb16b26212ea |
children | 390e1f4af608 |
files | volume_io/Geometry/gaussian.c volume_io/Include/volume_io/basic.h volume_io/MNI_formats/tag_points.c volume_io/Prog_utils/files.c volume_io/Volumes/multidim_arrays.c volume_io/Volumes/volume_cache.c volume_io/Volumes/volumes.c |
diffstat | 7 files changed, 51 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/volume_io/Geometry/gaussian.c +++ b/volume_io/Geometry/gaussian.c @@ -60,6 +60,13 @@ if( ABS(a[i][j]) > s[i] ) s[i] = ABS(a[i][j]); } + + if( s[i] == 0.0 ) + { + FREE( s ); + + return( FALSE ); + } } success = TRUE; @@ -95,12 +102,21 @@ for_less( j, i+1, n ) { + if( a[row[i]][i] == 0.0 ) + { + success = FALSE; + break; + } + m = a[row[j]][i] / a[row[i]][i]; for_less( k, i+1, n ) a[row[j]][k] -= m * a[row[i]][k]; for_less( v, 0, n_values ) solution[row[j]][v] -= m * solution[row[i]][v]; } + + if( !success ) + break; } if( success && a[row[n-1]][n-1] == 0.0 )
--- a/volume_io/Include/volume_io/basic.h +++ b/volume_io/Include/volume_io/basic.h @@ -29,7 +29,7 @@ ---------------------------------------------------------------------------- */ #ifndef lint -static char basic_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/basic.h,v 1.25 1995-12-19 15:47:12 david Exp $"; +static char basic_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/basic.h,v 1.26 1996-04-10 17:19:38 david Exp $"; #endif #include <stdlib.h> @@ -130,17 +130,11 @@ #define IS_INT( x ) ((double) (x) == (double) ((int) (x))) -#define FLOOR( x ) (((x) < 0.0) ? ((IS_INT(x) ? (int) (x) : (int) (x) - 1)) \ - : (int) (x) ) - -#define ROUND( x ) FLOOR( (x) + 0.5 ) +#define FLOOR( x ) ((int) floor(x)) -#define POSITIVE_ROUND( x ) ((int)( (x) + 0.5 )) +#define ROUND( x ) FLOOR( (double) (x) + 0.5 ) -#define CEILING( x ) ( IS_INT(x) ? \ - ((int) (x)) : \ - ((x) < 0.0 ? (int)(x) : ((int) (x)+1)) \ - ) +#define CEILING( x ) ((int) ceil(x)) #define FRACTION( x ) ((x) - FLOOR(x))
--- a/volume_io/MNI_formats/tag_points.c +++ b/volume_io/MNI_formats/tag_points.c @@ -15,7 +15,7 @@ #include <internal_volume_io.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/tag_points.c,v 1.19 1995-11-10 20:23:19 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/MNI_formats/tag_points.c,v 1.20 1996-04-10 17:19:44 david Exp $"; #endif static const char *TAG_FILE_HEADER = "MNI Tag Point File"; @@ -216,6 +216,8 @@ @CALLS : @CREATED : 1993 David MacDonald @MODIFIED : Oct. 19, 1995 D. MacDonald, now calls the 1 at a time routine +@MODIFIED : Apr. 1, 1996 D. MacDonald, fixed bug of passing non-null + tags_volume2 with n_volumes==1 ---------------------------------------------------------------------------- */ public Status output_tag_points( @@ -240,8 +242,8 @@ for( i = 0; i < n_tag_points; ++i ) { status = output_one_tag( file, n_volumes, - tags_volume1 == NULL ? NULL : tags_volume1[i], - tags_volume2 == NULL ? NULL : tags_volume2[i], + tags_volume1[i], + (n_volumes == 1) ? NULL : tags_volume2[i], weights == NULL ? NULL : &weights[i], structure_ids == NULL ? NULL : &structure_ids[i], patient_ids == NULL ? NULL : &patient_ids[i],
--- a/volume_io/Prog_utils/files.c +++ b/volume_io/Prog_utils/files.c @@ -19,7 +19,7 @@ #include <errno.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Prog_utils/files.c,v 1.30 1996-04-10 13:34:49 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Prog_utils/files.c,v 1.31 1996-04-10 17:19:39 david Exp $"; #endif private BOOLEAN has_no_extension( STRING ); @@ -828,14 +828,18 @@ --slash_index; if( slash_index < 0 ) + directory = create_string( "." ); + else + { ++slash_index; - directory = alloc_string( slash_index ); + directory = alloc_string( slash_index ); - for_less( i, 0, slash_index ) - directory[i] = expanded[i]; + for_less( i, 0, slash_index ) + directory[i] = expanded[i]; - directory[slash_index] = END_OF_STRING; + directory[slash_index] = END_OF_STRING; + } delete_string( expanded );
--- a/volume_io/Volumes/multidim_arrays.c +++ b/volume_io/Volumes/multidim_arrays.c @@ -17,7 +17,7 @@ #include <float.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/multidim_arrays.c,v 1.10 1996-02-28 16:04:00 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/multidim_arrays.c,v 1.11 1996-04-10 17:19:42 david Exp $"; #endif /* ----------------------------- MNI Header ----------------------------------- @@ -376,7 +376,7 @@ BOOLEAN use_src_order ) { char *src_ptr, *dest_ptr; - int i, d; + int d; int dest_offsets[MAX_DIMENSIONS], src_offsets[MAX_DIMENSIONS]; int dest_offset0, dest_offset1, dest_offset2, dest_offset3; int dest_offset4;
--- a/volume_io/Volumes/volume_cache.c +++ b/volume_io/Volumes/volume_cache.c @@ -13,7 +13,7 @@ ---------------------------------------------------------------------------- */ #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volume_cache.c,v 1.23 1996-03-14 15:51:42 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volume_cache.c,v 1.24 1996-04-10 17:19:43 david Exp $"; #endif #include <internal_volume_io.h> @@ -148,7 +148,7 @@ @MODIFIED : ---------------------------------------------------------------------------- */ -private int get_default_max_bytes_in_cache() +public int get_default_max_bytes_in_cache() { int n_bytes; @@ -694,11 +694,11 @@ for_less( d, 0, get_volume_n_dimensions(volume) ) { - if( block_sizes[d] >= 1 ) - { - if( cache->block_sizes[d] != block_sizes[d] ) - changed = TRUE; - } + if( block_sizes[d] < 1 || block_sizes[d] > sizes[d] ) + block_sizes[d] = sizes[d]; + + if( cache->block_sizes[d] != block_sizes[d] ) + changed = TRUE; } /*--- if the block sizes have not changed, do nothing */ @@ -716,12 +716,7 @@ } for_less( d, 0, get_volume_n_dimensions(volume) ) - { - if( block_sizes[d] < 1 || block_sizes[d] > sizes[d] ) - cache->block_sizes[d] = sizes[d]; - else - cache->block_sizes[d] = block_sizes[d]; - } + cache->block_sizes[d] = block_sizes[d]; alloc_volume_cache( cache, volume ); }
--- a/volume_io/Volumes/volumes.c +++ b/volume_io/Volumes/volumes.c @@ -17,7 +17,7 @@ #include <float.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volumes.c,v 1.61 1996-02-28 16:03:57 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volumes.c,v 1.62 1996-04-10 17:19:41 david Exp $"; #endif STRING XYZ_dimension_names[] = { MIxspace, MIyspace, MIzspace }; @@ -591,6 +591,7 @@ Volume volume, General_transform *transform ) { + Real sign; int c, axis; Vector axes[N_DIMENSIONS]; Transform *linear_transform; @@ -609,9 +610,12 @@ for_less( c, 0, N_DIMENSIONS ) { axis = volume->spatial_axes[c]; + if( volume->separations[axis] < 0.0 ) + sign = -1.0; + else + sign = 1.0; if( axis >= 0 ) - volume->separations[axis] = SIGN( volume->separations[axis] ) * - MAGNITUDE( axes[c] ); + volume->separations[axis] = sign * MAGNITUDE( axes[c] ); } } }