Doxygen Source Code Documentation
1dcat.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Defines | |
#define | MAXIM 1024 |
Functions | |
int | main (int argc, char *argv[]) |
Define Documentation
|
|
Function Documentation
|
convert three sub-briks to a raw dataset with consecutive triplets Definition at line 11 of file 1dcat.c. References AFNI_yesenv(), argc, far, machdep(), malloc, MRI_FLOAT_PTR, mri_free(), mri_read_1D(), mri_read_ascii_ragged(), mri_transpose(), MRI_IMAGE::nx, MRI_IMAGE::ny, and TS_HELP_STRING.
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 } |