Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
edt_fullcopy.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "mrilib.h"
00008
00009
00010
00011
00012
00013 THD_3dim_dataset * EDIT_full_copy( THD_3dim_dataset *dset , char *new_prefix )
00014 {
00015 THD_3dim_dataset *new_dset ;
00016 int ival , ityp , nbytes , nvals ;
00017 void *new_brick , *old_brick ;
00018
00019 ENTRY("EDIT_full_copy") ;
00020
00021
00022
00023 if( ! ISVALID_3DIM_DATASET(dset) ) RETURN(NULL) ;
00024
00025
00026
00027 new_dset = EDIT_empty_copy( dset ) ;
00028
00029
00030
00031 if( new_prefix != NULL )
00032 EDIT_dset_items( new_dset ,
00033 ADN_prefix , new_prefix ,
00034 ADN_label1 , new_prefix ,
00035 ADN_none ) ;
00036
00037
00038
00039 THD_load_datablock( dset->dblk ) ;
00040
00041 nvals = DSET_NVALS(dset) ;
00042
00043 for( ival=0 ; ival < nvals ; ival++ ){
00044 ityp = DSET_BRICK_TYPE(new_dset,ival) ;
00045 nbytes = DSET_BRICK_BYTES(new_dset,ival) ;
00046 new_brick = malloc( nbytes ) ;
00047
00048 if( new_brick == NULL ){
00049 THD_delete_3dim_dataset( new_dset , False ) ;
00050 RETURN(NULL) ;
00051 }
00052
00053 EDIT_substitute_brick( new_dset , ival , ityp , new_brick ) ;
00054
00055
00056
00057 old_brick = DSET_BRICK_ARRAY(dset,ival) ;
00058
00059 if( old_brick == NULL ){
00060 THD_delete_3dim_dataset( new_dset , False ) ;
00061 RETURN(NULL) ;
00062 }
00063
00064 memcpy( new_brick , old_brick , nbytes ) ;
00065 }
00066
00067 RETURN( new_dset );
00068 }