Mercurial > hg > minc-tools
changeset 1014:abc2e561fd95
check_in_all
author | david <david> |
---|---|
date | Mon, 09 Dec 1996 20:20:17 +0000 |
parents | 340c11f86adb |
children | 6f88b68afde4 |
files | volume_io/Documentation/volume_io.tex volume_io/Include/volume_io/volume.h volume_io/Volumes/input_mnc.c volume_io/Volumes/output_mnc.c volume_io/Volumes/volumes.c |
diffstat | 5 files changed, 145 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/volume_io/Documentation/volume_io.tex +++ b/volume_io/Documentation/volume_io.tex @@ -2195,6 +2195,35 @@ world axis (0.0, 1.0, 1.0) normalized to unit length, then scaled by the volume separation for the second volume dimension.} +{\bf\begin{verbatim} +public void get_volume_direction_cosine( + Volume volume, + int dimension, + Real dir[] ) +\end{verbatim}} + +\desc{Passes back the real world axis for a specific voxel dimension. Note +that \name{dimension} must be a spatial dimension in the volume.} + +{\bf\begin{verbatim} +public void set_volume_space_name( + Volume volume, + STRING name ) +\end{verbatim}} + +\desc{Sets the coordinate system type of the volume in terms of a string +name. This can be any string, but a set of defined constants is given by +MINC: \name{MI\_NATIVE}, \name{MI\_TALAIRACH}, and \name{MI\_CALLOSAL}.} + +{\bf\begin{verbatim} +public STRING get_volume_space_name( + Volume volume ) +\end{verbatim}} + +\desc{Returns a copy of the coordinate system type of the volume in terms of +a string name. The calling function must free this string when finished with +it.} + \subsection{Copying Volumes} Another method of creating a volume is to simply copy the entire
--- a/volume_io/Include/volume_io/volume.h +++ b/volume_io/Include/volume_io/volume.h @@ -16,7 +16,7 @@ ---------------------------------------------------------------------------- */ #ifndef lint -static char volume_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/volume.h,v 1.47 1996-11-15 16:09:42 david Exp $"; +static char volume_rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Include/volume_io/volume.h,v 1.48 1996-12-09 20:20:23 david Exp $"; #endif /* ----------------------------- MNI Header ----------------------------------- @@ -53,6 +53,8 @@ #define ANY_SPATIAL_DIMENSION "any_spatial_dimension" +#define MI_UNKNOWN_SPACE "unknown___" + typedef struct { BOOLEAN is_cached_volume; @@ -79,6 +81,8 @@ Real world_space_for_translation_voxel[N_DIMENSIONS]; General_transform voxel_to_world_transform; + + STRING coordinate_system_name; } volume_struct; typedef volume_struct *Volume;
--- a/volume_io/Volumes/input_mnc.c +++ b/volume_io/Volumes/input_mnc.c @@ -16,7 +16,7 @@ #include <minc.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/input_mnc.c,v 1.55 1996-11-15 16:09:45 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/input_mnc.c,v 1.56 1996-12-09 20:20:26 david Exp $"; #endif #define INVALID_AXIS -1 @@ -91,7 +91,7 @@ @GLOBALS : @CALLS : @CREATED : 1993 David MacDonald -@MODIFIED : +@MODIFIED : Nov. 15, 1996 D. MacDonald - added handling of space type ---------------------------------------------------------------------------- */ public Minc_file initialize_minc_input_from_minc_id( @@ -107,10 +107,12 @@ BOOLEAN min_voxel_found, max_voxel_found, range_specified; double valid_range[2], temp; long long_size, mindex[MAX_VAR_DIMS]; - BOOLEAN converted_sign; + BOOLEAN converted_sign, space_type_consensus; nc_type converted_type; - char signed_flag[MI_MAX_ATTSTR_LEN+1]; + char signed_flag[MI_MAX_ATTSTR_LEN+1], *ptr; char dim_name[MI_MAX_ATTSTR_LEN+1]; + char prev_space_type[MI_MAX_ATTSTR_LEN+1]; + char space_type[MI_MAX_ATTSTR_LEN+1]; nc_type file_datatype; int sizes[MAX_VAR_DIMS]; double file_separations[MAX_VAR_DIMS]; @@ -289,6 +291,9 @@ /* --- get the spatial axis info, slice separation, start pos, etc. */ + prev_space_type[0] = (char) 0; + space_type_consensus = TRUE; + for_less( d, 0, file->n_file_dimensions ) { file_separations[d] = 1.0; @@ -323,6 +328,22 @@ dir_cosines[d][1] = tmp_cosines[1]; dir_cosines[d][2] = tmp_cosines[2]; } + + ptr = miattgetstr( file->cdfid, dimvar, MIspacetype, + MI_MAX_ATTSTR_LEN+1, space_type ); + + if( ptr != NULL ) + { + if( string_length( prev_space_type ) > 0 && + string_length( space_type ) > 0 && + !equal_strings( prev_space_type, space_type ) ) + { + space_type_consensus = FALSE; + } + + if( string_length( space_type ) > 0 ) + (void) strcpy( prev_space_type, space_type ); + } } } @@ -338,6 +359,9 @@ } } + if( space_type_consensus ) + set_volume_space_type( volume, prev_space_type ); + /* --- create the file world transform */ fill_Point( origin, 0.0, 0.0, 0.0 );
--- a/volume_io/Volumes/output_mnc.c +++ b/volume_io/Volumes/output_mnc.c @@ -16,7 +16,7 @@ #include <minc.h> #ifndef lint -static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.47 1996-11-15 16:09:47 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/output_mnc.c,v 1.48 1996-12-09 20:20:29 david Exp $"; #endif #define INVALID_AXIS -1 @@ -73,6 +73,7 @@ /* ----------------------------- MNI Header ----------------------------------- @NAME : output_world_transform @INPUT : file + space_type voxel_to_world_transform @OUTPUT : @RETURNS : OK or ERROR @@ -82,11 +83,12 @@ @GLOBALS : @CALLS : @CREATED : Oct. 24, 1995 David MacDonald -@MODIFIED : +@MODIFIED : Nov. 15, 1996 D. MacDonald - added handling of space type ---------------------------------------------------------------------------- */ private Status output_world_transform( Minc_file file, + STRING space_type, General_transform *voxel_to_world_transform ) { double separation[MAX_VAR_DIMS]; @@ -171,6 +173,11 @@ NC_DOUBLE, N_DIMENSIONS, dir_cosines[axis]); } (void) miattputstr( file->cdfid, file->dim_ids[d], MIunits, UNITS ); + if( !equal_strings( space_type, MI_UNKNOWN_SPACE ) ) + { + (void) miattputstr( file->cdfid, file->dim_ids[d], MIspacetype, + space_type ); + } } else file->dim_ids[d] = -1; @@ -204,7 +211,7 @@ @GLOBALS : @CALLS : @CREATED : 1993 David MacDonald -@MODIFIED : +@MODIFIED : Nov. 15, 1996 D. MacDonald - added handling of space type ---------------------------------------------------------------------------- */ public Minc_file initialize_minc_output( @@ -367,8 +374,8 @@ (long) sizes[d] ); } - if( output_world_transform( file, voxel_to_world_transform ) - != OK ) + if( output_world_transform( file, volume_to_attach->coordinate_system_name, + voxel_to_world_transform ) != OK ) { FREE( file ); return( NULL );
--- 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.64 1996-11-15 16:09:46 david Exp $"; +static char rcsid[] = "$Header: /private-cvsroot/minc/volume_io/Volumes/volumes.c,v 1.65 1996-12-09 20:20:27 david Exp $"; #endif STRING XYZ_dimension_names[] = { MIxspace, MIyspace, MIzspace }; @@ -134,8 +134,8 @@ @METHOD : @GLOBALS : @CALLS : -@CREATED : June, 1993 David MacDonald -@MODIFIED : +@CREATED : June, 1993 David MacDonald +@MODIFIED : Nov. 15, 1996 D. MacDonald - handles space type ---------------------------------------------------------------------------- */ public Volume create_volume( @@ -214,6 +214,8 @@ make_identity_transform( &identity ); create_linear_transform( &volume->voxel_to_world_transform, &identity ); + volume->coordinate_system_name = create_string( MI_UNKNOWN_SPACE ); + return( volume ); } @@ -459,7 +461,7 @@ @GLOBALS : @CALLS : @CREATED : June, 1993 David MacDonald -@MODIFIED : +@MODIFIED : Nov. 15, 1996 D. MacDonald - handles space type ---------------------------------------------------------------------------- */ public void delete_volume( @@ -480,6 +482,8 @@ for_less( d, 0, get_volume_n_dimensions(volume) ) delete_string( volume->dimension_names[d] ); + delete_string( volume->coordinate_system_name ); + FREE( volume ); } @@ -850,6 +854,50 @@ } /* ----------------------------- MNI Header ----------------------------------- +@NAME : get_volume_space_type +@INPUT : volume +@OUTPUT : +@RETURNS : +@DESCRIPTION: Returns a copy of the string representing the volume coordinate + system name. The calling function must delete_string() the + value when done. +@METHOD : +@GLOBALS : +@CALLS : +@CREATED : Nov. 15, 1996 David MacDonald +@MODIFIED : +---------------------------------------------------------------------------- */ + +public STRING get_volume_space_type( + Volume volume ) +{ + return( create_string( volume->coordinate_system_name ) ); +} + +/* ----------------------------- MNI Header ----------------------------------- +@NAME : set_volume_space_type +@INPUT : volume + name +@OUTPUT : +@RETURNS : +@DESCRIPTION: Copies the name into the volume's coordinate system name. + Copies the string, rather than just the pointer. +@METHOD : +@GLOBALS : +@CALLS : +@CREATED : Nov. 15, 1996 David MacDonald +@MODIFIED : +---------------------------------------------------------------------------- */ + +public void set_volume_space_type( + Volume volume, + STRING name ) +{ + delete_string( volume->coordinate_system_name ); + volume->coordinate_system_name = create_string( name ); +} + +/* ----------------------------- MNI Header ----------------------------------- @NAME : get_volume_separations @INPUT : volume @OUTPUT : separations @@ -1026,6 +1074,21 @@ recompute_world_transform( volume ); } +/* ----------------------------- MNI Header ----------------------------------- +@NAME : get_volume_direction_cosine +@INPUT : volume + axis +@OUTPUT : dir +@RETURNS : +@DESCRIPTION: Passes back the direction cosine corresponding to the given + voxel axis, which must be a spatial dimension. +@METHOD : +@GLOBALS : +@CALLS : +@CREATED : Nov. 15, 1996 David MacDonald +@MODIFIED : +---------------------------------------------------------------------------- */ + public void get_volume_direction_cosine( Volume volume, int axis, @@ -1036,7 +1099,7 @@ if( axis < 0 || axis >= get_volume_n_dimensions(volume) ) { print_error( - "get_volume_direction_cosine: cannot set dir cosine for axis %d\n", + "get_volume_direction_cosine: cannot get dir cosine for axis %d\n", axis ); return; } @@ -1663,7 +1726,7 @@ @GLOBALS : @CALLS : @CREATED : 1993 David MacDonald -@MODIFIED : +@MODIFIED : Nov. 15, 1996 D. MacDonald - handles space type ---------------------------------------------------------------------------- */ public Volume copy_volume_definition_no_alloc( @@ -1710,6 +1773,8 @@ set_voxel_to_world_transform( copy, &transform ); + set_volume_space_type( copy, volume->coordinate_system_name ); + return( copy ); }