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_clustarr.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #include "mrilib.h"
00008 
00009 /*-----------------------------------------------------------------------------
00010    Routine to edit cluster array.
00011 
00012       clar        = cluster array to be edited
00013       edit_clust  = flag to indicate cluster editing option
00014       dxyz        = volume of a voxel
00015       vmul        = minimum volume for a cluster
00016 
00017    The edited cluster array is returned in clar.
00018 
00019    Author :  B. D. Ward
00020    Date   :  10 September 1996
00021 
00022    Modified 09 June 1998 by RWCox to add ECFLAG_ORDER option.
00023 -----------------------------------------------------------------------------*/
00024 
00025 void EDIT_cluster_array (MCW_cluster_array * clar, int edit_clust,
00026                          float dxyz, float vmul)
00027 {
00028    int iclu;       /* cluster index */
00029    int nclu;       /* non-empty cluster index */
00030    int ii;         /* voxel index */
00031    float
00032       mag,         /* voxel intensity */
00033       sum,         /* sum of voxel intensities */
00034       max,         /* maximum of voxel intensities */
00035       amax,        /* maximum of absolute voxel intensities */
00036       smax,        /* signed maximum of absolute voxel intensities */
00037       mean,        /* mean of voxel intensities */
00038       size;        /* size of cluster (multiples of vmul) */
00039 
00040 ENTRY("EDIT_cluster_array") ;
00041 
00042    if( edit_clust == ECFLAG_ORDER ){
00043       SORT_CLARR(clar) ;
00044    }
00045 
00046    nclu = 0;
00047    for (iclu = 0; iclu < clar->num_clu; iclu++)
00048    {
00049       if ((clar->clar[iclu] != NULL) && (clar->clar[iclu]->num_pt > 0))
00050       {
00051          nclu++;
00052 
00053          /* initialization of basic statistics for this cluster */
00054          sum = max = smax = clar->clar[iclu]->mag[0];
00055          amax = fabs(smax);
00056 
00057          /* calculate basic statistics for this cluster */
00058          for (ii = 1; ii < clar->clar[iclu]->num_pt; ii++)
00059          {
00060             mag = clar->clar[iclu]->mag[ii];
00061             switch (edit_clust)
00062             {
00063                case ECFLAG_MEAN :
00064                   sum += mag;  break;
00065                case ECFLAG_MAX  :
00066                   if (mag > max)  max = mag;   break;
00067                case ECFLAG_AMAX :
00068                   if (fabs(mag) > amax)  amax = fabs(mag);  break;
00069                case ECFLAG_SMAX :
00070                   if (fabs(mag) > fabs(smax))  smax = mag;  break;
00071                case ECFLAG_SIZE : break;
00072                default          : break;
00073             }
00074 
00075          }
00076 
00077          /* additional calculations */
00078          if (edit_clust == ECFLAG_MEAN)
00079             mean = sum / clar->clar[iclu]->num_pt;
00080          if (edit_clust == ECFLAG_SIZE)
00081             size = clar->clar[iclu]->num_pt * dxyz / vmul;
00082 
00083          /* set all voxel intensities in this cluster to the same value */
00084          for (ii = 0; ii < clar->clar[iclu]->num_pt; ii++)
00085          {
00086             switch (edit_clust)
00087             {
00088                case ECFLAG_MEAN :  clar->clar[iclu]->mag[ii] = mean;
00089                case ECFLAG_MAX  :  clar->clar[iclu]->mag[ii] = max;   break;
00090                case ECFLAG_AMAX :  clar->clar[iclu]->mag[ii] = amax;  break;
00091                case ECFLAG_SMAX :  clar->clar[iclu]->mag[ii] = smax;  break;
00092                case ECFLAG_SIZE :  clar->clar[iclu]->mag[ii] = size;  break;
00093                case ECFLAG_ORDER:  clar->clar[iclu]->mag[ii] = nclu;  break;
00094                default          :                                     break;
00095             }
00096          }
00097       }
00098    }  /* iclu */
00099 
00100    EXRETURN ;
00101 }
 

Powered by Plone

This site conforms to the following standards: