Doxygen Source Code Documentation
thd_manydset.c File Reference
#include "mrilib.h"#include "thd.h"Go to the source code of this file.
Functions | |
| THD_3dim_dataset_array * | THD_array_3dim_from_block (THD_datablock_array *blk_arr) |
Function Documentation
|
|
Definition at line 16 of file thd_manydset.c. References ADDTO_3DARR, THD_3dim_dataset::anat_parent_name, THD_3dim_dataset_array::ar, THD_datablock_array::ar, DSET_ERR, DSET_WARN, ENTRY, FREE_3DARR, INIT_3DARR, ISANAT, ISFUNC, myXtFree, THD_3dim_dataset_array::num, THD_datablock_array::num, RETURN, SORT_3DARR, THD_3dim_from_block(), and THD_delete_3dim_dataset(). Referenced by THD_init_session().
00017 {
00018 THD_3dim_dataset_array * dset_arr ;
00019 THD_3dim_dataset * dset ;
00020 int id ;
00021 Boolean dset_ok = True , all_anat , all_func ;
00022
00023 ENTRY("THD_array_3dim_from_block") ;
00024
00025 INIT_3DARR( dset_arr ) ;
00026
00027 if( blk_arr == NULL || blk_arr->num <= 0 ) RETURN(dset_arr) ;
00028
00029 for( id=0 ; id < blk_arr->num ; id++ ){
00030
00031 dset = THD_3dim_from_block( blk_arr->ar[id] ) ;
00032
00033 if( dset != NULL ) ADDTO_3DARR( dset_arr , dset ) ;
00034 }
00035
00036 if( dset_arr->num <= 0 ) RETURN(dset_arr) ;
00037
00038 /******************************************************/
00039 /*-- now, check the set of datasets for consistency --*/
00040 /******************************************************/
00041
00042 /*-- 1. Images should all be anatomy type or function type --*/
00043
00044 all_anat = all_func = True ;
00045 for( id=0 ; id < dset_arr->num ; id++ ){
00046 dset = dset_arr->ar[id] ;
00047 all_anat = all_anat && ISANAT(dset) ;
00048 all_func = all_func && ISFUNC(dset) ;
00049 }
00050 if( !all_anat && !all_func )
00051 DSET_ERR("image type conflicts (ANAT and FUNC mixed)") ;
00052
00053 SORT_3DARR( dset_arr ) ;
00054
00055 /*-- 2. If all images are anat, nothing to do at this moment. --*/
00056
00057 if( all_anat ){
00058 } /* end of dealing with all_anat case */
00059
00060 /*-- 3. If all images are func .... --*/
00061
00062 if( all_func ){
00063 THD_3dim_dataset * dset0 ;
00064 int jd ;
00065
00066 #if 0
00067 /* check for anat parents (should all have one) */
00068
00069 for( id=0 ; id < dset_arr->num ; id++ ){ /* check for anat parent */
00070 dset = dset_arr->ar[id] ;
00071 if( strlen(dset->anat_parent_name) == 0 )
00072 DSET_WARN("functional image has no anatomical parent!") ;
00073 }
00074 #endif
00075
00076 } /* end of dealing with all_func case */
00077
00078 /*********************************************************/
00079 /*---------- if an error occurred, clean up -------------*/
00080 /*********************************************************/
00081
00082 if( ! dset_ok ){
00083
00084 /*-- delete data in subsidiary data structures --*/
00085
00086 for( id=0 ; id < dset_arr->num ; id++ ){
00087 THD_delete_3dim_dataset( dset_arr->ar[id] , False ) ;
00088 myXtFree( dset_arr->ar[id] ) ;
00089 }
00090
00091 FREE_3DARR( dset_arr ) ;
00092 INIT_3DARR( dset_arr ) ; /* return a blank array */
00093 }
00094
00095 /*-- at last!
00096 give the caller the list of (nearly) initialized datasets --*/
00097
00098 RETURN(dset_arr) ;
00099 }
|