Doxygen Source Code Documentation
plug_edit.c File Reference
#include "afni.h"
Go to the source code of this file.
Defines | |
#define | MEGA 1048576 |
Functions | |
char * | EDIT_main (PLUGIN_interface *) |
DEFINE_PLUGIN_PROTOTYPE PLUGIN_interface * | PLUGIN_init (int ncall) |
char * | EDIT_opts (PLUGIN_interface *plint, THD_3dim_dataset **dset, EDIT_options *edopt, char **new_prefix, char **new_session, int *datum, int *keepthr, int *thrdatum) |
Variables | |
char | helpstring [] |
Define Documentation
|
Definition at line 30 of file plug_edit.c. Referenced by EDIT_main(). |
Function Documentation
|
Definition at line 800 of file plug_edit.c. References ADN_directory_name, ADN_func_type, ADN_label1, ADN_none, ADN_nvals, ADN_prefix, THD_3dim_dataset::daxes, THD_3dim_dataset::dblk, THD_datablock::diskptr, DSET_ARRAY, DSET_BRICK, DSET_BRICK_FACTOR, DSET_BRICK_TYPE, DSET_BRIKNAME, DSET_PRINCIPAL_VALUE, DSET_unload, EDIT_coerce_autoscale(), EDIT_coerce_scale_type(), EDIT_dset_items(), EDIT_empty_copy(), EDIT_one_dataset(), EDIT_opts(), EDIT_substitute_brick(), free, FUNC_FIM_TYPE, FUNC_HAVE_THR, THD_3dim_dataset::func_type, THD_diskptr::header_name, INIT_EDOPT, input_datum, ISFUNC, MAX_STAT_AUX, MEGA, mri_datum_size(), mri_fix_data_pointer(), mri_free(), THD_datablock::nvals, THD_dataxes::nxx, THD_dataxes::nyy, nz, THD_dataxes::nzz, PLUTO_add_dset(), PLUTO_commandstring(), PLUTO_copy_dset(), THD_3dim_dataset::self_name, THD_delete_3dim_dataset(), THD_is_file(), THD_datablock::total_bytes, tross_Append_History(), tross_Copy_History(), and XtMalloc. Referenced by PLUGIN_init().
00801 { 00802 EDIT_options PE_edopt; 00803 int PE_keepthr = 0; 00804 int PE_datum = ILLEGAL_TYPE; 00805 int PE_thdatum = ILLEGAL_TYPE; 00806 int PE_be_quiet = 0; 00807 char * PE_output_session = NULL; 00808 char * PE_output_prefix = NULL; 00809 00810 00811 int nx,ny,nz , nxyz , ii , ival; 00812 THD_3dim_dataset * old_dset = NULL, * dset=NULL , * new_dset=NULL ; 00813 int datum ; 00814 float fimfac , fimfacinv , first_fimfac , thrfac ; 00815 int output_datum , output_thdatum ; 00816 int input_datum , input_thdatum , first_datum ; 00817 00818 float thr_stataux[MAX_STAT_AUX] ; 00819 char * str; 00820 00821 00822 00823 /*-- set up for dataset editing --*/ 00824 INIT_EDOPT( &PE_edopt ) ; 00825 00826 00827 /*----- read input options -----*/ 00828 str = EDIT_opts (plint, &old_dset, &PE_edopt, 00829 &PE_output_prefix, &PE_output_session, &PE_datum, 00830 &PE_keepthr, &PE_thdatum); 00831 if (str != NULL) return (str); 00832 00833 /*----- make a copy of the original dataset -----*/ 00834 dset = PLUTO_copy_dset (old_dset, NULL); 00835 DSET_unload (old_dset); 00836 00837 /*----- get the dimensions -----*/ 00838 nx = dset->daxes->nxx ; 00839 ny = dset->daxes->nyy ; 00840 nz = dset->daxes->nzz ; nxyz = nx*ny*nz ; 00841 00842 00843 ival = DSET_PRINCIPAL_VALUE(dset) ; 00844 input_datum = DSET_BRICK_TYPE(dset,ival) ; 00845 if (PE_datum >= 0) output_datum = PE_datum ; 00846 else output_datum = input_datum ; 00847 00848 new_dset = EDIT_empty_copy( dset ) ; 00849 00850 EDIT_dset_items( new_dset , 00851 ADN_prefix , PE_output_prefix , 00852 ADN_label1 , PE_output_prefix , 00853 ADN_directory_name , PE_output_session , 00854 ADN_none ) ; 00855 strcat( new_dset->self_name , "(PE)" ) ; 00856 00857 { char * his = PLUTO_commandstring(plint) ; 00858 tross_Copy_History( dset , new_dset ) ; 00859 tross_Append_History( new_dset, his ) ; free(his) ; 00860 } 00861 00862 if( ! PE_keepthr && new_dset->dblk->nvals > 1 ) 00863 EDIT_dset_items( new_dset , 00864 ADN_nvals , 1 , 00865 ADN_func_type , FUNC_FIM_TYPE , 00866 ADN_none ) ; 00867 00868 if ( PE_keepthr && ISFUNC(new_dset) && FUNC_HAVE_THR(new_dset->func_type) ) 00869 { 00870 ii = FUNC_ival_thr[dset->func_type] ; 00871 input_thdatum = DSET_BRICK_TYPE(dset,ii) ; 00872 if (PE_thdatum >= 0) output_thdatum = PE_thdatum ; 00873 else output_thdatum = input_thdatum ; 00874 } 00875 else 00876 { 00877 output_thdatum = input_thdatum = ILLEGAL_TYPE ; 00878 } 00879 00880 if ( THD_is_file(new_dset->dblk->diskptr->header_name) ) 00881 { 00882 fprintf(stderr, 00883 "*** Output file %s already exists -- cannot continue!\n", 00884 new_dset->dblk->diskptr->header_name ) ; 00885 return("*** Output file already exists -- cannot continue!"); 00886 /*EXIT(1) ;*/ 00887 } 00888 00889 if (! PE_be_quiet) 00890 { 00891 printf("-- editing input dataset in memory (%.1f MB)", 00892 ((double)dset->dblk->total_bytes) / MEGA ) ; 00893 fflush(stdout) ; 00894 } 00895 00896 00897 EDIT_one_dataset( dset , &PE_edopt ) ; /* all the real work */ 00898 00899 00900 if (! PE_be_quiet) { printf(".\n") ; fflush(stdout) ; } 00901 00902 00903 /** Coerce the output data type into a new brick, if needed **/ 00904 ival = DSET_PRINCIPAL_VALUE(dset) ; 00905 ii = DSET_PRINCIPAL_VALUE(new_dset) ; 00906 00907 if( input_datum == output_datum ) 00908 { 00909 /* 00910 Attach the brick of the input dataset to the brick of the output. 00911 This isn't exactly kosher, but we are exiting almost immediately. 00912 */ 00913 if (! PE_be_quiet) 00914 printf ("connecting edited input to be output \n"); 00915 mri_fix_data_pointer (DSET_ARRAY(dset,ival), DSET_BRICK(new_dset,ii)); 00916 DSET_BRICK_FACTOR(new_dset,ii) = DSET_BRICK_FACTOR(dset,ival); 00917 } 00918 else 00919 { 00920 /** Must create a new brick and do the conversion **/ 00921 void * dfim , * efim ; 00922 float etop ; 00923 00924 if(! PE_be_quiet) 00925 { 00926 printf("-- coercing output datum to be %s\n", 00927 MRI_TYPE_name[output_datum]); 00928 } 00929 00930 efim = DSET_ARRAY(dset,ival) ; 00931 dfim = (void *) XtMalloc( mri_datum_size(output_datum) * nxyz ) ; 00932 00933 fimfac = EDIT_coerce_autoscale( nxyz , input_datum , efim , 00934 output_datum , dfim ) ; 00935 00936 DSET_BRICK_FACTOR(new_dset,ii) = (fimfac != 0.0 && fimfac != 1.0) 00937 ? 1.0/fimfac : 0.0 ; 00938 00939 EDIT_substitute_brick( new_dset , ii , output_datum , dfim ) ; 00940 mri_free( DSET_BRICK(dset,ival) ) ; 00941 } 00942 00943 /** Now do the threshold data **/ 00944 00945 if( output_thdatum >= 0 ) 00946 { 00947 ival = FUNC_ival_thr[ dset->func_type] ; 00948 ii = FUNC_ival_thr[new_dset->func_type] ; 00949 00950 if( input_thdatum == output_thdatum ) 00951 { 00952 if (! PE_be_quiet) 00953 printf ("connecting input and output thresholds \n") ; 00954 mri_fix_data_pointer (DSET_ARRAY(dset,ival),DSET_BRICK(new_dset,ii)); 00955 DSET_BRICK_FACTOR(new_dset,ii) = DSET_BRICK_FACTOR(dset,ival) ; 00956 } 00957 else 00958 { 00959 void * dfim , * efim ; 00960 00961 if( ! PE_be_quiet ) 00962 { 00963 printf("-- coercing threshold datum to be %s\n", 00964 MRI_TYPE_name[output_thdatum]); 00965 } 00966 00967 efim = DSET_ARRAY(dset,ival) ; 00968 dfim = (void *) XtMalloc( mri_datum_size(output_thdatum) * nxyz ) ; 00969 00970 switch( output_thdatum ) 00971 { 00972 default: fprintf(stderr,"** illegal output_thdatum = %d\n", 00973 output_thdatum); 00974 return("** illegal output_thdatum"); 00975 /* EXIT(1) ;*/ 00976 00977 case MRI_float: 00978 fimfacinv = 0.0 ; 00979 fimfac = DSET_BRICK_FACTOR(dset,ival) ; 00980 if( fimfac == 0.0 ) 00981 { 00982 fimfac = (input_thdatum == MRI_short) 00983 ? 1.0/FUNC_scale_short[dset->func_type] 00984 : (input_thdatum == MRI_byte) 00985 ? 1.0/FUNC_scale_byte[dset->func_type] : 0.0 ; 00986 } 00987 break ; 00988 00989 case MRI_short: 00990 if( input_datum == MRI_float ) 00991 { 00992 fimfac = FUNC_scale_short[new_dset->func_type] ; 00993 fimfacinv = 1.0 / fimfac ; 00994 } 00995 else 00996 if( input_datum == MRI_byte ) 00997 { 00998 fimfac = ((float)FUNC_scale_short[new_dset->func_type]) 00999 / FUNC_scale_byte[new_dset->func_type] ; 01000 fimfacinv = 1.0 / FUNC_scale_short[new_dset->func_type] ; 01001 } 01002 else 01003 { 01004 fprintf(stderr, 01005 "** illegal input_thdatum = %d\n",input_thdatum); 01006 return("** illegal input_thdatum"); 01007 /* EXIT(1) ;*/ 01008 } 01009 break ; 01010 01011 case MRI_byte: 01012 if( input_datum == MRI_float ) 01013 { 01014 fimfac = FUNC_scale_byte[new_dset->func_type] ; 01015 fimfacinv = 1.0 / fimfac ; 01016 } 01017 else 01018 if( input_datum == MRI_short ) 01019 { 01020 fimfac = ((float)FUNC_scale_byte[new_dset->func_type]) 01021 / FUNC_scale_short[new_dset->func_type] ; 01022 fimfacinv = 1.0 / FUNC_scale_byte[new_dset->func_type] ; 01023 } 01024 else 01025 { 01026 fprintf(stderr,"** illegal input_thdatum = %d\n", 01027 input_thdatum); 01028 return("** illegal input_thdatum"); 01029 /* EXIT(1) ;*/ 01030 } 01031 break; 01032 } 01033 01034 EDIT_coerce_scale_type( nxyz , fimfac , 01035 DSET_BRICK_TYPE(dset,ival),efim , 01036 output_thdatum,dfim ); 01037 01038 DSET_BRICK_FACTOR(new_dset,ii) = fimfacinv; 01039 EDIT_substitute_brick( new_dset , ii , output_thdatum , dfim ); 01040 mri_free( DSET_BRICK(dset,ival) ); 01041 } 01042 } 01043 01044 if (! PE_be_quiet) 01045 printf("-- Writing edited dataset:%s\n" , DSET_BRIKNAME(new_dset) ) ; 01046 01047 ival = PLUTO_add_dset( plint , new_dset , DSET_ACTION_MAKE_CURRENT ) ; 01048 01049 if (ival) 01050 { 01051 THD_delete_3dim_dataset( new_dset , False ) ; 01052 return 01053 "*********************************************\n" 01054 "EDIT_main: failure to add new dataset to AFNI\n" 01055 "*********************************************" ; 01056 } 01057 else 01058 return (NULL) ; 01059 01060 } |
|
Definition at line 235 of file plug_edit.c. References DSET_NUM_TIMES, DSET_THRESH_INDEX, ECFLAG_AMAX, ECFLAG_MAX, ECFLAG_MEAN, ECFLAG_ORDER, ECFLAG_SAME, ECFLAG_SIZE, ECFLAG_SMAX, FCFLAG_AMAX, FCFLAG_AVER, FCFLAG_MAX, FCFLAG_MEAN, FCFLAG_NZMEAN, FCFLAG_SMAX, FWHM_TO_SIGMA, PLUTO_find_dset(), PLUTO_prefix_ok(), RMS_TO_SIGMA, top, x2, y1, and z1. Referenced by EDIT_main().
00246 { 00247 char * tag; /* plugin option tag */ 00248 char * str; /* input string */ 00249 float rmm; /* cluster or filter radius (mm) */ 00250 float vmul; /* cluster minimum volume (ul) */ 00251 float thresh; /* threshold level */ 00252 MCW_idcode * idc ; /* dataset id code */ 00253 int ival; /* integer value input */ 00254 float bot, top; /* clip option limits */ 00255 float blur; /* Gaussian blur function width */ 00256 float fval; /* input floating point value */ 00257 float dx, dy, dz, dxyz; /* voxel dimensions */ 00258 float x1, x2, y1, y2, z1, z2; /* zero volume limits */ 00259 float pv; /* pv % voxels within rmm must be active */ 00260 00261 00262 /*----- Check inputs from AFNI to see if they are reasonable-ish -----*/ 00263 if( plint == NULL ) 00264 return 00265 "*********************\n" 00266 "EDIT_opts: NULL input\n" 00267 "*********************"; 00268 00269 00270 /*--------- go to first input line ---------*/ 00271 tag = PLUTO_get_optiontag(plint) ; 00272 if( (tag==NULL) || (strcmp(tag,"Dataset") != 0) ) 00273 return 00274 "*********************************\n" 00275 "EDIT_opts: Bad dataset option tag\n" 00276 "*********************************"; 00277 00278 idc = PLUTO_get_idcode(plint) ; 00279 (*dset) = PLUTO_find_dset(idc) ; 00280 if( (*dset) == NULL ) 00281 return 00282 "****************************\n" 00283 "EDIT_opts: Bad input dataset\n" 00284 "****************************"; 00285 00286 if (DSET_NUM_TIMES((*dset)) > 1) 00287 return 00288 "*************************************************\n" 00289 "EDIT_opts: Unable to edit time-dependent datasets\n" 00290 "*************************************************"; 00291 00292 /*----- get the dimensions -----*/ 00293 dx = fabs((*dset)->daxes->xxdel); 00294 dy = fabs((*dset)->daxes->yydel); 00295 dz = fabs((*dset)->daxes->zzdel); 00296 dxyz = dx*dy*dz ; 00297 00298 00299 str = PLUTO_get_string(plint); 00300 if (str != NULL) 00301 { 00302 if( ! PLUTO_prefix_ok(str) ) 00303 return 00304 "*********************\n" 00305 "EDIT_opts: bad prefix\n" 00306 "*********************"; 00307 else 00308 *new_prefix = str; 00309 } 00310 00311 str = PLUTO_get_string(plint); 00312 if (str != NULL) 00313 { 00314 *new_session = str; 00315 } 00316 00317 00318 /*------ loop over remaining options, check their tags, process them -----*/ 00319 do 00320 { 00321 tag = PLUTO_get_optiontag(plint) ; 00322 if( tag == NULL ) break ; 00323 00324 00325 /*----- Miscellaneous Options -----*/ 00326 if (strcmp (tag, "Options") == 0) 00327 { 00328 str = PLUTO_get_string(plint); 00329 if (strcmp (str, "True") == 0) 00330 { 00331 if (DSET_THRESH_INDEX(*dset) < 0) 00332 return 00333 "*********************************************\n" 00334 "EDIT_opts: Dataset has no threshold sub-brick\n" 00335 "*********************************************"; 00336 else 00337 edopt->thtoin = 1; 00338 } 00339 else 00340 edopt->thtoin = 0; 00341 00342 str = PLUTO_get_string(plint); 00343 if (strcmp (str, "True") == 0) 00344 edopt->noneg = 1; 00345 else 00346 edopt->noneg = 0; 00347 00348 str = PLUTO_get_string(plint); 00349 if (strcmp (str, "True") == 0) 00350 edopt->abss = 1; 00351 else 00352 edopt->abss = 0; 00353 00354 continue; 00355 } 00356 00357 00358 /*----- Clip Option -----*/ 00359 if (strcmp(tag,"Clip") == 0) 00360 { 00361 bot = PLUTO_get_number(plint); 00362 top = PLUTO_get_number(plint); 00363 str = PLUTO_get_string(plint); 00364 00365 if (bot >= top) 00366 return 00367 "**********************************************************\n" 00368 "EDIT_opts: First clip value must be less than second value\n" 00369 "**********************************************************"; 00370 00371 edopt->clip_bot = bot; 00372 edopt->clip_top = top; 00373 00374 if (strcmp (str, "True") == 0) 00375 edopt->clip_unscaled = 1; 00376 else 00377 edopt->clip_unscaled = 0; 00378 00379 continue; 00380 } 00381 00382 00383 /*----- Threshold Option -----*/ 00384 if (strcmp(tag,"Threshold") == 0) 00385 { 00386 thresh = PLUTO_get_number(plint) ; 00387 00388 if (thresh < 0.0) 00389 return 00390 "******************************\n" 00391 "EDIT_opts: Bad Threshold input\n" 00392 "******************************"; 00393 00394 if( thresh > 0.0 && DSET_THRESH_INDEX(*dset) < 0 ) 00395 return 00396 "*********************************************\n" 00397 "EDIT_opts: Dataset has no threshold sub-brick\n" 00398 "*********************************************"; 00399 00400 edopt->thresh = thresh; 00401 00402 continue; 00403 } 00404 00405 00406 /*----- Blur Option -----*/ 00407 if (strcmp(tag,"Blur") == 0) 00408 { 00409 str = PLUTO_get_string(plint); 00410 blur = PLUTO_get_number(plint); 00411 00412 if (blur <= 0.0 ) 00413 return 00414 "*****************************\n" 00415 "EDIT_opts: Illegal Blur input\n" 00416 "*****************************"; 00417 00418 if (strcmp(str,"Sigma") == 0) 00419 edopt->blur = blur; 00420 else 00421 if (strcmp(str,"RMS") == 0) 00422 edopt->blur = RMS_TO_SIGMA(blur); 00423 else 00424 if (strcmp(str,"FWHM") == 0) 00425 edopt->blur = FWHM_TO_SIGMA(blur); 00426 else 00427 return 00428 "******************************\n" 00429 "EDIT_opts: Illegal Blur option\n" 00430 "******************************"; 00431 00432 continue; 00433 } 00434 00435 00436 /*----- Zero Volume Option -----*/ 00437 if (strcmp(tag, "Zero Vol UL") == 0) 00438 { 00439 x2 = PLUTO_get_number(plint); 00440 y2 = PLUTO_get_number(plint); 00441 z2 = PLUTO_get_number(plint); 00442 00443 tag = PLUTO_get_optiontag(plint); 00444 if (strcmp(tag, "Zero Vol LL") == 0) 00445 { 00446 x1 = PLUTO_get_number(plint); 00447 y1 = PLUTO_get_number(plint); 00448 z1 = PLUTO_get_number(plint); 00449 } 00450 else 00451 return 00452 "***************************\n" 00453 "EDIT_opts: Need Zero Vol LL\n" 00454 "***************************"; 00455 00456 edopt->zv_x1 = x1; edopt->zv_x2 = x2; 00457 edopt->zv_y1 = y1; edopt->zv_y2 = y2; 00458 edopt->zv_z1 = z1; edopt->zv_z2 = z2; 00459 edopt->do_zvol = 1; 00460 continue; 00461 } 00462 00463 00464 if (strcmp(tag, "Zero Vol LL") == 0) 00465 { 00466 return 00467 "***************************\n" 00468 "EDIT_opts: Need Zero Vol UL\n" 00469 "***************************"; 00470 } 00471 00472 00473 /*----- Cluster Option -----*/ 00474 if (strcmp(tag,"Cluster") == 0) 00475 { 00476 str = PLUTO_get_string(plint); 00477 rmm = PLUTO_get_number(plint) ; 00478 vmul = PLUTO_get_number(plint) ; 00479 00480 if ( (rmm < dx) && (rmm < dy) && (rmm < dz) ) 00481 return 00482 "***********************************\n" 00483 "EDIT_opts: Cluster rmm is too small\n" 00484 "***********************************"; 00485 00486 if (vmul <= dxyz) 00487 return 00488 "************************************\n" 00489 "EDIT_opts: Cluster vmul is too small\n" 00490 "************************************"; 00491 00492 edopt->clust_rmm = rmm; 00493 edopt->clust_vmul = vmul; 00494 00495 if (strcmp(str,"Keep") == 0) 00496 edopt->edit_clust = ECFLAG_SAME; 00497 else 00498 if (strcmp(str,"Mean") == 0) 00499 edopt->edit_clust = ECFLAG_MEAN; 00500 else 00501 if (strcmp(str,"Max") == 0) 00502 edopt->edit_clust = ECFLAG_MAX; 00503 else 00504 if (strcmp(str,"AMax") == 0) 00505 edopt->edit_clust = ECFLAG_AMAX; 00506 else 00507 if (strcmp(str,"SMax") == 0) 00508 edopt->edit_clust = ECFLAG_SMAX; 00509 else 00510 if (strcmp(str,"Size") == 0) 00511 edopt->edit_clust = ECFLAG_SIZE; 00512 else 00513 if (strcmp(str,"Order") == 0) 00514 edopt->edit_clust = ECFLAG_ORDER; 00515 else 00516 return 00517 "*********************************\n" 00518 "EDIT_opts: Illegal Cluster option\n" 00519 "*********************************"; 00520 00521 continue; 00522 } 00523 00524 00525 /*----- Erosion/Dilation Option -----*/ 00526 if (strcmp(tag,"Erode/Dilate") == 0) 00527 { 00528 pv = PLUTO_get_number(plint); 00529 if ((pv > 0.0) && (edopt->clust_rmm <= 0.0)) 00530 return 00531 "******************************************************\n" 00532 "EDIT_opts: Erode/Dilate requires use of Cluster option\n" 00533 "******************************************************"; 00534 else 00535 edopt->erode_pv = pv / 100.0; 00536 00537 str = PLUTO_get_string(plint); 00538 if (strcmp (str, "True") == 0) 00539 { 00540 if (pv <= 0.0) 00541 return 00542 "**********************************************\n" 00543 "EDIT_opts: Dilate requires use of Erode option\n" 00544 "**********************************************"; 00545 else 00546 edopt->dilate = 1; 00547 } 00548 else 00549 edopt->dilate = 0; 00550 00551 continue; 00552 } 00553 00554 00555 /*----- Filter Option -----*/ 00556 if (strcmp(tag,"Filter") == 0) 00557 { 00558 str = PLUTO_get_string(plint); 00559 rmm = PLUTO_get_number(plint) ; 00560 00561 if ( (rmm < dx) && (rmm < dy) && (rmm < dz) ) 00562 return 00563 "**********************************\n" 00564 "EDIT_opts: Filter rmm is too small\n" 00565 "**********************************"; 00566 00567 edopt->filter_rmm = rmm; 00568 00569 if (strcmp(str,"Mean") == 0) 00570 edopt->filter_opt = FCFLAG_MEAN; 00571 else 00572 if (strcmp(str,"NZMean") == 0) 00573 edopt->filter_opt = FCFLAG_NZMEAN; 00574 else 00575 if (strcmp(str,"Max") == 0) 00576 edopt->filter_opt = FCFLAG_MAX; 00577 else 00578 if (strcmp(str,"AMax") == 0) 00579 edopt->filter_opt = FCFLAG_AMAX; 00580 else 00581 if (strcmp(str,"SMax") == 0) 00582 edopt->filter_opt = FCFLAG_SMAX; 00583 else 00584 if (strcmp(str,"Aver") == 0) /* 07 Jan 1998 */ 00585 edopt->filter_opt = FCFLAG_AVER; 00586 else 00587 return 00588 "********************************\n" 00589 "EDIT_opts: Illegal Filter option\n" 00590 "********************************"; 00591 00592 continue; 00593 } 00594 00595 00596 /*----- Multiply Option -----*/ 00597 if (strcmp(tag,"Multiply") == 0) 00598 { 00599 fval = PLUTO_get_number(plint); 00600 00601 if (fval == 0.0) 00602 return 00603 "*****************************\n" 00604 "EDIT_opts: Bad Multiply input\n" 00605 "*****************************"; 00606 00607 edopt->mult = fval; 00608 00609 continue; 00610 } 00611 00612 00613 /*----- Datum Type Option -----*/ 00614 if (strcmp(tag, "Datum") == 0) 00615 { 00616 str = PLUTO_get_string(plint); 00617 if (strcmp(str,"Byte") == 0) 00618 *datum = MRI_byte; 00619 else 00620 if (strcmp(str,"Short") == 0) 00621 *datum = MRI_short; 00622 else 00623 if (strcmp(str,"Float") == 0) 00624 *datum = MRI_float; 00625 else 00626 { 00627 return 00628 "*****************************\n" 00629 "EDIT_opts: Illegal Datum type\n" 00630 "*****************************"; 00631 } 00632 00633 continue; 00634 } 00635 00636 00637 /*----- Keep Threshold Option -----*/ 00638 if (strcmp(tag,"Keep Thr") == 0) 00639 { 00640 str = PLUTO_get_string(plint); 00641 if (strcmp (str, "True") == 0) 00642 { 00643 if (DSET_THRESH_INDEX(*dset) < 0) 00644 return 00645 "*********************************************\n" 00646 "EDIT_opts: Dataset has no threshold sub-brick\n" 00647 "*********************************************"; 00648 else 00649 *keepthr = 1; 00650 } 00651 else 00652 *keepthr = 0; 00653 00654 continue; 00655 } 00656 00657 00658 /*----- Threshold Blur Option -----*/ 00659 if (strcmp(tag,"Thr Blur") == 0) 00660 { 00661 if (DSET_THRESH_INDEX(*dset) < 0) 00662 return 00663 "*********************************************\n" 00664 "EDIT_opts: Dataset has no threshold sub-brick\n" 00665 "*********************************************"; 00666 00667 str = PLUTO_get_string(plint); 00668 blur = PLUTO_get_number(plint) ; 00669 00670 if (blur <= 0.0 ) 00671 return 00672 "***************************************\n" 00673 "EDIT_opts: Illegal Threshold Blur input\n" 00674 "***************************************"; 00675 00676 if (strcmp(str,"Sigma") == 0) 00677 edopt->thrblur = blur; 00678 else 00679 if (strcmp(str,"RMS") == 0) 00680 edopt->thrblur = RMS_TO_SIGMA(blur); 00681 else 00682 if (strcmp(str,"FWHM") == 0) 00683 edopt->thrblur = FWHM_TO_SIGMA(blur); 00684 else 00685 return 00686 "******************************\n" 00687 "EDIT_opts: Illegal Blur option\n" 00688 "******************************"; 00689 00690 *keepthr = 1; 00691 00692 continue; 00693 } 00694 00695 00696 /*----- Threshold Filter Option -----*/ 00697 if (strcmp(tag,"Thr Filter") == 0) 00698 { 00699 if (DSET_THRESH_INDEX(*dset) < 0) 00700 return 00701 "*********************************************\n" 00702 "EDIT_opts: Dataset has no threshold sub-brick\n" 00703 "*********************************************"; 00704 00705 str = PLUTO_get_string(plint); 00706 rmm = PLUTO_get_number(plint) ; 00707 00708 if ( (rmm < dx) && (rmm < dy) && (rmm < dz) ) 00709 return 00710 "**************************************\n" 00711 "EDIT_opts: Thr Filter rmm is too small\n" 00712 "**************************************"; 00713 00714 edopt->thrfilter_rmm = rmm; 00715 00716 if (strcmp(str,"Mean") == 0) 00717 edopt->thrfilter_opt = FCFLAG_MEAN; 00718 else 00719 if (strcmp(str,"NZMean") == 0) 00720 edopt->thrfilter_opt = FCFLAG_NZMEAN; 00721 else 00722 if (strcmp(str,"Max") == 0) 00723 edopt->thrfilter_opt = FCFLAG_MAX; 00724 else 00725 if (strcmp(str,"AMax") == 0) 00726 edopt->thrfilter_opt = FCFLAG_AMAX; 00727 else 00728 if (strcmp(str,"SMax") == 0) 00729 edopt->thrfilter_opt = FCFLAG_SMAX; 00730 else 00731 if (strcmp(str,"Aver") == 0) /* 07 Jan 1998 */ 00732 edopt->thrfilter_opt = FCFLAG_AVER; 00733 else 00734 return 00735 "************************************\n" 00736 "EDIT_opts: Illegal Thr Filter option\n" 00737 "************************************"; 00738 00739 *keepthr = 1; 00740 00741 continue; 00742 } 00743 00744 00745 /*----- Threshold Datum Type Option -----*/ 00746 if (strcmp(tag, "Thr Datum") == 0) 00747 { 00748 if (DSET_THRESH_INDEX(*dset) < 0) 00749 return 00750 "*********************************************\n" 00751 "EDIT_opts: Dataset has no threshold sub-brick\n" 00752 "*********************************************"; 00753 00754 str = PLUTO_get_string(plint); 00755 if (strcmp(str,"Byte") == 0) 00756 *thrdatum = MRI_byte; 00757 else 00758 if (strcmp(str,"Short") == 0) 00759 *thrdatum = MRI_short; 00760 else 00761 if (strcmp(str,"Float") == 0) 00762 *thrdatum = MRI_float; 00763 else 00764 { 00765 return 00766 "***************************************\n" 00767 "EDIT_opts: Illegal Threshold Datum type\n" 00768 "***************************************"; 00769 } 00770 00771 *keepthr = 1; 00772 00773 continue; 00774 } 00775 00776 00777 /*----- Illegal Option -----*/ 00778 else 00779 { 00780 return 00781 "***********************************\n" 00782 "EDIT_opts: Illegal optiontag found!\n" 00783 "***********************************"; 00784 } 00785 00786 } while(1) ; 00787 00788 00789 /*---------- End of input options ----------*/ 00790 00791 return NULL; 00792 } |
|
Definition at line 76 of file plug_edit.c. References ANAT_ALL_MASK, EDIT_main(), FUNC_ALL_MASK, helpstring, PLUTO_add_hint(), and PLUTO_set_sequence().
00077 { 00078 /*----- plugin option labels -----*/ 00079 char * boolean_types[2] = {"False", "True"}; 00080 char * blur_types[3] = {"Sigma", "RMS", "FWHM"}; 00081 char * cluster_types[7] = {"Keep", "Mean", "Max", "AMax", "SMax", "Size", 00082 "Order"}; 00083 char * filter_types[6] = {"Mean", "NZMean", "Max", "AMax", "SMax", "Aver" }; 00084 char * brick_types[2] = {"Intensity", "Threshold"}; 00085 char * datum_types[3] = {"Byte", "Short", "Float"}; 00086 00087 PLUGIN_interface * plint ; 00088 00089 00090 if( ncall > 0 ) return NULL ; /* only one interface */ 00091 00092 /*-- set titles and call point --*/ 00093 plint = PLUTO_new_interface( "3D Edit" , "Dataset Editing" , helpstring , 00094 PLUGIN_CALL_VIA_MENU , EDIT_main ) ; 00095 00096 PLUTO_add_hint( plint , "Edit Dataset Contents" ) ; 00097 00098 PLUTO_set_sequence( plint , "A:newdset:edit" ) ; 00099 00100 /*---- line 1 of input: Dataset -----*/ 00101 PLUTO_add_option (plint, "Dataset", "Dataset", TRUE); 00102 PLUTO_add_hint( plint , "Choose input and output" ) ; 00103 00104 PLUTO_add_dataset (plint, "Input", 00105 ANAT_ALL_MASK, FUNC_ALL_MASK, 00106 DIMEN_3D_MASK | BRICK_ALLREAL_MASK); 00107 PLUTO_add_hint( plint , "Choose input dataset" ) ; 00108 00109 PLUTO_add_string (plint, "Prefix", 0, NULL, 19); 00110 PLUTO_add_hint( plint , "Name output dataset" ) ; 00111 00112 PLUTO_add_string (plint, "Session", 0, NULL, 19); 00113 PLUTO_add_hint( plint , "Name output directory" ) ; 00114 00115 /*----- line 2 of input: Options -----*/ 00116 PLUTO_add_option (plint, "Options", "Options", FALSE); 00117 PLUTO_add_hint( plint , "Preprocessing steps" ) ; 00118 00119 PLUTO_add_string (plint, "Thr->Int", 2, boolean_types, 0); 00120 PLUTO_add_hint( plint , "Copy threshold over intensity brick?" ) ; 00121 00122 PLUTO_add_string (plint, "No Neg", 2, boolean_types, 0); 00123 PLUTO_add_hint( plint , "Zero out negative values?" ) ; 00124 00125 PLUTO_add_string (plint, "Abs Value", 2, boolean_types, 0); 00126 PLUTO_add_hint( plint , "Take absolute value?" ) ; 00127 00128 /*----- line 3 of input: Clipping -----*/ 00129 PLUTO_add_option (plint, "Clip", "Clip", FALSE); 00130 PLUTO_add_hint( plint , "Zero out values in some range" ) ; 00131 00132 PLUTO_add_number (plint, "Lower", -99999, 99999, 0, 0, TRUE); 00133 PLUTO_add_hint( plint , "Values above this => zero" ) ; 00134 00135 PLUTO_add_number (plint, "Upper", -99999, 99999, 0, 0, TRUE); 00136 PLUTO_add_hint( plint , "Values below this => zero" ) ; 00137 00138 PLUTO_add_string (plint, "Unscaled?", 2, boolean_types, 0); 00139 PLUTO_add_hint( plint , "Don't apply scaling factors?" ) ; 00140 00141 /*----- line 4 of input: Threshold -----*/ 00142 PLUTO_add_option (plint, "Threshold", "Threshold" , FALSE); 00143 PLUTO_add_hint( plint , "Zero out if threshold brick too small" ) ; 00144 00145 PLUTO_add_number (plint, "Cutoff" , 0, 10000, 2, 50, TRUE); 00146 PLUTO_add_hint( plint , "Threshold values < this => 0" ) ; 00147 00148 /*----- line 5 of input: Blurring -----*/ 00149 PLUTO_add_option (plint, "Blur", "Blur", FALSE); 00150 PLUTO_add_hint( plint , "Gaussian convolution" ) ; 00151 00152 PLUTO_add_string (plint, "Format", 3, blur_types, 0); 00153 PLUTO_add_hint( plint , "How blur width is specified" ) ; 00154 00155 PLUTO_add_number (plint, "Width(mm)", 0, 500, 1, 20, TRUE); 00156 PLUTO_add_hint( plint , "Range of blurring function" ) ; 00157 00158 /*----- line 6 of input: Zero Volume -----*/ 00159 PLUTO_add_option (plint, "Zero Vol UL", "Zero Vol UL", FALSE); 00160 PLUTO_add_number (plint, "x Upper", -999, 999, 0, 0, TRUE); 00161 PLUTO_add_number (plint, "y Upper", -999, 999, 0, 0, TRUE); 00162 PLUTO_add_number (plint, "z Upper", -999, 999, 0, 0, TRUE); 00163 00164 /*----- line 7 of input: Zero Volume -----*/ 00165 PLUTO_add_option (plint, "Zero Vol LL", "Zero Vol LL", FALSE); 00166 PLUTO_add_number (plint, "x Lower", -999, 999, 0, 0, TRUE); 00167 PLUTO_add_number (plint, "y Lower", -999, 999, 0, 0, TRUE); 00168 PLUTO_add_number (plint, "z Lower", -999, 999, 0, 0, TRUE); 00169 00170 /*----- line 8 of input: Cluster Parameters -----*/ 00171 PLUTO_add_option (plint, "Cluster", "Cluster", FALSE); 00172 PLUTO_add_hint( plint , "Find and reject small clusters" ) ; 00173 00174 PLUTO_add_string (plint, "Type", 7, cluster_types, 0); 00175 PLUTO_add_hint( plint , "How to process data inside clusters" ) ; 00176 00177 PLUTO_add_number (plint, "Radius(mm)", 0, 100, 1, 20, TRUE); 00178 PLUTO_add_hint( plint , "Max distance between 'neighbors'" ) ; 00179 00180 PLUTO_add_number (plint, "MinVol(ul)", 0, 1000, -1, 100, TRUE); 00181 PLUTO_add_hint( plint , "Min size for cluster to survive" ) ; 00182 00183 /*----- line 8a of input: Erosion/Dilation option -----*/ /* 18 June 1998 */ 00184 PLUTO_add_option (plint, "Erode/Dilate", "Erode/Dilate", FALSE); 00185 PLUTO_add_hint (plint , "Sever narrow connecting paths between clusters"); 00186 00187 PLUTO_add_number (plint, "% Voxels", 0, 100, 0, 50, TRUE); 00188 PLUTO_add_hint (plint, 00189 "Min % of active 'neighbors' for a voxel to survive"); 00190 00191 PLUTO_add_string (plint, "Dilate?", 2, boolean_types, 0); 00192 PLUTO_add_hint (plint , "Restore voxels near main body of cluster"); 00193 00194 /*----- line 9 of input: Filtering -----*/ 00195 PLUTO_add_option (plint, "Filter", "Filter", FALSE); 00196 PLUTO_add_string (plint, "Type", 6, filter_types, 0); 00197 PLUTO_add_number (plint, "Radius(mm)", 0, 100, 1, 20, TRUE); 00198 00199 /*----- line 10 of input: Multiply -----*/ 00200 PLUTO_add_option (plint, "Multiply", "Multiply", FALSE); 00201 PLUTO_add_number (plint, "Factor", -99999, 99999, 0, 1, TRUE); 00202 00203 /*----- line 11 of input: Datum -----*/ 00204 PLUTO_add_option (plint, "Datum", "Datum", FALSE); 00205 PLUTO_add_string (plint, "Type", 3, datum_types, 1); 00206 00207 /*----- line 12 of input: Keep Threshold -----*/ 00208 PLUTO_add_option (plint, "Keep Thr", "Keep Thr", FALSE); 00209 PLUTO_add_string (plint, "Keep?", 2, boolean_types, 0); 00210 00211 /*----- line 13 of input: Threshold Blur -----*/ 00212 PLUTO_add_option (plint, "Thr Blur", "Thr Blur", FALSE); 00213 PLUTO_add_string (plint, "Format", 3, blur_types, 0); 00214 PLUTO_add_number (plint, "Width(mm)", 0, 100, 1, 20, TRUE); 00215 00216 /*----- line 14 of input: Threshold Filter -----*/ 00217 PLUTO_add_option (plint, "Thr Filter", "Thr Filter", FALSE); 00218 PLUTO_add_string (plint, "Type", 6, filter_types, 0); 00219 PLUTO_add_number (plint, "Radius(mm)", 0, 100, 1, 20, TRUE); 00220 00221 /*----- line 15 of input: Threshold Datum -----*/ 00222 PLUTO_add_option (plint, "Thr Datum", "Thr Datum", FALSE); 00223 PLUTO_add_string (plint, "Type", 3, datum_types, 1); 00224 00225 return plint ; 00226 } |
Variable Documentation
|
Initial value: "Purpose: AFNI plugin to edit data and return new dataset.\n" "Inputs: \n" " Dataset Input and Output datasets\n" " Input Input dataset that must already be in memory \n" " Prefix Prefix for output file name \n" " Session Write output into specified directory (default=./) \n" " Clip Clip intensities in range (lower,upper) to zero \n" " Unscaled Do not apply any automatic scaling factor \n" " Threshold Use threshold sub-brick to censor the intensities \n" " Blur Gaussian blur using specified function width \n" " Zero Vol UL Zero out entries inside the 3D volume defined by: \n" " Zero Vol LL xLL <= x <=xUL, yLL <= y <=yUL, zLL <= z <= zUL \n" " Cluster Form clusters and clip off data not in clusters \n" " Type Options for setting voxel intensities within a cluster \n" " Radius Max. distance for 2 voxels to be connected in a cluster \n" " MinVol Min. volume for a cluster to survive \n" " Erode/Dilate Sever narrow connecting paths between clusters \n" " % Voxels Min. % of active 'neighbors' for a voxel to survive \n" " Dilate Restore voxels near main body of cluster \n" " Filter Filter voxel intensities \n" " Type Defines filter action \n" " Radius Voxel intensity is effected by voxels within this radius\n" " Multiply Multiply intensities by the given factor\n" " Datum Coerce output data to be stored as the given type \n" " Keep Thr Copy the threshold sub-brick into the output dataset \n" " Thr Blur Apply Gaussian blur function to threshold data sub-brick \n" " Thr Filter Apply specified filter to threshold data sub-brick \n" " Thr Datum Coerce threshold data sub-brick to be stored as given type\n" "Author -- BD Ward" Definition at line 35 of file plug_edit.c. Referenced by PLUGIN_init(). |