Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
1dcat.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "mrilib.h"
00008
00009 #define MAXIM 1024
00010
00011 int main( int argc , char * argv[] )
00012 {
00013 int nim , ii , jj , kk , nx ;
00014 MRI_IMAGE ** inim ;
00015 float * far ;
00016
00017
00018
00019 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00020 printf("Usage: 1dcat a.1D b.1D ...\n"
00021 "where each file a.1D, b.1D, etc. is an ASCII file of numbers\n"
00022 "arranged in rows and columns.\n"
00023 "The row-by-row catenation of these files is written to stdout.\n"
00024 "\n"
00025 TS_HELP_STRING
00026 ) ;
00027 exit(0) ;
00028 }
00029
00030 machdep() ;
00031
00032
00033
00034 nim = argc-1 ;
00035 inim = (MRI_IMAGE **) malloc( sizeof(MRI_IMAGE *) * nim ) ;
00036 for( jj=0 ; jj < nim ; jj++ ){
00037 #if 0
00038 if( AFNI_yesenv("ragged") ){
00039 MRI_IMAGE *qim ;
00040 qim = mri_read_ascii_ragged( argv[jj+1] , 3.e+33 ) ;
00041 inim[jj] = mri_transpose(qim) ; mri_free(qim) ;
00042 } else
00043 #endif
00044 inim[jj] = mri_read_1D( argv[jj+1] ) ;
00045 if( inim[jj] == NULL ){
00046 fprintf(stderr,"** Can't read input file %s\n",argv[jj+1]) ;
00047 exit(1) ;
00048 }
00049 if( jj > 0 && inim[jj]->nx != inim[0]->nx ){
00050 fprintf(stderr,
00051 "** Input file %s doesn't match first file %s in length!\n",
00052 argv[jj+1],argv[1]) ;
00053 exit(1) ;
00054 }
00055 }
00056
00057 nx = inim[0]->nx ;
00058 for( ii=0 ; ii < nx ; ii++ ){
00059 for( jj=0 ; jj < nim ; jj++ ){
00060 far = MRI_FLOAT_PTR(inim[jj]) ;
00061 for( kk=0 ; kk < inim[jj]->ny ; kk++ ){
00062 printf(" %g", far[ii+kk*nx] ) ;
00063 }
00064 }
00065 printf("\n") ;
00066 }
00067
00068 exit(0) ;
00069 }