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  

nidset.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 int main( int argc , char *argv[] )
00004 {
00005    THD_3dim_dataset *dset ;
00006    NI_group *ngr ;
00007    NI_stream ns ;
00008    int ct , ii ;
00009 
00010    if( argc < 3 || strcmp(argv[1],"-help") == 0 ){
00011      printf("Usage: nidset tcp:host:53212 dataset\n"); exit(0);
00012    }
00013 
00014    ns = NI_stream_open( argv[1] , "w" ) ;
00015    if( ns == NULL ){
00016      fprintf(stderr,"** Can't open stream '%s'\n",argv[1]); exit(1);
00017    }
00018 
00019    dset = THD_open_dataset( argv[2] ) ;
00020    if( dset == NULL ){
00021      fprintf(stderr,"** Can't open dataset '%s'\n",argv[2]); exit(1);
00022    }
00023    DSET_load(dset) ;
00024    if( !DSET_LOADED(dset) ){
00025      fprintf(stderr,"** Can't load dataset '%s'\n",argv[2]); exit(1);
00026    }
00027    ngr = THD_dataset_to_niml(dset) ;
00028    if( ngr == NULL ){
00029      fprintf(stderr,"** Can't convert dataset to NIML\n"); exit(1);
00030    }
00031 
00032    while(1){
00033      ii = NI_stream_writecheck( ns , 666 ) ;
00034      if( ii == 1 ){ fprintf(stderr,"!READY!\n") ; break ; }
00035      if( ii <  0 ){ fprintf(stderr,"BAD writecheck\n"); exit(1); }
00036      fprintf(stderr,".") ;
00037    }
00038 
00039    ct = NI_clock_time() ;
00040    NI_write_element( ns , ngr , NI_BINARY_MODE ) ;
00041    NI_stream_close( ns ) ;
00042    ct = NI_clock_time() - ct ;
00043    fprintf(stderr,"++ Wrote element in %d ms\n",ct) ;
00044    exit(0) ;
00045 }
 

Powered by Plone

This site conforms to the following standards: