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  

thd_avts.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

MRI_IMAGETHD_average_timeseries (MCW_cluster_array *clustar, THD_3dim_dataset *dset)
MRI_IMAGETHD_average_one_timeseries (MCW_cluster *clust, THD_3dim_dataset *dset)

Function Documentation

MRI_IMAGE* THD_average_one_timeseries MCW_cluster   clust,
THD_3dim_dataset   dset
 

Extract a single average time series. --------------------------------------------------------------------------

Definition at line 57 of file thd_avts.c.

References ADDTO_CLARR, MCW_cluster_array::clar, DESTROY_CLARR, ENTRY, INIT_CLARR, ISVALID_DSET, RETURN, and THD_average_timeseries().

00059 {
00060    MRI_IMAGE *im ;
00061    MCW_cluster_array *clustar ;
00062 
00063 ENTRY("THD_average_one_timeseries") ;
00064 
00065    if( clust == NULL || !ISVALID_DSET(dset) ) RETURN(NULL) ;
00066 
00067    INIT_CLARR(clustar) ;
00068    ADDTO_CLARR(clustar,clust) ;
00069 
00070    im = THD_average_timeseries( clustar , dset ) ;
00071 
00072    clustar->clar[0] = NULL ; DESTROY_CLARR(clustar) ;
00073    RETURN(im) ;
00074 }

MRI_IMAGE* THD_average_timeseries MCW_cluster_array   clustar,
THD_3dim_dataset   dset
 

For each cluster of points in clustar, extract the average time series from dataset dset. Put the results into an nt X nc float image, where nt = number of dataset bricks, nc = number of clusters. -------------------------------------------------------------------------

Definition at line 9 of file thd_avts.c.

References MCW_cluster_array::clar, DSET_NVALS, DSET_NX, DSET_NY, ENTRY, free, MCW_cluster::i, ISVALID_DSET, MCW_cluster::j, MCW_cluster::k, malloc, MRI_FLOAT_PTR, mri_new(), nc, MCW_cluster_array::num_clu, MCW_cluster::num_pt, RETURN, THD_extract_array(), and THREE_TO_IJK.

Referenced by ROIPLOT_main(), and THD_average_one_timeseries().

00011 {
00012    int nt,nc , ii,jj , npt,kk , nx,ny,nxy , ijk,nav ;
00013    MRI_IMAGE *flim ;
00014    float     *flar , *tsar , *avar , fac ;
00015    MCW_cluster *clust ;
00016 
00017 ENTRY("THD_average_timeseries") ;
00018 
00019    if( clustar == NULL || clustar->num_clu == 0 || !ISVALID_DSET(dset) )
00020      RETURN(NULL) ;
00021 
00022    nt = DSET_NVALS(dset) ;
00023    nc = clustar->num_clu ;
00024    tsar = (float *) malloc(nt*sizeof(float)) ;
00025    avar = (float *) malloc(nt*sizeof(float)) ;
00026 
00027    flim = mri_new( nt,nc , MRI_float ) ;
00028    flar = MRI_FLOAT_PTR(flim) ;
00029 
00030    nx = DSET_NX(dset) ; ny = DSET_NY(dset) ; nxy = nx*ny ;
00031 
00032    for( jj=0 ; jj < nc ; jj++ ){
00033      clust = clustar->clar[jj] ;
00034      if( clust == NULL || clust->num_pt == 0 ) continue ;
00035      npt = clust->num_pt ;
00036      for( ii=0 ; ii < nt ; ii++ ) avar[ii] = 0.0 ;
00037      for( nav=kk=0 ; kk < npt ; kk++ ){
00038        ijk = THREE_TO_IJK(clust->i[kk],clust->j[kk],clust->k[kk],nx,nxy) ;
00039        ii  = THD_extract_array( ijk , dset , 0 , tsar ) ;
00040        if( ii < 0 ) continue ;
00041        for( ii=0 ; ii < nt ; ii++ ) avar[ii] += tsar[ii] ;
00042        nav++ ;
00043      }
00044      if( nav > 0 ){
00045        fac = 1.0 / nav ;
00046        for( ii=0 ; ii < nt ; ii++ ) flar[ii+jj*nt] = fac*avar[ii] ;
00047      }
00048    }
00049 
00050    free(avar) ; free(tsar) ; RETURN(flim) ;
00051 }
 

Powered by Plone

This site conforms to the following standards: