Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

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    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
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    /*-- help? --*/
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    /* read input files */
00033 
00034    nim = argc-1 ;
00035    inim = (MRI_IMAGE **) malloc( sizeof(MRI_IMAGE *) * nim ) ;
00036    for( jj=0 ; jj < nim ; jj++ ){
00037 #if 0                                   /** for testing only **/
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 }
 

Powered by Plone

This site conforms to the following standards: