Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

transform_io.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 00013 ---------------------------------------------------------------------------- */ 00014 00015 #include <volume_io/internal_volume_io.h> 00016 #include <bicpl/trans.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Transforms/transform_io.c,v 1.8 2000/02/06 15:30:51 stever Exp $"; 00020 #endif 00021 00022 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : write_transform_file 00024 @INPUT : filename 00025 comments 00026 transform 00027 @OUTPUT : 00028 @RETURNS : OK or ERROR 00029 @DESCRIPTION: Writes the specified transform to the file, in MNI format. 00030 @METHOD : 00031 @GLOBALS : 00032 @CALLS : 00033 @CREATED : 1993 David MacDonald 00034 @MODIFIED : 00035 ---------------------------------------------------------------------------- */ 00036 00037 public Status write_transform_file( 00038 STRING filename, 00039 STRING comments, 00040 Transform *transform ) 00041 { 00042 Status status; 00043 FILE *file; 00044 General_transform gen_transform; 00045 00046 create_linear_transform( &gen_transform, transform ); 00047 00048 status = open_file_with_default_suffix( filename, "xfm", 00049 WRITE_FILE, ASCII_FORMAT, &file ); 00050 00051 if( status == OK ) 00052 { 00053 status = output_transform( file, filename, NULL, comments, 00054 &gen_transform ); 00055 00056 (void) close_file( file ); 00057 } 00058 00059 delete_general_transform( &gen_transform ); 00060 00061 return( status ); 00062 } 00063 00064 /* ----------------------------- MNI Header ----------------------------------- 00065 @NAME : read_transform_file 00066 @INPUT : filename 00067 @OUTPUT : transform 00068 @RETURNS : OK or ERROR 00069 @DESCRIPTION: Reads a transform from a file. 00070 @METHOD : 00071 @GLOBALS : 00072 @CALLS : 00073 @CREATED : 1993 David MacDonald 00074 @MODIFIED : 00075 ---------------------------------------------------------------------------- */ 00076 00077 public Status read_transform_file( 00078 STRING filename, 00079 Transform *transform ) 00080 { 00081 Status status; 00082 FILE *file; 00083 Transform *lin_trans; 00084 General_transform gen_transform; 00085 00086 status = open_file_with_default_suffix( filename, "xfm", 00087 READ_FILE, ASCII_FORMAT, &file ); 00088 00089 if( status == OK ) 00090 { 00091 if( input_transform( file, filename, &gen_transform ) != OK ) 00092 status = ERROR; 00093 00094 (void) close_file( file ); 00095 } 00096 00097 if( status == OK && get_transform_type(&gen_transform) != LINEAR ) 00098 { 00099 print( "File %s does not contain a linear transform.\n", filename ); 00100 status = ERROR; 00101 } 00102 00103 if( status == OK ) 00104 { 00105 lin_trans = get_linear_transform_ptr( &gen_transform ); 00106 *transform = *lin_trans; 00107 } 00108 00109 delete_general_transform( &gen_transform ); 00110 00111 return( status ); 00112 }

Generated on Wed Jul 28 09:10:58 2004 for BICPL by doxygen 1.3.7