Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

edt_substbrick.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

void EDIT_substitute_brick (THD_3dim_dataset *dset, int ival, int ftype, void *fim)

Function Documentation

void EDIT_substitute_brick THD_3dim_dataset   dset,
int    ival,
int    ftype,
void *    fim
 

Definition at line 25 of file edt_substbrick.c.

References THD_datablock::brick, THD_datablock::brick_bytes, calloc, DATABLOCK_MEM_MALLOC, THD_3dim_dataset::dblk, DSET_BRICK, DSET_CRUSH_BSTAT, ENTRY, EXIT, fim, ISVALID_3DIM_DATASET, THD_datablock::malloc_type, mri_empty_conforming, mri_fix_data_pointer(), mri_free(), THD_datablock::nvals, MRI_IMAGE::nvox, MRI_IMAGE::pixel_size, and THD_datablock::total_bytes.

Referenced by AFNI_read_inputs(), applyMask(), attach_sub_brick(), basis_write_iresp(), basis_write_sresp(), CALC_read_opts(), copy_dset(), COPY_main(), DRAW_copy_dset(), EDIT_full_copy(), EDIT_main(), form_clusters(), Fourier_Filter_Driver(), get_options(), main(), MAKER_4D_to_typed_fbuc(), MAKER_4D_to_typed_fim(), MAKER_4D_to_typed_fith(), NUD_doall_CB(), NUD_update_base(), POWER_main(), process_NIML_Node_ROI(), r_fill_resampled_data_brick(), REORDER_main(), RT_process_image(), RT_registration_2D_onevol(), RT_registration_3D_onevol(), s2v_nodes2volume(), saveMask(), STAVG_main(), SUMA_BrainVoyager_Read_vmr(), SUMA_FormAfnidset(), SUMA_OpenDX_Read_CruiseVolHead(), THD_add_bricks(), THD_copy_dset_subs(), THD_load_tcat(), THD_warp3D(), THD_zeropad(), VOLREG_main(), WINsorize(), write_bucket(), write_bucket_data(), and write_results().

00026 {
00027    THD_datablock * dblk ;
00028    MRI_IMAGE * newim , * oldim ;
00029    int nbytes , nullfim = (fim == NULL) ;
00030 
00031 ENTRY("EDIT_substitute_brick") ;
00032 
00033    /**-- Sanity Checks --**/
00034 
00035    if( ! ISVALID_3DIM_DATASET(dset) )                   EXRETURN; /* error! */
00036    if( dset->dblk->brick == NULL )                      EXRETURN; /* ditto! */
00037    if( dset->dblk->malloc_type != DATABLOCK_MEM_MALLOC )EXRETURN; /* ditto! */
00038    if( ival >= dset->dblk->nvals || ival < 0 )          EXRETURN; /* ditto! */
00039    if( ftype < 0 || ftype > LAST_MRI_TYPE )             EXRETURN; /* ditto! */
00040 
00041    oldim = DSET_BRICK(dset,ival) ; if( oldim == NULL )  EXRETURN; /* ditto! */
00042 
00043    newim  = mri_empty_conforming( oldim , ftype ) ;      /* new sub-brick */
00044    nbytes = newim->nvox * newim->pixel_size ;            /* how big it is */
00045    mri_free( oldim ) ;                                   /* kill old one  */
00046 
00047    if( nullfim ){                                        /* if needed, */
00048       fim = calloc( 1,nbytes ) ;                         /* make array */
00049       if( fim == NULL ){
00050         fprintf(stderr,"\n*** malloc error for dataset sub-brick\n") ; EXIT(1) ;
00051       }
00052    }
00053    mri_fix_data_pointer( fim , newim ) ;                 /* attach new data */
00054    DSET_BRICK(dset,ival) = newim ;                       /* put in dataset  */
00055 
00056    /** change the byte count for this sub-brick and the total dataset **/
00057 
00058    dset->dblk->total_bytes      += (nbytes - dset->dblk->brick_bytes[ival]) ;
00059    dset->dblk->brick_bytes[ival] = nbytes ;
00060 
00061    DSET_CRUSH_BSTAT(dset,ival) ;
00062 
00063    EXRETURN ;
00064 }
 

Powered by Plone

This site conforms to the following standards: