Doxygen Source Code Documentation
colari.c File Reference
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
Function Documentation
|
convert DTIStudio fiber format data to SUMA segment data Definition at line 4 of file colari.c. References argc, and strtod().
00005 { 00006 int ii , iarg ; 00007 int xx,yy,zz ; 00008 float fx,fy,fz ; 00009 float sx,ax , sy,ay, sz,az ; 00010 int truncate = 0 ; 00011 00012 if( argc < 7 ){ 00013 fprintf(stderr, 00014 "Usage: colari [-int] sx ax sy ay sz ax < input > output\n" 00015 "where output x = sx * (input x) + ax, etc\n" 00016 " -int --> truncate results to integers\n" ) ; 00017 exit(0) ; 00018 } 00019 00020 iarg = 1 ; 00021 if( strncmp(argv[iarg],"-int",4) == 0 ){ 00022 truncate = 1 ; 00023 iarg++ ; 00024 } 00025 00026 if( iarg+6 > argc ){ 00027 fprintf(stderr,"Not enough arguments! Try colari -help.\n") ; 00028 exit(-1) ; 00029 } 00030 00031 sx = strtod( argv[iarg++] , NULL ) ; 00032 ax = strtod( argv[iarg++] , NULL ) ; 00033 sy = strtod( argv[iarg++] , NULL ) ; 00034 ay = strtod( argv[iarg++] , NULL ) ; 00035 sz = strtod( argv[iarg++] , NULL ) ; 00036 az = strtod( argv[iarg++] , NULL ) ; 00037 00038 if( sx==0.0 || sy==0.0 || sz==0.0 ){ 00039 fprintf(stderr,"Illegal command line!\n") ; 00040 exit(-1) ; 00041 } else { 00042 fprintf(stderr,"sx=%g ax=%g sy=%g ay=%g sz=%g az=%g\n", 00043 sx,ax,sy,ay,sz,az ) ; 00044 } 00045 00046 do { 00047 00048 ii = fscanf( stdin , " %f %f %f" , &fx,&fy,&fz ) ; 00049 if( ii != 3 ) break ; 00050 00051 fx = sx*fx + ax ; 00052 fy = sy*fy + ay ; 00053 fz = sz*fz + az ; 00054 00055 if( truncate ){ 00056 xx = fx ; yy = fy ; zz = fz ; 00057 fprintf( stdout , "%d %d %d\n" , xx,yy,zz ) ; 00058 } else { 00059 fprintf( stdout , "%g %g %g\n" , fx,fy,fz ) ; 00060 } 00061 } while(1) ; 00062 exit(0) ; 00063 } |