Doxygen Source Code Documentation
3dbucket.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Defines | |
#define | PROGRAM_NAME "3dbucket" |
#define | LAST_MOD_DATE "30 October 2003" |
#define | NSUBV(id) ( ((int *)BUCK_subv->ar[(id)])[0] ) |
#define | SUBV(id, jj) ( ((int *)BUCK_subv->ar[(id)])[(jj)+1] ) |
#define | DSUB(id) DSET_IN_3DARR(BUCK_dsar,(id)) |
Functions | |
void | BUCK_read_opts (int, char **) |
void | BUCK_Syntax (void) |
int * | BUCK_get_subv (int, char *) |
void | BUCK_read_opts (int argc, char *argv[]) |
int | main (int argc, char *argv[]) |
Variables | |
THD_3dim_dataset_array * | BUCK_dsar = NULL |
XtPointer_array * | BUCK_subv = NULL |
int | BUCK_nvox = -1 |
int | BUCK_dry = 0 |
int | BUCK_verb = 0 |
int | BUCK_type = -1 |
int | BUCK_glue = 0 |
char | BUCK_output_prefix [THD_MAX_PREFIX] = "buck" |
char | BUCK_session [THD_MAX_NAME] = "./" |
Define Documentation
|
Definition at line 58 of file 3dbucket.c. Referenced by main(). |
|
Definition at line 35 of file 3dbucket.c. Referenced by main(). |
|
Definition at line 56 of file 3dbucket.c. |
|
Definition at line 34 of file 3dbucket.c. Referenced by main(). |
|
Definition at line 57 of file 3dbucket.c. |
Function Documentation
|
Definition at line 256 of file 3dbucket.c. References myXtFree, XtMalloc, and XtRealloc. Referenced by BUCK_read_opts().
00257 { 00258 int * subv = NULL ; 00259 int ii , ipos , nout , slen ; 00260 int ibot,itop,istep , nused ; 00261 char * cpt ; 00262 00263 /* Meaningless input? */ 00264 00265 if( nvals < 1 ) return NULL ; 00266 00267 /* No selection list ==> select it all */ 00268 00269 if( str == NULL || str[0] == '\0' ){ 00270 subv = (int *) XtMalloc( sizeof(int) * (nvals+1) ) ; 00271 subv[0] = nvals ; 00272 for( ii=0 ; ii < nvals ; ii++ ) subv[ii+1] = ii ; 00273 return subv ; 00274 } 00275 00276 /* skip initial '[' */ 00277 00278 subv = (int *) XtMalloc( sizeof(int) * 2 ) ; 00279 subv[0] = nout = 0 ; 00280 00281 ipos = 0 ; 00282 if( str[ipos] == '[' ) ipos++ ; 00283 00284 /*** loop through each sub-selector until end of input ***/ 00285 00286 slen = strlen(str) ; 00287 while( ipos < slen && str[ipos] != ']' ){ 00288 00289 /** get starting value **/ 00290 00291 if( str[ipos] == '$' ){ /* special case */ 00292 ibot = nvals-1 ; ipos++ ; 00293 } else { /* decode an integer */ 00294 ibot = strtol( str+ipos , &cpt , 10 ) ; 00295 if( ibot < 0 ){ myXtFree(subv) ; return NULL ; } 00296 if( ibot >= nvals ) ibot = nvals-1 ; 00297 nused = (cpt-(str+ipos)) ; 00298 if( ibot == 0 && nused == 0 ){ myXtFree(subv) ; return NULL ; } 00299 ipos += nused ; 00300 } 00301 00302 /** if that's it for this sub-selector, add one value to list **/ 00303 00304 if( str[ipos] == ',' || str[ipos] == '\0' || str[ipos] == ']' ){ 00305 nout++ ; 00306 subv = (int *) XtRealloc( (char *)subv , sizeof(int) * (nout+1) ) ; 00307 subv[0] = nout ; 00308 subv[nout] = ibot ; 00309 ipos++ ; continue ; /* re-start loop at next sub-selector */ 00310 } 00311 00312 /** otherwise, must have '..' or '-' as next inputs **/ 00313 00314 if( str[ipos] == '-' ){ 00315 ipos++ ; 00316 } else if( str[ipos] == '.' && str[ipos+1] == '.' ){ 00317 ipos++ ; ipos++ ; 00318 } else { 00319 myXtFree(subv) ; return NULL ; 00320 } 00321 00322 /** get ending value for loop now **/ 00323 00324 if( str[ipos] == '$' ){ /* special case */ 00325 itop = nvals-1 ; ipos++ ; 00326 } else { /* decode an integer */ 00327 itop = strtol( str+ipos , &cpt , 10 ) ; 00328 if( itop < 0 ){ myXtFree(subv) ; return NULL ; } 00329 if( itop >= nvals ) itop = nvals-1 ; 00330 nused = (cpt-(str+ipos)) ; 00331 if( itop == 0 && nused == 0 ){ myXtFree(subv) ; return NULL ; } 00332 ipos += nused ; 00333 } 00334 00335 /** set default loop step **/ 00336 00337 istep = (ibot <= itop) ? 1 : -1 ; 00338 00339 /** check if we have a non-default loop step **/ 00340 00341 if( str[ipos] == '(' ){ /* decode an integer */ 00342 ipos++ ; 00343 istep = strtol( str+ipos , &cpt , 10 ) ; 00344 if( istep == 0 ){ myXtFree(subv) ; return NULL ; } 00345 nused = (cpt-(str+ipos)) ; 00346 ipos += nused ; 00347 if( str[ipos] == ')' ) ipos++ ; 00348 } 00349 00350 /** add values to output **/ 00351 00352 for( ii=ibot ; (ii-itop)*istep <= 0 ; ii += istep ){ 00353 nout++ ; 00354 subv = (int *) XtRealloc( (char *)subv , sizeof(int) * (nout+1) ) ; 00355 subv[0] = nout ; 00356 subv[nout] = ii ; 00357 } 00358 00359 /** check if we have a comma to skip over **/ 00360 00361 if( str[ipos] == ',' ) ipos++ ; 00362 00363 } /* end of loop through selector string */ 00364 00365 return subv ; 00366 } |
|
Definition at line 70 of file 3dbucket.c. References ADDTO_3DARR, ADDTO_XTARR, argc, BUCK_dry, BUCK_get_subv(), BUCK_glue, BUCK_nvox, BUCK_output_prefix, BUCK_session, BUCK_type, BUCK_verb, DATABLOCK_MEM_MALLOC, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, DSET_NVALS, FIRST_VIEW_TYPE, HEAD_ANAT_TYPE, HEAD_FUNC_TYPE, ilen, INIT_3DARR, INIT_XTARR, LAST_VIEW_TYPE, MCW_strncpy, THD_dataxes::nxx, THD_dataxes::nyy, THD_dataxes::nzz, THD_force_malloc_type(), THD_MAX_NAME, THD_MAX_PREFIX, THD_open_one_dataset(), and THD_3dim_dataset::type. Referenced by main().
00071 { 00072 int nopt = 1 , ii ; 00073 char dname[THD_MAX_NAME] ; 00074 char subv[THD_MAX_NAME] ; 00075 char * cpt ; 00076 THD_3dim_dataset * dset ; 00077 int * svar ; 00078 char * str; 00079 int ok, ilen, nlen; 00080 00081 INIT_3DARR(BUCK_dsar) ; 00082 INIT_XTARR(BUCK_subv) ; 00083 00084 while( nopt < argc ){ 00085 00086 /**** -prefix prefix ****/ 00087 00088 if( strncmp(argv[nopt],"-prefix",6) == 0 || 00089 strncmp(argv[nopt],"-output",6) == 0 ){ 00090 if (BUCK_glue){ 00091 fprintf(stderr,"-prefix and -glueto options are not compatible\n"); 00092 exit(1) ; 00093 } 00094 nopt++ ; 00095 if( nopt >= argc ){ 00096 fprintf(stderr,"need argument after -prefix!\n") ; exit(1) ; 00097 } 00098 MCW_strncpy( BUCK_output_prefix , argv[nopt++] , THD_MAX_PREFIX ) ; 00099 continue ; 00100 } 00101 00102 /**** -session directory ****/ 00103 00104 if( strncmp(argv[nopt],"-session",6) == 0 ){ 00105 if (BUCK_glue){ 00106 fprintf(stderr, 00107 "-session and -glueto options are not compatible\n"); 00108 exit(1) ; 00109 } 00110 nopt++ ; 00111 if( nopt >= argc ){ 00112 fprintf(stderr,"need argument after -session!\n") ; exit(1) ; 00113 } 00114 MCW_strncpy( BUCK_session , argv[nopt++] , THD_MAX_NAME ) ; 00115 continue ; 00116 } 00117 00118 if( strncmp(argv[nopt],"-dry",3) == 0 ){ 00119 BUCK_dry = BUCK_verb = 1 ; 00120 nopt++ ; continue ; 00121 } 00122 00123 if( strncmp(argv[nopt],"-fbuc",4) == 0 ){ 00124 BUCK_type = HEAD_FUNC_TYPE ; 00125 nopt++ ; continue ; 00126 } 00127 00128 if( strncmp(argv[nopt],"-abuc",4) == 0 ){ 00129 BUCK_type = HEAD_ANAT_TYPE ; 00130 nopt++ ; continue ; 00131 } 00132 00133 if( strncmp(argv[nopt],"-verb",5) == 0 ){ 00134 BUCK_verb = 1 ; 00135 nopt++ ; continue ; 00136 } 00137 00138 if( strncmp(argv[nopt],"-glueto",5) == 0 ){ 00139 if( strncmp(BUCK_output_prefix, "buck", 5) != 0 ){ 00140 fprintf(stderr,"-prefix and -glueto options are not compatible\n"); 00141 exit(1) ; 00142 } 00143 if( strncmp(BUCK_session, "./", 5) != 0 ){ 00144 fprintf(stderr, 00145 "-session and -glueto options are not compatible\n"); 00146 exit(1) ; 00147 } 00148 BUCK_glue = 1 ; 00149 nopt++ ; 00150 if( nopt >= argc ){ 00151 fprintf(stderr,"need argument after -glueto!\n") ; exit(1) ; 00152 } 00153 00154 /*----- Verify that file name ends in View Type -----*/ 00155 ok = 1; 00156 nlen = strlen(argv[nopt]); 00157 if (nlen <= 5) ok = 0; 00158 00159 if (ok) 00160 { 00161 #if 0 /* old code - scan from end, instead */ 00162 00163 for (ilen = 0; ilen < nlen; ilen++) 00164 { 00165 str = argv[nopt] + ilen; 00166 if (str[0] == '+') break; 00167 } 00168 if (ilen == nlen) ok = 0; 00169 #endif 00170 00171 /* scan from end for view type extension, require one char */ 00172 /* 30 Oct 2003 [rickr] */ 00173 for (ilen = nlen - 1; ilen > 0; ilen--) 00174 { 00175 str = argv[nopt] + ilen; 00176 if (str[0] == '+') break; 00177 } 00178 if (ilen == 0) ok = 0; 00179 } 00180 00181 if (ok) 00182 { 00183 str = argv[nopt] + ilen + 1; 00184 00185 for (ii=FIRST_VIEW_TYPE ; ii <= LAST_VIEW_TYPE ; ii++) 00186 if (! strncmp(str,VIEW_codestr[ii],4)) break ; 00187 00188 if( ii > LAST_VIEW_TYPE ) ok = 0; 00189 } 00190 00191 if (! ok) 00192 { 00193 fprintf(stderr, 00194 "File name must end in +orig, +acpc, or +tlrc after -glueto\n"); 00195 exit(1); 00196 } 00197 00198 /*----- Remove View Type from string to make output prefix -----*/ 00199 MCW_strncpy( BUCK_output_prefix , argv[nopt] , ilen+1) ; 00200 00201 /*----- Note: no "continue" statement here. File name will now 00202 be processed as an input dataset -----*/ 00203 } 00204 00205 if( argv[nopt][0] == '-' ){ 00206 fprintf(stderr,"Unknown option: %s\n",argv[nopt]) ; exit(1) ; 00207 } 00208 00209 /**** read dataset ****/ 00210 00211 cpt = strstr(argv[nopt],"[") ; 00212 if( cpt == NULL ){ 00213 strcpy(dname,argv[nopt]) ; 00214 subv[0] = '\0' ; 00215 } else if( cpt == argv[nopt] ){ 00216 fprintf(stderr,"illegal dataset specifier: %s\n",argv[nopt]) ; 00217 exit(1) ; 00218 } else { 00219 ii = cpt - argv[nopt] ; 00220 memcpy(dname,argv[nopt],ii) ; dname[ii] = '\0' ; 00221 strcpy(subv,cpt) ; 00222 } 00223 nopt++ ; 00224 00225 dset = THD_open_one_dataset( dname ) ; 00226 if( dset == NULL ){ 00227 fprintf(stderr,"can't open dataset %s\n",dname) ; exit(1) ; 00228 } 00229 THD_force_malloc_type( dset->dblk , DATABLOCK_MEM_MALLOC ) ; 00230 00231 if( BUCK_type < 0 ) BUCK_type = dset->type ; 00232 00233 ii = dset->daxes->nxx * dset->daxes->nyy * dset->daxes->nzz ; 00234 if( BUCK_nvox < 0 ){ 00235 BUCK_nvox = ii ; 00236 } else if( ii != BUCK_nvox ){ 00237 fprintf(stderr,"dataset %s differs in size from others\n",dname); 00238 exit(1) ; 00239 } 00240 ADDTO_3DARR(BUCK_dsar,dset) ; 00241 00242 svar = BUCK_get_subv( DSET_NVALS(dset) , subv ) ; 00243 if( svar == NULL || svar[0] <= 0 ){ 00244 fprintf(stderr,"can't decipher index codes from %s%s\n",dname,subv) ; 00245 exit(1) ; 00246 } 00247 ADDTO_XTARR(BUCK_subv,svar) ; 00248 00249 } /* end of loop over command line arguments */ 00250 00251 return ; 00252 } |
|
|
|
check if we have a comma to skip over * Definition at line 370 of file 3dbucket.c. Referenced by main().
00371 { 00372 printf( 00373 "Concatenate sub-bricks from input datasets into one big\n" 00374 "'bucket' dataset.\n" 00375 "Usage: 3dbucket options\n" 00376 "where the options are:\n" 00377 ) ; 00378 00379 printf( 00380 " -prefix pname = Use 'pname' for the output dataset prefix name.\n" 00381 " OR -output pname [default='buck']\n" 00382 "\n" 00383 " -session dir = Use 'dir' for the output dataset session directory.\n" 00384 " [default='./'=current working directory]\n" 00385 " -glueto fname = Append bricks to the end of the 'fname' dataset.\n" 00386 " This command is an alternative to the -prefix \n" 00387 " and -session commands. \n" 00388 " -dry = Execute a 'dry run'; that is, only print out\n" 00389 " what would be done. This is useful when\n" 00390 " combining sub-bricks from multiple inputs.\n" 00391 " -verb = Print out some verbose output as the program\n" 00392 " proceeds (-dry implies -verb).\n" 00393 " -fbuc = Create a functional bucket.\n" 00394 " -abuc = Create an anatomical bucket. If neither of\n" 00395 " these options is given, the output type is\n" 00396 " determined from the first input type.\n" 00397 "\n" 00398 "Command line arguments after the above are taken as input datasets.\n" 00399 "A dataset is specified using one of these forms:\n" 00400 " 'prefix+view', 'prefix+view.HEAD', or 'prefix+view.BRIK'.\n" 00401 "You can also add a sub-brick selection list after the end of the\n" 00402 "dataset name. This allows only a subset of the sub-bricks to be\n" 00403 "included into the output (by default, all of the input dataset\n" 00404 "is copied into the output). A sub-brick selection list looks like\n" 00405 "one of the following forms:\n" 00406 " fred+orig[5] ==> use only sub-brick #5\n" 00407 " fred+orig[5,9,17] ==> use #5, #9, and #12\n" 00408 " fred+orig[5..8] or [5-8] ==> use #5, #6, #7, and #8\n" 00409 " fred+orig[5..13(2)] or [5-13(2)] ==> use #5, #7, #9, #11, and #13\n" 00410 "Sub-brick indexes start at 0. You can use the character '$'\n" 00411 "to indicate the last sub-brick in a dataset; for example, you\n" 00412 "can select every third sub-brick by using the selection list\n" 00413 " fred+orig[0..$(3)]\n" 00414 "\n" 00415 "N.B.: The sub-bricks are output in the order specified, which may\n" 00416 " not be the order in the original datasets. For example, using\n" 00417 " fred+orig[0..$(2),1..$(2)]\n" 00418 " will cause the sub-bricks in fred+orig to be output into the\n" 00419 " new dataset in an interleaved fashion. Using\n" 00420 " fred+orig[$..0]\n" 00421 " will reverse the order of the sub-bricks in the output.\n" 00422 "\n" 00423 "N.B.: Bucket datasets have multiple sub-bricks, but do NOT have\n" 00424 " a time dimension. You can input sub-bricks from a 3D+time dataset\n" 00425 " into a bucket dataset. You can use the '3dinfo' program to see\n" 00426 " how many sub-bricks a 3D+time or a bucket dataset contains.\n" 00427 "\n" 00428 "N.B.: The '$', '(', ')', '[', and ']' characters are special to\n" 00429 " the shell, so you will have to escape them. This is most easily\n" 00430 " done by putting the entire dataset plus selection list inside\n" 00431 " single quotes, as in 'fred+orig[5..7,9]'.\n" 00432 "\n" 00433 "N.B.: In non-bucket functional datasets (like the 'fico' datasets\n" 00434 " output by FIM, or the 'fitt' datasets output by 3dttest), sub-brick\n" 00435 " [0] is the 'intensity' and sub-brick [1] is the statistical parameter\n" 00436 " used as a threshold. Thus, to create a bucket dataset using the\n" 00437 " intensity from dataset A and the threshold from dataset B, and\n" 00438 " calling the output dataset C, you would type\n" 00439 " 3dbucket -prefix C -fbuc 'A+orig[0]' -fbuc 'B+orig[1]'\n" 00440 "\n" 00441 "WARNING: using this program, it is possible to create a dataset that\n" 00442 " has different basic datum types for different sub-bricks\n" 00443 " (e.g., shorts for brick 0, floats for brick 1).\n" 00444 " Do NOT do this! Very few AFNI programs will work correctly\n" 00445 " with such datasets!\n" 00446 ) ; 00447 00448 exit(0) ; 00449 } |
|
compute the overall minimum and maximum voxel values for a dataset Definition at line 453 of file 3dbucket.c. References addto_args(), ADN_brick_fac_one, ADN_brick_keywords_append_one, ADN_brick_keywords_replace_one, ADN_brick_label_one, ADN_brick_stataux_one, ADN_directory_name, ADN_func_type, ADN_none, ADN_ntt, ADN_nvals, ADN_prefix, ADN_type, AFNI_logger(), ANAT_BUCK_TYPE, argc, BUCK_dry, BUCK_glue, BUCK_output_prefix, BUCK_read_opts(), BUCK_session, BUCK_Syntax(), BUCK_type, DATABLOCK_MEM_MALLOC, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, DSET_ARRAY, DSET_BRICK, DSET_BRICK_FACTOR, DSET_BRICK_KEYWORDS, DSET_BRICK_LABEL, DSET_BRICK_STATAUX, DSET_BRICK_STATCODE, DSET_BRICK_TYPE, DSET_BRIKNAME, DSET_FILECODE, DSET_HEADNAME, DSET_load, DSET_LOADED, DSET_NVALS, DSET_PREFIX, DSUB, EDIT_dset_items(), EDIT_empty_copy(), EDIT_substitute_brick(), EQUIV_DATAXES, free, FUNC_BUCK_TYPE, FUNC_IS_STAT, THD_3dim_dataset::func_type, THD_3dim_dataset::idcode, ISANATTYPE, ISFUNC, THD_3dim_dataset::keywords, LAST_MOD_DATE, machdep(), mainENTRY, malloc, mri_free(), myXtFree, NSUBV, THD_3dim_dataset_array::num, PRINT_VERSION, PROGRAM_NAME, THD_3dim_dataset::stat_aux, SUBV, THD_force_malloc_type(), THD_is_file(), THD_load_statistics(), THD_write_3dim_dataset(), tross_Copy_History(), and tross_Make_History().
00454 { 00455 int ninp , ids , nv , iv,jv,kv , ivout , new_nvals ; 00456 THD_3dim_dataset * new_dset=NULL , * dset ; 00457 char buf[256] ; 00458 00459 /*----- identify program -----*/ 00460 printf ("\n\nProgram %s \n", PROGRAM_NAME); 00461 printf ("Last revision: %s \n\n", LAST_MOD_DATE); 00462 00463 /*** read input options ***/ 00464 00465 if( argc < 2 || strncmp(argv[1],"-help",4) == 0 ) BUCK_Syntax() ; 00466 00467 mainENTRY("3dbucket main"); machdep(); PRINT_VERSION("3dbucket") ; 00468 00469 /*-- 20 Apr 2001: addto the arglist, if user wants to [RWCox] --*/ 00470 00471 { int new_argc ; char ** new_argv ; 00472 addto_args( argc , argv , &new_argc , &new_argv ) ; 00473 if( new_argv != NULL ){ argc = new_argc ; argv = new_argv ; } 00474 } 00475 00476 AFNI_logger("3dbucket",argc,argv) ; 00477 00478 BUCK_read_opts( argc , argv ) ; 00479 00480 /*** create new dataset (empty) ***/ 00481 ninp = BUCK_dsar->num ; 00482 if( ninp < 1 ){ 00483 fprintf(stderr,"*** No input datasets?\n") ; exit(1) ; 00484 } 00485 00486 new_nvals = 0 ; 00487 for( ids=0 ; ids < ninp ; ids++ ) new_nvals += NSUBV(ids) ; 00488 00489 if( BUCK_verb ) printf("-verb: output will have %d sub-bricks\n",new_nvals) ; 00490 00491 new_dset = EDIT_empty_copy( DSUB(0) ) ; 00492 00493 /* 23 May 2005: check for axis consistency */ 00494 00495 for( iv=1 ; iv < ninp ; iv++ ){ 00496 if( !EQUIV_DATAXES(new_dset->daxes,DSUB(iv)->daxes) ) 00497 fprintf(stderr,"++ WARNING: %s grid mismatch with %s\n", 00498 DSET_BRIKNAME(DSUB(0)) , DSET_BRIKNAME(DSUB(iv)) ) ; 00499 } 00500 00501 /* if( ninp == 1 ) */ tross_Copy_History( DSUB(0) , new_dset ) ; 00502 tross_Make_History( "3dbucket" , argc,argv , new_dset ) ; 00503 00504 EDIT_dset_items( new_dset , 00505 ADN_prefix , BUCK_output_prefix , 00506 ADN_directory_name, BUCK_session , 00507 ADN_type , BUCK_type , 00508 ADN_func_type , ISANATTYPE(BUCK_type) ? ANAT_BUCK_TYPE 00509 : FUNC_BUCK_TYPE, 00510 ADN_ntt , 0 , 00511 ADN_nvals , new_nvals , 00512 ADN_none ) ; 00513 00514 /* can't re-write existing dataset, unless glueing is used */ 00515 00516 if (! BUCK_glue){ 00517 if( THD_is_file(DSET_HEADNAME(new_dset)) ){ 00518 fprintf(stderr,"*** Fatal error: file %s already exists!\n", 00519 DSET_HEADNAME(new_dset) ) ; 00520 exit(1) ; 00521 } 00522 } else { /* if glueing is used, make the 'new' 00523 dataset have the same idcode as the old one */ 00524 00525 new_dset->idcode = DSUB(0) -> idcode ; /* copy the struct */ 00526 } 00527 00528 THD_force_malloc_type( new_dset->dblk , DATABLOCK_MEM_MALLOC ) ; 00529 00530 /*** loop over input datasets ***/ 00531 00532 if( ninp > 1 ) myXtFree( new_dset->keywords ) ; 00533 00534 ivout = 0 ; 00535 for( ids=0 ; ids < ninp ; ids++ ){ 00536 dset = DSUB(ids) ; 00537 nv = NSUBV(ids) ; 00538 00539 if( ! BUCK_dry ){ 00540 DSET_load(dset) ; 00541 if( ! DSET_LOADED(dset) ){ 00542 fprintf(stderr,"*** Fatal error: can't load data from %s\n", 00543 DSET_FILECODE(dset)) ; 00544 exit(1) ; 00545 } 00546 } 00547 00548 /** loop over sub-bricks to output **/ 00549 00550 for( iv=0 ; iv < nv ; iv++ ){ 00551 jv = SUBV(ids,iv) ; /* which sub-brick to use */ 00552 00553 if( ! BUCK_dry ){ 00554 EDIT_substitute_brick( new_dset , ivout , 00555 DSET_BRICK_TYPE(dset,jv) , DSET_ARRAY(dset,jv) ) ; 00556 00557 /*----- If this sub-brick is from a bucket dataset, 00558 preserve the label for this sub-brick -----*/ 00559 if (dset->func_type == FUNC_BUCK_TYPE) 00560 sprintf (buf, "%s", DSET_BRICK_LABEL(dset,jv)); 00561 else 00562 sprintf(buf,"%.12s[%d]",DSET_PREFIX(dset),jv) ; 00563 EDIT_dset_items( new_dset , ADN_brick_label_one+ivout, buf , ADN_none ) ; 00564 00565 sprintf(buf,"%s[%d]",DSET_FILECODE(dset),jv) ; 00566 EDIT_dset_items( 00567 new_dset, ADN_brick_keywords_replace_one+ivout, buf, ADN_none ) ; 00568 00569 EDIT_dset_items( 00570 new_dset , 00571 ADN_brick_fac_one +ivout, DSET_BRICK_FACTOR(dset,jv), 00572 ADN_brick_keywords_append_one+ivout, DSET_BRICK_KEYWORDS(dset,jv) , 00573 ADN_none ) ; 00574 00575 /** possibly write statistical parameters for this sub-brick **/ 00576 00577 kv = DSET_BRICK_STATCODE(dset,jv) ; 00578 00579 if( FUNC_IS_STAT(kv) ){ /* input sub-brick has stat params */ 00580 00581 int npar = FUNC_need_stat_aux[kv] , lv ; 00582 float * par = (float *) malloc( sizeof(float) * (npar+2) ) ; 00583 float * sax = DSET_BRICK_STATAUX(dset,jv) ; 00584 par[0] = kv ; 00585 par[1] = npar ; 00586 for( lv=0 ; lv < npar ; lv++ ) 00587 par[lv+2] = (sax != NULL) ? sax[lv] : 0.0 ; 00588 00589 EDIT_dset_items(new_dset , 00590 ADN_brick_stataux_one+ivout , par , 00591 ADN_none ) ; 00592 free(par) ; 00593 00594 /* 2: if the input dataset has statistical parameters */ 00595 00596 } else if( ISFUNC(dset) && /* dset has stat */ 00597 FUNC_IS_STAT(dset->func_type) && /* params */ 00598 jv == FUNC_ival_thr[dset->func_type] ){ /* thr sub-brick */ 00599 00600 int npar , lv ; 00601 float * par , * sax ; 00602 kv = dset->func_type ; 00603 npar = FUNC_need_stat_aux[kv] ; 00604 par = (float *) malloc( sizeof(float) * (npar+2) ) ; 00605 sax = dset->stat_aux ; 00606 par[0] = kv ; 00607 par[1] = npar ; 00608 for( lv=0 ; lv < npar ; lv++ ) 00609 par[lv+2] = (sax != NULL) ? sax[lv] : 0.0 ; 00610 00611 EDIT_dset_items(new_dset , 00612 ADN_brick_stataux_one+ivout , par , 00613 ADN_none ) ; 00614 free(par) ; 00615 } 00616 00617 /** print a message? **/ 00618 00619 if( BUCK_verb ) printf("-verb: copied %s[%d] into %s[%d]\n" , 00620 DSET_FILECODE(dset) , jv , 00621 DSET_FILECODE(new_dset) , ivout ) ; 00622 } else { 00623 printf("-dry: would copy %s[%d] into %s[%d]\n" , 00624 DSET_FILECODE(dset) , jv , 00625 DSET_FILECODE(new_dset) , ivout ) ; 00626 } 00627 00628 ivout++ ; 00629 } 00630 00631 /** loop over all bricks in input dataset and 00632 unload them if they aren't going into the output 00633 (not required, but is done to economize on memory) **/ 00634 00635 if( ! BUCK_dry && nv < DSET_NVALS(dset) ){ 00636 00637 for( kv=0 ; kv < DSET_NVALS(dset) ; kv++ ){ /* all input sub-bricks */ 00638 for( iv=0 ; iv < nv ; iv++ ){ /* all output sub-bricks */ 00639 jv = SUBV(ids,iv) ; 00640 if( jv == kv ) break ; /* input matches output */ 00641 } 00642 if( iv == nv ){ 00643 mri_free( DSET_BRICK(dset,kv) ) ; 00644 #if 0 00645 if( BUCK_verb ) printf("-verb: unloaded unused %s[%d]\n" , 00646 DSET_FILECODE(dset) , kv ) ; 00647 #endif 00648 } 00649 } 00650 } 00651 00652 } /* end of loop over input datasets */ 00653 00654 if( ! BUCK_dry ){ 00655 if( BUCK_verb ) fprintf(stderr,"-verb: loading statistics\n") ; 00656 THD_load_statistics( new_dset ) ; 00657 THD_write_3dim_dataset( NULL,NULL , new_dset , True ) ; 00658 if( BUCK_verb ) fprintf(stderr,"-verb: wrote output: %s\n",DSET_BRIKNAME(new_dset)) ; 00659 } 00660 00661 exit(0) ; 00662 } |
Variable Documentation
|
Definition at line 48 of file 3dbucket.c. Referenced by BUCK_read_opts(), and main(). |
|
Definition at line 45 of file 3dbucket.c. |
|
Definition at line 51 of file 3dbucket.c. Referenced by BUCK_read_opts(), and main(). |
|
Definition at line 47 of file 3dbucket.c. Referenced by BUCK_read_opts(). |
|
Definition at line 53 of file 3dbucket.c. Referenced by BUCK_read_opts(), and main(). |
|
Definition at line 54 of file 3dbucket.c. Referenced by BUCK_read_opts(), and main(). |
|
Definition at line 46 of file 3dbucket.c. |
|
Definition at line 50 of file 3dbucket.c. Referenced by BUCK_read_opts(), and main(). |
|
Definition at line 49 of file 3dbucket.c. Referenced by BUCK_read_opts(). |