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  

nimel.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 int main( int argc , char *argv[] )
00004 {
00005    int nfl , ii , ct ;
00006    char *sspec ;
00007    NI_element *nel ;
00008    NI_stream ns ;
00009    float *flar ;
00010 
00011    if( argc < 3 || strcmp(argv[1],"-help") == 0 ){
00012      printf("Usage: nimel N streamspec\n") ; exit(0) ;
00013    }
00014 
00015    nfl = strtol( argv[1] , NULL , 10) ;
00016    if( nfl < 1 ) nfl = 100000 ;
00017    sspec = argv[2] ;
00018    ns = NI_stream_open( sspec , "w" ) ;
00019    if( ns == NULL ){
00020      fprintf(stderr,"NI_stream_open fails\n"); exit(1);
00021    }
00022 
00023    nel = NI_new_data_element( "Tester" , nfl ) ;
00024    flar = (float *)malloc(sizeof(float)*nfl) ;
00025    for( ii=0 ; ii < nfl ; ii++ ) flar[ii] = (float)ii ;
00026    NI_add_column( nel , NI_FLOAT , flar ) ;
00027    free((void *)flar) ;
00028 
00029    while(1){
00030      ii = NI_stream_writecheck( ns , 666 ) ;
00031      if( ii == 1 ){ fprintf(stderr,"!\n") ; break ; }
00032      if( ii <  0 ){ fprintf(stderr,"BAD writecheck\n"); exit(1); }
00033      fprintf(stderr,".") ;
00034    }
00035 
00036    ct = NI_clock_time() ;
00037    NI_write_element( ns , nel , NI_BINARY_MODE ) ;
00038    NI_stream_closenow( ns ) ;
00039    ct = NI_clock_time() - ct ;
00040    fprintf(stderr,"Wrote %d floats in %d ms\n",nfl,ct) ;
00041    exit(0) ;
00042 }
 

Powered by Plone

This site conforms to the following standards: