Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
1dtranspose.c
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "mrilib.h"
00008 
00009 int main( int argc , char * argv[] )
00010 {
00011    MRI_IMAGE * inim ;
00012 
00013    
00014 
00015    if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00016      printf(
00017        "Usage: 1dtranspose infile outfile\n"
00018        "where infile is an AFNI *.1D file (ASCII list of numbers arranged\n"
00019        "in columns); outfile will be a similar file, but transposed.\n"
00020        "You can use a column subvector selector list on infile, as in\n"
00021        "  1dtranspose 'fred.1D[0,3,7]' ethel.1D\n"
00022        "\n"
00023        "* This program may produce files with lines longer than a\n"
00024        "   text editor can handle.\n"
00025        "* If 'outfile' is '-' (or missing entirely), output goes to stdout.\n"
00026      ) ;
00027      exit(0) ;
00028    }
00029 
00030    machdep() ;
00031 
00032    if( argc > 2 && !THD_filename_ok(argv[2]) ){
00033       fprintf(stderr,"** Illegal output filename!\n"); exit(1);
00034    }
00035    if( argc > 2 && strcmp(argv[2],"-") != 0 && THD_is_file(argv[2]) ){
00036       fprintf(stderr,"** Output file already exists!\n"); exit(1);
00037    }
00038 
00039    
00040 
00041    inim = mri_read_1D( argv[1] ) ;
00042    if( inim == NULL ){
00043      fprintf(stderr,"** Can't read input file!\n"); exit(1);
00044    }
00045 
00046    mri_write_ascii( (argc>2) ? argv[2] : "-" , inim ) ;
00047    exit(0) ;
00048 }