|
From: <kin...@us...> - 2004-02-19 03:56:59
|
Update of /cvsroot/teem/teem/src/bane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22355 Modified Files: GNUmakefile bane.h clip.c defaultsBane.c gkmsFlotsam.c gkmsHvol.c hvol.c inc.c measr.c methodsBane.c privateBane.h rangeBane.c valid.c Log Message: INCOMPLETE RE-WRITE. NON_FUNCTIONALcvs diff | & more! Sorry. Index: GNUmakefile =================================================================== RCS file: /cvsroot/teem/teem/src/bane/GNUmakefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** GNUmakefile 7 Jan 2004 15:34:27 -0000 1.13 --- GNUmakefile 19 Feb 2004 03:46:51 -0000 1.14 *************** *** 47,56 **** $(L).PUBLIC_HEADERS = bane.h $(L).PRIVATE_HEADERS = privateBane.h ! $(L).OBJS = defaultsBane.o rangeBane.o inc.o clip.o measr.o valid.o \ ! methodsBane.o trnsf.o scat.o hvol.o trex.o \ gkmsHvol.o gkmsScat.o gkmsInfo.o gkmsPvg.o gkmsOpac.o \ ! gkmsMite.o gkmsFlotsam.o gkmsTxf.o $(L).TESTS = test/tinfo test/sigma test/pos \ ! test/opac test/tblah #### #### --- 47,57 ---- $(L).PUBLIC_HEADERS = bane.h $(L).PRIVATE_HEADERS = privateBane.h ! $(L).OBJS = defaultsBane.o rangeBane.o inc.o clip.o measr.o methodsBane.o \ ! valid.o trnsf.o scat.o hvol.o trex.o \ ! gkmsFlotsam.o \ gkmsHvol.o gkmsScat.o gkmsInfo.o gkmsPvg.o gkmsOpac.o \ ! gkmsMite.o gkmsTxf.o $(L).TESTS = test/tinfo test/sigma test/pos \ ! test/opac #### #### Index: bane.h =================================================================== RCS file: /cvsroot/teem/teem/src/bane/bane.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** bane.h 16 Jan 2004 17:35:11 -0000 1.42 --- bane.h 19 Feb 2004 03:46:51 -0000 1.43 *************** *** 32,41 **** #include <teem/gage.h> - #if defined(_WIN32) && !defined(TEEM_STATIC) && !defined(__CYGWIN__) - #define bane_export __declspec(dllimport) - #else - #define bane_export - #endif - #ifdef __cplusplus extern "C" { --- 32,35 ---- *************** *** 45,60 **** /* ! ** The idea is that the baneRange, baneInc, baneClip, and baneMeasr, ! ** structs, and the pointers to them declared below, are glorified ! ** constants. There is certainly nothing dynamically allocated in any ! ** of them. All the parameters to these things (the various double ! ** *xxxParm arrays) are kept in things which are dynamically allocated ! ** by the user. */ /* -------------------------- ranges -------------------------- */ /* ! ******** baneRange..._e enum ** ** Range: nature of the values generated by a measure- are they --- 39,53 ---- /* ! ******** #define BANE_PARM_NUM ! ** ! ** maximum number of parameters that may be needed by a baneInc, baneClip... */ + #define BANE_PARM_NUM 5 + /* -------------------------- ranges -------------------------- */ /* ! ******** baneRange... enum ** ** Range: nature of the values generated by a measure- are they *************** *** 64,68 **** ** value). ** ! ** The job of the ans() function in the range is not to exclude ** any data. Indeed, if the range is set correctly for the type ** of data used, then range->ans() should always return a range --- 57,61 ---- ** value). ** ! ** The job of the answer() function in the range is not to exclude ** any data. Indeed, if the range is set correctly for the type ** of data used, then range->ans() should always return a range *************** *** 73,86 **** */ enum { ! baneRangeUnknown_e, /* 0: nobody knows */ ! baneRangePos_e, /* 1: always positive: enforce that min == 0 */ ! baneRangeNeg_e, /* 2: always negative: enforce that max == 0 */ ! baneRangeZeroCent_e, /* 3: positive and negative, centered around ! zero: enforce (conservative) centering of ! interval around 0 */ ! baneRangeFloat_e, /* 4: anywhere: essentially a no-op */ ! baneRangeLast_e }; ! #define BANE_RANGE_MAX 4 /* ******** baneRange struct --- 66,79 ---- */ enum { ! baneRangeUnknown, /* 0: nobody knows */ ! baneRangePositive, /* 1: always positive: enforce that min == 0 */ ! baneRangeNegative, /* 2: always negative: enforce that max == 0 */ ! baneRangeZeroCentered, /* 3: positive and negative, centered around ! zero: enforce (conservative) centering of ! interval around 0 */ ! baneRangeAnywhere, /* 4: anywhere: essentially a no-op */ ! baneRangeLast }; ! /* ******** baneRange struct *************** *** 90,96 **** typedef struct { char name[AIR_STRLEN_SMALL]; ! int which; ! int (*ans)(double *ominP, double *omaxP, ! double imin, double imax); } baneRange; --- 83,92 ---- typedef struct { char name[AIR_STRLEN_SMALL]; ! int type; ! double center; /* for baneRangeAnywhere: nominal center of value range ! NOTE: there is currently no API for setting this, ! it has to be set manually */ ! int (*answer)(double *ominP, double *omaxP, ! double imin, double imax); } baneRange; *************** *** 98,106 **** /* ! ******** baneInc..._e enum ** ** Inc: methods for determing what range of measured values deserves ** to be included along one axes of a histogram volume. Each ! ** inclusion method has some parameters (at most BANE_INC_PARM_NUM) ** which are (or can be harmlessly cast to) floats. Some of them need ** a histogram (a Nrrd) in order to determine the new min and max, --- 94,102 ---- /* ! ******** baneInc... enum ** ** Inc: methods for determing what range of measured values deserves ** to be included along one axes of a histogram volume. Each ! ** inclusion method has some parameters (at most BANE_PARM_NUM) ** which are (or can be harmlessly cast to) floats. Some of them need ** a histogram (a Nrrd) in order to determine the new min and max, *************** *** 109,153 **** ** To make matters confusing, the behavior of some of these varies with ** the baneRange they are associated with... */ enum { ! baneIncUnknown_e, /* 0: nobody knows */ ! baneIncAbsolute_e, /* 1: within explicitly specified bounds ! incParm[0]: new min ! incParm[1]: new max */ ! baneIncRangeRatio_e, /* 2: some fraction of the total range ! incParm[0]: scales the size of the range ! after it has been sent through the ! associated range function. ! incParm[1]: (optional) for baneRangeFloat: ! midpoint of scaling; if doesn't exist, ! average of min and max is used. For all ! other range types, 0 is always used. */ ! baneIncPercentile_e, /* 3: exclude some percentile ! incParm[0]: resolution of histogram ! generated ! incParm[1]: PERCENT of hits to throw away, ! by nibbling away at lower and upper ends of ! range, in a manner dependant on the range ! type ! incParm[2]: (optional) for baneRangeFloat, ! center value that we nibble towards. If it ! doesn't exist, we use the average of the ! min and max (though perhaps the mode value ! would be better). For all other range ! types, we nibble towards 0. */ ! baneIncStdv_e, /* 4: some multiple of the standard deviation ! incParm[0]: range is standard deviation ! times this ! incParm[1]: (optional) for baneRangeFloat: ! if exists, the midpoint of the range, ! otherwise the mean is used. For all other ! range types, the range is positioned in the ! logical way. */ ! baneIncLast_e }; - #define BANE_INC_MAX 4 - #define BANE_INC_PARM_NUM 3 - - typedef void (baneIncPass)(Nrrd *hist, double val, double *incParm); /* --- 105,132 ---- ** To make matters confusing, the behavior of some of these varies with ** the baneRange they are associated with... + ** + ** As version 1.7, the incParm[] is no longer used to communicate the + ** center of a baneRangeAnywhere- that is now (as it should be) in + ** the baneRange itself. */ enum { ! baneIncUnknown, /* 0: nobody knows */ ! baneIncAbsolute, /* 1: within explicitly specified bounds ! -- incParm[0]: new min ! -- incParm[1]: new max */ ! baneIncRangeRatio, /* 2: some fraction of the total range ! -- incParm[0]: scales the size of the range, after ! it has been sent through the associated range ! function. */ ! baneIncPercentile, /* 3: exclude some percentile ! -- incParm[0]: resolution of histogram generated ! -- incParm[1]: PERCENT of hits to throw away, ! by nibbling away at lower and upper ends of ! range, in a manner dependant on the range type */ ! baneIncStdv, /* 4: some multiple of the standard deviation ! -- incParm[0]: range is standard deviation ! times this */ ! baneIncLast }; /* *************** *** 157,170 **** ** from histNew should be eventually passed to nrrdNuke. */ ! typedef struct { char name[AIR_STRLEN_SMALL]; ! int which; ! int numParm; /* assumed length of incParm in this ans() */ ! Nrrd *(*histNew)(double *incParm); ! baneIncPass *passA; ! baneIncPass *passB; ! int (*ans)(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range); } baneInc; --- 136,149 ---- ** from histNew should be eventually passed to nrrdNuke. */ ! typedef struct baneInc_t { char name[AIR_STRLEN_SMALL]; ! int type; ! double S, SS; int num; /* used for calculating standard dev */ ! Nrrd *nhist; ! baneRange *range; ! double parm[BANE_PARM_NUM]; ! void (*process[2])(struct baneInc_t *inc, double val); ! int (*answer)(double *minP, double *maxP, ! Nrrd *hist, double *parm, baneRange *range); } baneInc; *************** *** 172,176 **** /* ! ******** baneClip..._e enum ** ** Clip: how to map values in the "raw" histogram volume to the more --- 151,155 ---- /* ! ******** baneClip... enum ** ** Clip: how to map values in the "raw" histogram volume to the more *************** *** 180,192 **** */ enum { ! baneClipUnknown_e, /* 0: nobody knows */ ! baneClipAbsolute_e, /* 1: clip at explicitly specified bin count */ ! baneClipPeakRatio_e, /* 2: some fraction of maximum #hits in any bin */ ! baneClipPercentile_e, /* 3: percentile of values, sorted by hits */ ! baneClipTopN_e, /* 4: ignore the N bins with the highest counts */ baneClipLast }; ! #define BANE_CLIP_MAX 4 ! #define BANE_CLIP_PARM_NUM 1 /* ******** baneClip struct --- 159,170 ---- */ enum { ! baneClipUnknown, /* 0: nobody knows */ ! baneClipAbsolute, /* 1: clip at explicitly specified bin count */ ! baneClipPeakRatio, /* 2: some fraction of maximum #hits in any bin */ ! baneClipPercentile, /* 3: percentile of values, sorted by hits */ ! baneClipTopN, /* 4: ignore the N bins with the highest counts */ baneClipLast }; ! /* ******** baneClip struct *************** *** 196,202 **** typedef struct { char name[AIR_STRLEN_SMALL]; ! int which; ! int numParm; /* assumed length of clipParm in this ans() */ ! int (*ans)(Nrrd *hvol, double *clipParm); } baneClip; --- 174,180 ---- typedef struct { char name[AIR_STRLEN_SMALL]; ! int type; ! double parm[BANE_PARM_NUM]; ! int (*answer)(int *countP, Nrrd *hvol, double *clipParm); } baneClip; *************** *** 204,208 **** /* ! ******** baneMeasr..._e enum ** ** Measr: one of the kind of measurement which determines location along --- 182,186 ---- /* ! ******** baneMeasr... enum ** ** Measr: one of the kind of measurement which determines location along *************** *** 222,242 **** ** that eventually I'll want to do things which modify/combine those ** values in a parameter-controlled way, something which will never be ! ** in gage. Hence the measrParm arrays, even though nothing currently ** uses them. */ enum { ! baneMeasrUnknown_e, /* 0: nobody knows */ ! baneMeasrVal_e, /* 1: the data value */ ! baneMeasrGradMag_e, /* 2: gradient magnitude */ ! baneMeasrLapl_e, /* 3: Laplacian */ ! baneMeasrHess_e, /* 4: Hessian-based measure of 2nd DD along ! gradient */ ! baneMeasrCurvedness_e, /* 5: L2 norm of K1, K2 principal curvatures ! (gageSclCurvedness) */ ! baneMeasrShapeTrace_e, /* 6: shape indicator (gageSclShapeTrace) */ baneMeasrLast }; ! #define BANE_MEASR_MAX 6 ! #define BANE_MEASR_PARM_NUM 1 /* ******** baneMeasr struct --- 200,225 ---- ** that eventually I'll want to do things which modify/combine those ** values in a parameter-controlled way, something which will never be ! ** in gage. Hence the parm array, even though nothing currently ** uses them. */ enum { ! baneMeasrUnknown, /* 0: nobody knows */ ! baneMeasrValuePositive, /* 1: the data value, with positive range ! (gageSclValue) */ ! baneMeasrValueZeroCentered, /* 2: the data value, with zero-centered range ! (gageSclValue) */ ! baneMeasrValueAnywhere, /* 3: the data value, with anywhere range ! (gageSclValue) */ ! baneMeasrGradMag, /* 4: gradient magnitude (gageSclGradMag) */ ! baneMeasrLaplacian, /* 5: Laplacian (gageSclLaplacian) */ ! baneMeasr2ndDD, /* 6: Hessian-based measure of 2nd DD along ! gradient (gageScl2ndDD) */ ! baneMeasrTotalCurv, /* 7: L2 norm of K1, K2 principal curvatures ! (gageSclTotalCurv) */ ! baneMeasrFlowlineCurv, /* 8: curvature of normal streamline ! (gageSclFlowlineCurv) */ baneMeasrLast }; ! /* ******** baneMeasr struct *************** *** 244,256 **** ** things used to calculate and describe measurements */ ! typedef struct { char name[AIR_STRLEN_SMALL]; ! int which; ! int numParm; /* assumed length of measrParm in this ans() */ ! int query; /* the gageScl query needed for this measure. ! Does not need to be the recursive ! prerequisite expansion). */ baneRange *range; ! float (*ans)(gage_t *, double *measrParm); } baneMeasr; --- 227,239 ---- ** things used to calculate and describe measurements */ ! typedef struct baneMeasr_t { char name[AIR_STRLEN_SMALL]; ! int type; ! double parm[BANE_PARM_NUM]; ! gageQuery query; /* the gageScl query needed for this measure, ! but NOT its recursive prerequisite expansion). */ baneRange *range; ! int offset0; ! double (*answer)(struct baneMeasr_t *, gage_t *, double *parm); } baneMeasr; *************** *** 262,274 **** ** Information for how to do measurement and inclusion along each axis ** of the histogram volume. - ** - ** No dynamically allocated stuff in here!! */ typedef struct { int res; /* resolution = number of bins */ baneMeasr *measr; - double measrParm[BANE_MEASR_PARM_NUM]; baneInc *inc; - double incParm[BANE_INC_PARM_NUM]; } baneAxis; --- 245,253 ---- *************** *** 276,392 **** ******** baneHVolParm struct ** ! ** Information for how to create a histogram volume. NB: We have an ! ** array of baneAxis structs, not pointers to them. baneHVolParmNew ! ** does initialization of them. ** - ** No dynamically allocated stuff in here!! */ typedef struct { ! int verbose; /* status messages to stderr */ ! int makeMeasrVol; /* create a 3 x X x Y x Z volume of measurements, so that they aren't measured (as many as) three times */ ! Nrrd *measrVol; ! int measrVolDone; /* values in measrVol are filled */ ! baneAxis ax[3]; /* NB: not pointers to baneAxis */ ! int k3pack; ! int renormalize; /* use gage's mask renormalization */ const NrrdKernel *k[GAGE_KERNEL_NUM]; double kparm[GAGE_KERNEL_NUM][NRRD_KERNEL_PARMS_NUM]; baneClip *clip; - double clipParm[BANE_CLIP_PARM_NUM]; double incLimit; /* lowest permissible fraction of the data remaining after new inclusion has been determined */ } baneHVolParm; /* defaultsBane.c */ ! extern bane_export const char *baneBiffKey; ! extern bane_export int baneDefVerbose; ! extern bane_export int baneDefMakeMeasrVol; ! extern bane_export float baneDefIncLimit; ! extern bane_export int baneDefRenormalize; ! extern bane_export int baneDefPercHistBins; ! extern bane_export int baneStateHistEqBins; ! extern bane_export int baneStateHistEqSmart; ! extern bane_export int baneHack; /* rangeBane.c */ ! extern bane_export baneRange *baneRangeUnknown; ! extern bane_export baneRange *baneRangePos; ! extern bane_export baneRange *baneRangeNeg; ! extern bane_export baneRange *baneRangeZeroCent; ! extern bane_export baneRange *baneRangeFloat; ! extern bane_export baneRange *baneRangeArray[BANE_RANGE_MAX+1]; /* inc.c */ ! extern bane_export baneInc *baneIncUnknown; ! extern bane_export baneInc *baneIncAbsolute; ! extern bane_export baneInc *baneIncRangeRatio; ! extern bane_export baneInc *baneIncPercentile; ! extern bane_export baneInc *baneIncStdv; ! extern bane_export baneInc *baneIncArray[BANE_INC_MAX+1]; ! ! /* measr.c */ ! extern bane_export baneMeasr *baneMeasrUnknown; ! extern bane_export baneMeasr *baneMeasrVal; ! extern bane_export baneMeasr *baneMeasrGradMag; ! extern bane_export baneMeasr *baneMeasrLapl; ! extern bane_export baneMeasr *baneMeasrHess; ! extern bane_export baneMeasr *baneMeasrCurvedness; ! extern bane_export baneMeasr *baneMeasrShadeTrace; ! extern bane_export baneMeasr *baneMeasrArray[BANE_MEASR_MAX+1]; /* clip.c */ ! extern bane_export baneClip *baneClipUnknown; ! extern bane_export baneClip *baneClipAbsolute; ! extern bane_export baneClip *baneClipPeakRatio; ! extern bane_export baneClip *baneClipPercentile; ! extern bane_export baneClip *baneClipTopN; ! extern bane_export baneClip *baneClipArray[BANE_CLIP_MAX+1]; /* methodsBane.c */ ! extern baneHVolParm *baneHVolParmNew(); ! extern void baneHVolParmGKMSInit(baneHVolParm *hvp); ! extern baneHVolParm *baneHVolParmNix(baneHVolParm *hvp); /* valid.c */ ! extern int baneInputCheck(Nrrd *nin, baneHVolParm *hvp); ! extern int baneHVolCheck(Nrrd *hvol); ! extern int baneInfoCheck(Nrrd *info2D, int wantDim); ! extern int banePosCheck(Nrrd *pos, int wantDim); ! extern int baneBcptsCheck(Nrrd *Bcpts); /* hvol.c */ ! extern void baneProbe(double val[3], ! Nrrd *nin, baneHVolParm *hvp, gageContext *ctx, ! int x, int y, int z); ! extern int baneFindInclusion(double min[3], double max[3], ! Nrrd *nin, baneHVolParm *hvp, gageContext *ctx); ! extern int baneMakeHVol(Nrrd *hvol, Nrrd *nin, baneHVolParm *hvp); ! extern Nrrd *baneGKMSHVol(Nrrd *nin, float gradPerc, float hessPerc); /* trnsf.c */ ! extern int baneOpacInfo(Nrrd *info, Nrrd *hvol, int dim, int measr); ! extern int bane1DOpacInfoFrom2D(Nrrd *info1D, Nrrd *info2D); ! extern int baneSigmaCalc(float *sP, Nrrd *info); ! extern int banePosCalc(Nrrd *pos, float sigma, float gthresh, Nrrd *info); ! extern void _baneOpacCalcA(int lutLen, float *opacLut, ! int numCpts, float *xo, ! float *pos); ! extern void _baneOpacCalcB(int lutLen, float *opacLut, ! int numCpts, float *x, float *o, ! float *pos); ! extern int baneOpacCalc(Nrrd *opac, Nrrd *Bcpts, Nrrd *pos); /* trex.c */ ! extern float *_baneTRexRead(char *fname); ! extern void _baneTRexDone(); /* scat.c */ ! extern int baneRawScatterplots(Nrrd *nvg, Nrrd *nvh, Nrrd *hvol, int histEq); /* gkms{Flotsam,Hvol,Scat,Pvg,Opac,Mite}.c */ ! #define BANE_GKMS_DECLARE(C) extern bane_export unrrduCmd baneGkms_##C##Cmd; #define BANE_GKMS_LIST(C) &baneGkms_##C##Cmd, #define BANE_GKMS_MAP(F) \ --- 255,367 ---- ******** baneHVolParm struct ** ! ** Information for how to create a histogram volume. ** */ typedef struct { ! /* -------------- input */ ! int verbose, /* status messages to stderr */ ! makeMeasrVol, /* create a 3 x X x Y x Z volume of measurements, so that they aren't measured (as many as) three times */ ! renormalize, /* use gage's mask renormalization */ ! k3pack; const NrrdKernel *k[GAGE_KERNEL_NUM]; double kparm[GAGE_KERNEL_NUM][NRRD_KERNEL_PARMS_NUM]; baneClip *clip; double incLimit; /* lowest permissible fraction of the data remaining after new inclusion has been determined */ + baneAxis axis[3]; + /* -------------- internal */ + Nrrd *measrVol; + int measrVolDone; /* values in measrVol are filled */ } baneHVolParm; /* defaultsBane.c */ ! TEEM_API const char *baneBiffKey; ! TEEM_API int baneDefVerbose; ! TEEM_API int baneDefMakeMeasrVol; ! TEEM_API double baneDefIncLimit; ! TEEM_API int baneDefRenormalize; ! TEEM_API int baneDefPercHistBins; ! TEEM_API int baneStateHistEqBins; ! TEEM_API int baneStateHistEqSmart; ! TEEM_API int baneHack; /* rangeBane.c */ ! TEEM_API baneRange *baneRangeNew(int type); ! TEEM_API baneRange *baneRangeCopy(baneRange *range); ! TEEM_API int baneRangeAnswer(baneRange *range, ! double *ominP, double *omaxP, ! double imin, double imax); ! TEEM_API baneRange *baneRangeNix(baneRange *range); /* inc.c */ ! TEEM_API baneInc *baneIncNew(int type, baneRange *range, double *parm); ! TEEM_API void baneIncProcess(baneInc *inc, int passIdx, double val); ! TEEM_API int baneIncAnswer(baneInc *inc, double *minP, double *maxP); ! TEEM_API baneInc *baneIncCopy(baneInc *inc); ! TEEM_API baneInc *baneIncNix(baneInc *inc); /* clip.c */ ! TEEM_API baneClip *baneClipNew(int type, double *parm); ! TEEM_API int baneClipAnswer(int *countP, baneClip *clip, Nrrd *hvol); ! TEEM_API baneClip *baneClipCopy(baneClip *clip); ! TEEM_API baneClip *baneClipNix(baneClip *clip); ! ! /* measr.c */ ! TEEM_API baneMeasr *baneMeasrNew(int type, double *parm); ! TEEM_API double baneMeasrAnswer(baneMeasr *measr, gageContext *gctx); ! TEEM_API baneMeasr *baneMeasrCopy(baneMeasr *measr); ! TEEM_API baneMeasr *baneMeasrNix(baneMeasr *measr); /* methodsBane.c */ ! /* NOTE: this is NOT a complete API, like gage has. Currently there ! is only API for things that have to be allocated internally */ ! TEEM_API baneHVolParm *baneHVolParmNew(); ! TEEM_API void baneHVolParmGKMSInit(baneHVolParm *hvp); ! TEEM_API void baneHVolParmAxisSet(baneHVolParm *hvp, int axisIdx, ! int res, baneMeasr *measr, baneInc *inc); ! TEEM_API void baneHVolParmClipSet(baneHVolParm *hvp, baneClip *clip); ! TEEM_API baneHVolParm *baneHVolParmNix(baneHVolParm *hvp); /* valid.c */ ! TEEM_API int baneInputCheck(Nrrd *nin, baneHVolParm *hvp); ! TEEM_API int baneHVolCheck(Nrrd *hvol); ! TEEM_API int baneInfoCheck(Nrrd *info2D, int wantDim); ! TEEM_API int banePosCheck(Nrrd *pos, int wantDim); ! TEEM_API int baneBcptsCheck(Nrrd *Bcpts); /* hvol.c */ ! TEEM_API void baneProbe(double val[3], ! Nrrd *nin, baneHVolParm *hvp, gageContext *ctx, ! int x, int y, int z); ! TEEM_API int baneFindInclusion(double min[3], double max[3], ! Nrrd *nin, baneHVolParm *hvp, gageContext *ctx); ! TEEM_API int baneMakeHVol(Nrrd *hvol, Nrrd *nin, baneHVolParm *hvp); ! TEEM_API Nrrd *baneGKMSHVol(Nrrd *nin, float gradPerc, float hessPerc); /* trnsf.c */ ! TEEM_API int baneOpacInfo(Nrrd *info, Nrrd *hvol, int dim, int measr); ! TEEM_API int bane1DOpacInfoFrom2D(Nrrd *info1D, Nrrd *info2D); ! TEEM_API int baneSigmaCalc(float *sP, Nrrd *info); ! TEEM_API int banePosCalc(Nrrd *pos, float sigma, float gthresh, Nrrd *info); ! TEEM_API void _baneOpacCalcA(int lutLen, float *opacLut, ! int numCpts, float *xo, ! float *pos); ! TEEM_API void _baneOpacCalcB(int lutLen, float *opacLut, ! int numCpts, float *x, float *o, ! float *pos); ! TEEM_API int baneOpacCalc(Nrrd *opac, Nrrd *Bcpts, Nrrd *pos); /* trex.c */ ! TEEM_API float *_baneTRexRead(char *fname); ! TEEM_API void _baneTRexDone(); /* scat.c */ ! TEEM_API int baneRawScatterplots(Nrrd *nvg, Nrrd *nvh, Nrrd *hvol, int histEq); /* gkms{Flotsam,Hvol,Scat,Pvg,Opac,Mite}.c */ ! #define BANE_GKMS_DECLARE(C) TEEM_API unrrduCmd baneGkms_##C##Cmd; #define BANE_GKMS_LIST(C) &baneGkms_##C##Cmd, #define BANE_GKMS_MAP(F) \ *************** *** 399,408 **** F(txf) BANE_GKMS_MAP(BANE_GKMS_DECLARE) ! extern bane_export airEnum *baneGkmsMeasr; ! extern bane_export unrrduCmd *baneGkmsCmdList[]; ! extern void baneGkmsUsage(char *me, hestParm *hparm); ! extern bane_export hestCB *baneGkmsHestIncStrategy; ! extern bane_export hestCB *baneGkmsHestBEF; ! extern bane_export hestCB *baneGkmsHestGthresh; #ifdef __cplusplus --- 374,383 ---- F(txf) BANE_GKMS_MAP(BANE_GKMS_DECLARE) ! TEEM_API airEnum *baneGkmsMeasr; ! TEEM_API unrrduCmd *baneGkmsCmdList[]; ! TEEM_API void baneGkmsUsage(char *me, hestParm *hparm); ! TEEM_API hestCB *baneGkmsHestIncStrategy; ! TEEM_API hestCB *baneGkmsHestBEF; ! TEEM_API hestCB *baneGkmsHestGthresh; #ifdef __cplusplus Index: clip.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/clip.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** clip.c 7 Jan 2004 15:34:27 -0000 1.12 --- clip.c 19 Feb 2004 03:46:51 -0000 1.13 *************** *** 22,66 **** #include "privateBane.h" - /* ----------------- baneClipUnknown -------------------- */ int ! _baneClipUnknown_Ans(Nrrd *hvol, double *clipParm) { ! char me[]="_baneClipUnknown_Ans"; ! fprintf(stderr, "%s: a baneClip is unset somewhere ...\n", me); ! return -1; ! } ! ! baneClip ! _baneClipUnknown = { ! "unknown", ! baneClipUnknown_e, ! 0, ! _baneClipUnknown_Ans ! }; ! baneClip * ! baneClipUnknown = &_baneClipUnknown; ! ! /* ----------------- baneClipAbsolute -------------------- */ ! ! int ! _baneClipAbsolute_Ans(Nrrd *hvol, double *clipParm) { ! return clipParm[0]; } - baneClip - _baneClipAbsolute = { - "absolute", - baneClipAbsolute_e, - 1, - _baneClipAbsolute_Ans - }; - baneClip * - baneClipAbsolute = &_baneClipAbsolute; - - /* ----------------- baneClipPeakRatio -------------------- */ - int ! _baneClipPeakRatio_Ans(Nrrd *hvol, double *clipParm) { int *hits, maxhits; size_t idx, num; --- 22,35 ---- #include "privateBane.h" int ! _baneClipAnswer_Absolute(int *countP, Nrrd *hvol, double *clipParm) { ! *countP = clipParm[0]; ! return 0; } int ! _baneClipAnswer_PeakRatio(int *countP, Nrrd *hvol, double *clipParm) { int *hits, maxhits; size_t idx, num; *************** *** 73,104 **** } ! return maxhits*clipParm[0]; } - baneClip - _baneClipPeakRatio = { - "peak-ratio", - baneClipPeakRatio_e, - 1, - _baneClipPeakRatio_Ans - }; - baneClip * - baneClipPeakRatio = &_baneClipPeakRatio; - - /* ----------------- baneClipPercentile -------------------- */ - int ! _baneClipPercentile_Ans(Nrrd *hvol, double *clipParm) { ! char me[]="_baneClipPercentile", err[AIR_STRLEN_MED]; ! Nrrd *copy; int *hits, clip; size_t num, sum, out, outsofar, hi; ! if (nrrdCopy(copy=nrrdNew(), hvol)) { sprintf(err, "%s: couldn't create copy of histovol", me); ! biffMove(BANE, err, NRRD); return -1; } ! hits = copy->data; ! num = nrrdElementNumber(copy); qsort(hits, num, sizeof(int), nrrdValCompare[nrrdTypeInt]); sum = 0; --- 42,62 ---- } ! *countP = maxhits*clipParm[0]; ! return 0; } int ! _baneClipAnswer_Percentile(int *countP, Nrrd *hvol, double *clipParm) { ! char me[]="_baneClipAnswer_Percentile", err[AIR_STRLEN_MED]; ! Nrrd *ncopy; int *hits, clip; size_t num, sum, out, outsofar, hi; ! if (nrrdCopy(ncopy=nrrdNew(), hvol)) { sprintf(err, "%s: couldn't create copy of histovol", me); ! biffMove(BANE, err, NRRD); return 1; } ! hits = ncopy->data; ! num = nrrdElementNumber(ncopy); qsort(hits, num, sizeof(int), nrrdValCompare[nrrdTypeInt]); sum = 0; *************** *** 113,173 **** } while (outsofar < out); clip = hits[hi]; ! nrrdNuke(copy); ! return clip; } - baneClip - _baneClipPercentile = { - "percentile", - baneClipPercentile_e, - 1, - _baneClipPercentile_Ans - }; - baneClip * - baneClipPercentile = &_baneClipPercentile; - - /* ----------------- baneClipTopN -------------------- */ - int ! _baneClipTopN_Ans(Nrrd *hvol, double *clipParm) { ! char me[]="_baneClipTopN", err[AIR_STRLEN_MED]; Nrrd *copy; ! int *hits, clip; size_t num; if (nrrdCopy(copy=nrrdNew(), hvol)) { sprintf(err, "%s: couldn't create copy of histovol", me); ! biffMove(BANE, err, NRRD); return -1; } hits = copy->data; num = nrrdElementNumber(copy); qsort(hits, num, sizeof(int), nrrdValCompare[nrrdTypeInt]); ! clipParm[0] = AIR_CLAMP(0, (int)clipParm[0], num-1); ! clip = hits[num-(int)clipParm[0]-1]; nrrdNuke(copy); ! return clip; } - baneClip - _baneClipTopN = { - "top-N", - baneClipTopN_e, - 1, - _baneClipTopN_Ans - }; baneClip * ! baneClipTopN = &_baneClipTopN; ! /* --------------------------------------------------- */ baneClip * ! baneClipArray[BANE_CLIP_MAX+1] = { ! &_baneClipUnknown, ! &_baneClipAbsolute, ! &_baneClipPeakRatio, ! &_baneClipPercentile, ! &_baneClipTopN ! }; --- 71,186 ---- } while (outsofar < out); clip = hits[hi]; ! nrrdNuke(ncopy); ! *countP = clip; ! return 0; } int ! _baneClipAnswer_TopN(int *countP, Nrrd *hvol, double *clipParm) { ! char me[]="_baneClipAnwer_TopN", err[AIR_STRLEN_MED]; Nrrd *copy; ! int *hits, tmp; size_t num; if (nrrdCopy(copy=nrrdNew(), hvol)) { sprintf(err, "%s: couldn't create copy of histovol", me); ! biffMove(BANE, err, NRRD); return 1; } hits = copy->data; num = nrrdElementNumber(copy); qsort(hits, num, sizeof(int), nrrdValCompare[nrrdTypeInt]); ! tmp = AIR_CLAMP(0, (int)clipParm[0], num-1); ! *countP = hits[num-tmp-1]; nrrdNuke(copy); ! return 0; } baneClip * ! baneClipNew(int type, double *parm) { ! char me[]="baneClipNew", err[AIR_STRLEN_MED]; ! baneClip *clip; ! if (!( AIR_IN_OP(baneClipUnknown, type, baneClipLast) )) { ! sprintf(err, "%s: baneClip %d invalid", me, type); ! biffAdd(BANE, err); return NULL; ! } ! if (!parm) { ! sprintf(err, "%s: got NULL pointer", me); ! biffAdd(BANE, err); return NULL; ! } ! if (!(AIR_EXISTS(parm[0]))) { ! sprintf(err, "%s: parm[0] doesn't exist", me); ! biffAdd(BANE, err); return NULL; ! } ! clip = (baneClip*)calloc(1, sizeof(baneClip)); ! if (!clip) { ! sprintf(err, "%s: couldn't allocate baneClip!", me); ! biffAdd(BANE, err); return NULL; ! } ! clip->parm[0] = parm[0]; ! clip->type = type; ! switch(type) { ! case baneClipAbsolute: ! sprintf(clip->name, "absolute"); ! clip->answer = _baneClipAnswer_Absolute; ! break; ! case baneClipPeakRatio: ! sprintf(clip->name, "peak ratio"); ! clip->answer = _baneClipAnswer_PeakRatio; ! break; ! case baneClipPercentile: ! sprintf(clip->name, "percentile"); ! clip->answer = _baneClipAnswer_Percentile; ! break; ! case baneClipTopN: ! sprintf(clip->name, "top N"); ! clip->answer = _baneClipAnswer_TopN; ! break; ! default: ! sprintf(err, "%s: sorry, baneClip %d not implemented", me, type); ! biffAdd(BANE, err); baneClipNix(clip); return NULL; ! break; ! } ! return clip; ! } ! ! int ! baneClipAnswer(int *countP, baneClip *clip, Nrrd *hvol) { ! char me[]="baneClipAnswer", err[AIR_STRLEN_MED]; ! ! if (!( countP && clip && hvol )) { ! sprintf(err, "%s: got NULL pointer", me); ! biffAdd(BANE, err); return 0; ! } ! if (clip->answer(countP, hvol, clip->parm)) { ! sprintf(err, "%s: trouble", me); ! biffAdd(BANE, err); return 0; ! } ! return 0; ! } baneClip * ! baneClipCopy(baneClip *clip) { ! char me[]="baneClipCopy", err[AIR_STRLEN_MED]; ! baneClip *ret = NULL; ! ! ret = baneClipNew(clip->type, clip->parm); ! if (!ret) { ! sprintf(err, "%s: couldn't make new clip", me); ! biffAdd(BANE, err); return NULL; ! } ! return ret; ! } ! ! baneClip * ! baneClipNix(baneClip *clip) { ! ! if (clip) { ! airFree(clip->name); ! airFree(clip); ! } ! return NULL; ! } Index: defaultsBane.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/defaultsBane.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** defaultsBane.c 7 Jan 2004 15:34:27 -0000 1.6 --- defaultsBane.c 19 Feb 2004 03:46:51 -0000 1.7 *************** *** 29,37 **** baneDefMakeMeasrVol = AIR_TRUE; ! float baneDefIncLimit = 0.80; /* throwing away more than 20% is too much */ int ! baneDefRenormalize = AIR_FALSE; int --- 29,37 ---- baneDefMakeMeasrVol = AIR_TRUE; ! double baneDefIncLimit = 0.80; /* throwing away more than 20% is too much */ int ! baneDefRenormalize = AIR_TRUE; int Index: gkmsFlotsam.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/gkmsFlotsam.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gkmsFlotsam.c 7 Jan 2004 15:34:27 -0000 1.7 --- gkmsFlotsam.c 19 Feb 2004 03:46:51 -0000 1.8 *************** *** 28,32 **** ** baneGkmsParseIncStrategy ** ! ** inc[0]: member of baneInc*_e enum ** inc[1], inc[2] ... : incParm[0], incParm[1] ... */ --- 28,32 ---- ** baneGkmsParseIncStrategy ** ! ** inc[0]: member of baneInc* enum ** inc[1], inc[2] ... : incParm[0], incParm[1] ... */ *************** *** 43,72 **** inc = ptr; incParm = inc + 1; ! for (i=0; i<BANE_INC_PARM_NUM; i++) { incParm[i] = AIR_NAN; } if (1 == sscanf(str, "f:%lg", incParm+0) || 2 == sscanf(str, "f:%lg,%lg", incParm+0, incParm+1)) { ! inc[0] = baneIncRangeRatio_e; return 0; } if (1 == sscanf(str, "p:%lg", incParm+1) || 2 == sscanf(str, "p:%lg,%lg", incParm+1, incParm+2)) { ! inc[0] = baneIncPercentile_e; incParm[0] = baneDefPercHistBins; return 0; } if (3 == sscanf(str, "p:%d,%lg,%lg", &bins, incParm+1, incParm+2)) { ! inc[0] = baneIncPercentile_e; incParm[0] = bins; return 0; } if (2 == sscanf(str, "a:%lg,%lg", incParm+0, incParm+1)) { ! inc[0] = baneIncAbsolute_e; return 0; } if (1 == sscanf(str, "s:%lg", incParm+0) || 2 == sscanf(str, "s:%lg,%lg", incParm+1, incParm+2)) { ! inc[0] = baneIncStdv_e; return 0; } --- 43,72 ---- inc = ptr; incParm = inc + 1; ! for (i=0; i<BANE_PARM_NUM; i++) { incParm[i] = AIR_NAN; } if (1 == sscanf(str, "f:%lg", incParm+0) || 2 == sscanf(str, "f:%lg,%lg", incParm+0, incParm+1)) { ! inc[0] = baneIncRangeRatio; return 0; } if (1 == sscanf(str, "p:%lg", incParm+1) || 2 == sscanf(str, "p:%lg,%lg", incParm+1, incParm+2)) { ! inc[0] = baneIncPercentile; incParm[0] = baneDefPercHistBins; return 0; } if (3 == sscanf(str, "p:%d,%lg,%lg", &bins, incParm+1, incParm+2)) { ! inc[0] = baneIncPercentile; incParm[0] = bins; return 0; } if (2 == sscanf(str, "a:%lg,%lg", incParm+0, incParm+1)) { ! inc[0] = baneIncAbsolute; return 0; } if (1 == sscanf(str, "s:%lg", incParm+0) || 2 == sscanf(str, "s:%lg,%lg", incParm+1, incParm+2)) { ! inc[0] = baneIncStdv; return 0; } *************** *** 79,83 **** hestCB _baneGkmsHestIncStrategy = { ! (1+BANE_INC_PARM_NUM)*sizeof(double), "inclusion strategy", baneGkmsParseIncStrategy, --- 79,83 ---- hestCB _baneGkmsHestIncStrategy = { ! (1+BANE_PARM_NUM)*sizeof(double), "inclusion strategy", baneGkmsParseIncStrategy, Index: gkmsHvol.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/gkmsHvol.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gkmsHvol.c 7 Jan 2004 15:34:27 -0000 1.10 --- gkmsHvol.c 19 Feb 2004 03:46:51 -0000 1.11 *************** *** 36,40 **** airArray *mop; int pret, dim[3], lapl, i, j, perm[3] = {1,2,0}, slow, gz = AIR_FALSE; ! double inc[3*(1+BANE_INC_PARM_NUM)]; baneHVolParm *hvp; NrrdIoState *nio; --- 36,40 ---- airArray *mop; int pret, dim[3], lapl, i, j, perm[3] = {1,2,0}, slow, gz = AIR_FALSE; ! double inc[3*(1+BANE_PARM_NUM)]; baneHVolParm *hvp; NrrdIoState *nio; *************** *** 100,107 **** hvp->makeMeasrVol = !slow; ! hvp->ax[0].res = dim[perm[0]]; ! hvp->ax[1].res = dim[perm[1]]; ! hvp->ax[2].res = dim[perm[2]]; ! hvp->ax[1].measr = lapl ? baneMeasrLapl : baneMeasrHess; for (i=0; i<=2; i++) { hvp->ax[i].inc = baneIncArray[(int)inc[(1+BANE_INC_PARM_NUM)*perm[i]]]; --- 100,109 ---- hvp->makeMeasrVol = !slow; ! fprintf(stderr, "!%s: need to be using baneHVolParmAxisSet\n", me); ! /* ! hvp->axis[0].res = dim[perm[0]]; ! hvp->axis[1].res = dim[perm[1]]; ! hvp->axis[2].res = dim[perm[2]]; ! hvp->axis[1].measr = lapl ? baneMeasrLapl : baneMeasrHess; for (i=0; i<=2; i++) { hvp->ax[i].inc = baneIncArray[(int)inc[(1+BANE_INC_PARM_NUM)*perm[i]]]; *************** *** 110,113 **** --- 112,116 ---- } } + */ hvp->k3pack = AIR_TRUE; nrrdKernelParmSet(&hvp->k[gageKernel00], hvp->kparm[gageKernel00], ksp00); Index: hvol.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/hvol.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** hvol.c 7 Jan 2004 15:34:27 -0000 1.29 --- hvol.c 19 Feb 2004 03:46:51 -0000 1.30 *************** *** 37,41 **** _baneAxisCheck (baneAxis *ax) { char me[]="_baneAxisCheck", err[AIR_STRLEN_MED]; - int i; if (!(ax->res >= 2)) { --- 37,40 ---- *************** *** 47,76 **** biffAdd(BANE, err); return 1; } - for (i=0; i<ax->measr->numParm; i++) { - if (!AIR_EXISTS(ax->measrParm[i])) { - sprintf(err, "%s: didn't get %d parms for %s measurement", - me, ax->measr->numParm, ax->measr->name); - biffAdd(BANE, err); return 1; - } - } if (!ax->inc) { sprintf(err, "%s: have NULL baneInc", me); biffAdd(BANE, err); return 1; } - for (i=0; i<ax->inc->numParm; i++) { - if (!AIR_EXISTS(ax->incParm[i])) { - sprintf(err, "%s: didn't get %d parms for %s inclusion", - me, ax->inc->numParm, ax->inc->name); - biffAdd(BANE, err); return 1; - } - } - if (_baneInc_HistNew == ax->inc->histNew) { - /* a histogram is needed for inclusion */ - if (!( 3 < ax->incParm[0] )) { - sprintf(err, "%s: won't make a size-%d histogram for %s inclusion", - me, (int)(ax->incParm[0]), ax->inc->name); - biffAdd(BANE, err); return 1; - } - } /* all okay */ --- 46,53 ---- *************** *** 82,89 **** Nrrd *nin, baneHVolParm *hvp, gageContext *ctx, int x, int y, int z) { - gage_t *san; float *data=NULL; - san = ctx->pvl[0]->ans; if (hvp->makeMeasrVol) { data = ( (float*)(hvp->measrVol->data) --- 59,64 ---- *************** *** 92,98 **** if (!hvp->makeMeasrVol || !hvp->measrVolDone) { gageProbe(ctx, x, y, z); ! val[0] = hvp->ax[0].measr->ans(san, hvp->ax[0].measrParm); ! val[1] = hvp->ax[1].measr->ans(san, hvp->ax[1].measrParm); ! val[2] = hvp->ax[2].measr->ans(san, hvp->ax[2].measrParm); if (hvp->makeMeasrVol) { data[0] = val[0]; --- 67,73 ---- if (!hvp->makeMeasrVol || !hvp->measrVolDone) { gageProbe(ctx, x, y, z); ! val[0] = baneMeasrAnswer(hvp->axis[0].measr, ctx); ! val[1] = baneMeasrAnswer(hvp->axis[1].measr, ctx); ! val[2] = baneMeasrAnswer(hvp->axis[2].measr, ctx); if (hvp->makeMeasrVol) { data[0] = val[0]; *************** *** 122,134 **** sy = nin->axis[1].size; sz = nin->axis[2].size; ! inc[0] = hvp->ax[0].inc; ! inc[1] = hvp->ax[1].inc; ! inc[2] = hvp->ax[2].inc; if (hvp->verbose) { fprintf(stderr, "%s: inclusions: %s %s %s\n", me, inc[0]->name, inc[1]->name, inc[2]->name); fprintf(stderr, "%s: measures: %s %s %s\n", me, ! hvp->ax[0].measr->name, hvp->ax[1].measr->name, ! hvp->ax[2].measr->name); /* fprintf(stderr, "%s: gage query:\n", me); --- 97,109 ---- sy = nin->axis[1].size; sz = nin->axis[2].size; ! inc[0] = hvp->axis[0].inc; ! inc[1] = hvp->axis[1].inc; ! inc[2] = hvp->axis[2].inc; if (hvp->verbose) { fprintf(stderr, "%s: inclusions: %s %s %s\n", me, inc[0]->name, inc[1]->name, inc[2]->name); fprintf(stderr, "%s: measures: %s %s %s\n", me, ! hvp->axis[0].measr->name, hvp->axis[1].measr->name, ! hvp->axis[2].measr->name); /* fprintf(stderr, "%s: gage query:\n", me); *************** *** 137,159 **** } - E = 0; - if (!E) { - ai = 0; - E |= (!(hist[0] = inc[0]->histNew(hvp->ax[0].incParm))); - } - if (!E) { - ai = 1; - E |= (!(hist[1] = inc[1]->histNew(hvp->ax[1].incParm))); - } - if (!E) { - ai = 2; - E |= (!(hist[2] = inc[2]->histNew(hvp->ax[2].incParm))); - } - if (E) { - sprintf(err, "%s: trouble getting Nrrds for axis %d (%s) inclusions", - me, ai, aname[ai]); - biffAdd(BANE, err); return 1; - } - /* Determining the inclusion ranges for the histogram volume takes some work- either finding the min and max values of some measure, --- 112,115 ---- *************** *** 169,173 **** fflush(stderr); } ! if (inc[0]->passA || inc[1]->passA || inc[2]->passA) { /* fprintf(stderr, "%s: inclusion pass CBs = %p %p %p \n", me, --- 125,131 ---- fflush(stderr); } ! if (inc[0]->process[0] ! || inc[1]->process[0] ! || inc[2]->process[0]) { /* fprintf(stderr, "%s: inclusion pass CBs = %p %p %p \n", me, *************** *** 190,199 **** for (x=0; x<sx; x++) { baneProbe(val, nin, hvp, ctx, x, y, z); ! if (inc[0]->passA) inc[0]->passA(hist[0], val[0], ! hvp->ax[0].incParm); ! if (inc[1]->passA) inc[1]->passA(hist[1], val[1], ! hvp->ax[1].incParm); ! if (inc[2]->passA) inc[2]->passA(hist[2], val[2], ! hvp->ax[2].incParm); } } --- 148,154 ---- for (x=0; x<sx; x++) { baneProbe(val, nin, hvp, ctx, x, y, z); ! if (inc[0]->process[0]) inc[0]->process[0](inc[0], val[0]); ! if (inc[1]->process[0]) inc[1]->process[0](inc[1], val[1]); ! if (inc[2]->process[0]) inc[2]->process[0](inc[2], val[2]); } } *************** *** 218,222 **** fflush(stderr); } ! if (inc[0]->passB || inc[1]->passB || inc[2]->passB) { if (hvp->makeMeasrVol && !hvp->measrVol) { if (nrrdMaybeAlloc(hvp->measrVol=nrrdNew(), nrrdTypeFloat, 4, --- 173,179 ---- fflush(stderr); } ! if (inc[0]->process[1] ! || inc[1]->process[1] ! || inc[2]->process[1]) { if (hvp->makeMeasrVol && !hvp->measrVol) { if (nrrdMaybeAlloc(hvp->measrVol=nrrdNew(), nrrdTypeFloat, 4, *************** *** 235,244 **** for (x=0; x<sx; x++) { baneProbe(val, nin, hvp, ctx, x, y, z); ! if (inc[0]->passB) inc[0]->passB(hist[0], val[0], ! hvp->ax[0].incParm); ! if (inc[1]->passB) inc[1]->passB(hist[1], val[1], ! hvp->ax[1].incParm); ! if (inc[2]->passB) inc[2]->passB(hist[2], val[2], ! hvp->ax[2].incParm); } } --- 192,198 ---- for (x=0; x<sx; x++) { baneProbe(val, nin, hvp, ctx, x, y, z); ! if (inc[0]->process[1]) inc[0]->process[1](inc[0], val[0]); ! if (inc[1]->process[1]) inc[1]->process[1](inc[1], val[1]); ! if (inc[2]->process[1]) inc[2]->process[1](inc[2], val[2]); } } *************** *** 265,280 **** if (!E) { ai = 0; ! E |= inc[0]->ans(0 + min, 0 + max, hist[0], hvp->ax[0].incParm, ! hvp->ax[0].measr->range); } if (!E) { ai = 1; ! E |= inc[1]->ans(1 + min, 1 + max, hist[1], hvp->ax[1].incParm, ! hvp->ax[1].measr->range); } if (!E) { ai = 2; ! E |= inc[2]->ans(2 + min, 2 + max, hist[2], hvp->ax[2].incParm, ! hvp->ax[2].measr->range); } if (E) { --- 219,231 ---- if (!E) { ai = 0; ! E |= baneIncAnswer(inc[0], 0 + min, 0 + max); } if (!E) { ai = 1; ! E |= baneIncAnswer(inc[1], 1 + min, 1 + max); } if (!E) { ai = 2; ! E |= baneIncAnswer(inc[2], 2 + min, 2 + max); } if (E) { *************** *** 342,348 **** if (!E) E |= gageKernelSet(ctx, gageKernel22, hvp->k[gageKernel22], hvp->kparm[gageKernel22]); ! if (!E) E |= gageQuerySet(ctx, pvl, (hvp->ax[0].measr->query | ! hvp->ax[1].measr->query | ! hvp->ax[2].measr->query)); if (!E) E |= gageUpdate(ctx); if (E) { --- 293,300 ---- if (!E) E |= gageKernelSet(ctx, gageKernel22, hvp->k[gageKernel22], hvp->kparm[gageKernel22]); ! if (!E) E |= gageQueryReset(ctx, pvl); ! if (!E) E |= gageQueryAdd(ctx, pvl, hvp->axis[0].measr->query); ! if (!E) E |= gageQueryAdd(ctx, pvl, hvp->axis[1].measr->query); ! if (!E) E |= gageQueryAdd(ctx, pvl, hvp->axis[2].measr->query); if (!E) E |= gageUpdate(ctx); if (E) { *************** *** 383,389 **** fflush(stderr); } ! shx = hvp->ax[0].res; ! shy = hvp->ax[1].res; ! shz = hvp->ax[2].res; if (nrrdMaybeAlloc(rawhvol=nrrdNew(), nrrdTypeInt, 3, shx, shy, shz)) { sprintf(err, "%s: couldn't allocate raw histovol (%dx%dx%d)", me, --- 335,341 ---- fflush(stderr); } ! shx = hvp->axis[0].res; ! shy = hvp->axis[1].res; ! shz = hvp->axis[2].res; if (nrrdMaybeAlloc(rawhvol=nrrdNew(), nrrdTypeInt, 3, shx, shy, shz)) { sprintf(err, "%s: couldn't allocate raw histovol (%dx%dx%d)", me, *************** *** 433,438 **** /* determine the clipping value and produce the final histogram volume */ ! clipVal = hvp->clip->ans(rawhvol, hvp->clipParm); ! if (-1 == clipVal) { sprintf(err, "%s: trouble determining clip value", me); biffAdd(BANE, err); airMopError(mop); return 1; --- 385,389 ---- /* determine the clipping value and produce the final histogram volume */ ! if (baneClipAnswer(&clipVal, hvp->clip, rawhvol)) { sprintf(err, "%s: trouble determining clip value", me); biffAdd(BANE, err); airMopError(mop); return 1; *************** *** 455,461 **** hvol->axis[1].max = max[1]; hvol->axis[2].max = max[2]; ! hvol->axis[0].label = airStrdup(hvp->ax[0].measr->name); ! hvol->axis[1].label = airStrdup(hvp->ax[1].measr->name); ! hvol->axis[2].label = airStrdup(hvp->ax[2].measr->name); hvol->axis[0].center = nrrdCenterCell; hvol->axis[1].center = nrrdCenterCell; --- 406,412 ---- hvol->axis[1].max = max[1]; hvol->axis[2].max = max[2]; ! hvol->axis[0].label = airStrdup(hvp->axis[0].measr->name); ! hvol->axis[1].label = airStrdup(hvp->axis[1].measr->name); ! hvol->axis[2].label = airStrdup(hvp->axis[2].measr->name); hvol->axis[0].center = nrrdCenterCell; hvol->axis[1].center = nrrdCenterCell; *************** *** 494,499 **** } baneHVolParmGKMSInit(hvp); ! hvp->ax[0].incParm[1] = gradPerc; ! hvp->ax[1].incParm[1] = hessPerc; hvol = nrrdNew(); if (baneMakeHVol(hvol, nin, hvp)) { --- 445,450 ---- } baneHVolParmGKMSInit(hvp); ! hvp->axis[0].inc->parm[1] = gradPerc; ! hvp->axis[1].inc->parm[1] = hessPerc; hvol = nrrdNew(); if (baneMakeHVol(hvol, nin, hvp)) { Index: inc.c =================================================================== RCS file: /cvsroot/teem/teem/src/bane/inc.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** inc.c 7 Jan 2004 15:34:27 -0000 1.18 --- inc.c 19 Feb 2004 03:46:51 -0000 1.19 *************** *** 21,109 **** #include "privateBane.h" - Nrrd * - _baneInc_EmptyHistNew(double *incParm) { - - return nrrdNew(); - } - - Nrrd * - _baneInc_HistNew(double *incParm) { - char me[]="_baneInc_HistNew", err[AIR_STRLEN_MED]; - Nrrd *nhist; - - if (nrrdMaybeAlloc(nhist=nrrdNew(), nrrdTypeInt, 1, (int)(incParm[0]))) { - sprintf(err, "%s: ", me); - biffMove(BANE, err, NRRD); return NULL; - } - return nhist; - } - - /* - ** _baneInc_LearnMinMax() and _baneInc_HistFill() are - ** candidates for the baneIncPass *passA and *passB - ** that are in the baneInc struct - */ - void ! _baneInc_LearnMinMax(Nrrd *n, double val, double *incParm) { ! if (AIR_EXISTS(n->axis[0].min)) { /* then both min and max have seen at least one valid value */ ! n->axis[0].min = AIR_MIN(n->axis[0].min, val); ! n->axis[0].max = AIR_MAX(n->axis[0].max, val); } else { ! n->axis[0].min = n->axis[0].max = val; } /* fprintf(stderr, "## _baneInc_LearnMinMax: (%g,%g)\n", ! n->axis[0].min, n->axis[0].max); */ } void ! _baneInc_HistFill(Nrrd *n, double val, double *incParm) { int idx, *hist; ! AIR_INDEX(n->axis[0].min, val, n->axis[0].max, n->axis[0].size, idx); /* fprintf(stderr, "## _baneInc_HistFill: (%g,%g,%g) %d ---> %d\n", ! n->axis[0].min, val, n->axis[0].max, n->axis[0].size, idx); */ ! if (AIR_IN_CL(0, idx, n->axis[0].size-1)) { ! hist = (int*)n->data; hist[idx]++; } } - /* ----------------- baneIncUnknown -------------------- */ - - int - _baneIncUnknown_Ans(double *minP, double *maxP, - Nrrd *hist, double *incParm, - baneRange *range) { - char me[]="_baneIncUnknown_Ans", err[AIR_STRLEN_MED]; - - sprintf(err, "%s: a baneInc is unset", me); - biffAdd(BANE, err); - return 1; - } - - baneInc - _baneIncUnknown = { - "unknown", - baneIncUnknown_e, - 0, - _baneInc_EmptyHistNew, - NULL, - NULL, - _baneIncUnknown_Ans - }; - baneInc * - baneIncUnknown = &_baneIncUnknown; - - /* ----------------- baneIncAbsolute -------------------- */ - /* ! ** _baneIncAbsolute_Ans ** ** incParm[0]: new min --- 21,70 ---- #include "privateBane.h" void ! _baneIncProcess_LearnMinMax(baneInc *inc, double val) { ! if (AIR_EXISTS(inc->nhist->axis[0].min)) { /* then both min and max have seen at least one valid value */ ! inc->nhist->axis[0].min = AIR_MIN(inc->nhist->axis[0].min, val); ! inc->nhist->axis[0].max = AIR_MAX(inc->nhist->axis[0].max, val); } else { ! inc->nhist->axis[0].min = inc->nhist->axis[0].max = val; } /* fprintf(stderr, "## _baneInc_LearnMinMax: (%g,%g)\n", ! inc->nhist->axis[0].min, inc->nhist->axis[0].max); */ + return; + } + + void + _baneIncProcess_Stdv(baneInc *inc, double val) { + + inc->S += val; + inc->SS += val*val; + inc->num += 1; + return; } void ! _baneIncProcess_HistFill(baneInc *inc, double val) { int idx, *hist; ! AIR_INDEX(inc->nhist->axis[0].min, val, inc->nhist->axis[0].max, ! inc->nhist->axis[0].size, idx); /* fprintf(stderr, "## _baneInc_HistFill: (%g,%g,%g) %d ---> %d\n", ! inc->nhist->axis[0].min, val, inc->nhist->axis[0].max, ! inc->nhist->axis[0].size, idx); */ ! if (AIR_IN_CL(0, idx, inc->nhist->axis[0].size-1)) { ! hist = (int*)inc->nhist->data; hist[idx]++; } + return; } /* ! ** _baneIncAnswer_Absolute ** ** incParm[0]: new min *************** *** 111,117 **** */ int ! _baneIncAbsolute_Ans(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { *minP = incParm[0]; *maxP = incParm[1]; --- 72,78 ---- */ int ! _baneIncAnswer_Absolute(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { *minP = incParm[0]; *maxP = incParm[1]; *************** *** 119,159 **** } - baneInc - _baneIncAbsolute = { - "absolute", - baneIncAbsolute_e, - 2, - _baneInc_EmptyHistNew, - NULL, - NULL, - _baneIncAbsolute_Ans - }; - baneInc * - baneIncAbsolute = &_baneIncAbsolute; - - /* ----------------- baneIncRangeRatio -------------------- */ - /* ! ** _baneIncRangeRatio_Ans ** ** incParm[0]: scales the size of the range after it has been ** sent through the associated range function. - ** incParm[1]: (optional) for baneRangeFloat: midpoint of scaling; - ** if doesn't exist, average of min and max is used. For all other - ** range types, 0 is always used. */ int ! _baneIncRangeRatio_Ans(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { ! char me[]="_baneIncRangeRatio_Ans", err[AIR_STRLEN_MED]; double mid; ! if (range->ans(minP, maxP, hist->axis[0].min, hist->axis[0].max)) { ! sprintf(err, "%s:", me); biffAdd(BANE, err); return 1; } ! ! if (baneRangeFloat_e == range->which) { ! mid = AIR_EXISTS(incParm[1]) ? incParm[1] : (*minP + *maxP)/2; *minP = AIR_AFFINE(-1, -incParm[0], 0, *minP, mid); *maxP = AIR_AFFINE(0, incParm[0], 1, mid, *maxP); --- 80,103 ---- } /* ! ** _baneIncAnswer_RangeRatio ** ** incParm[0]: scales the size of the range after it has been ** sent through the associated range function. */ int ! _baneIncAnswer_RangeRatio(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { ! char me[]="_baneIncAnwer_RangeRatio", err[AIR_STRLEN_MED]; double mid; ! if (range->answer(minP, maxP, hist->axis[0].min, hist->axis[0].max)) { ! sprintf(err, "%s: trouble", me); ! biffAdd(BANE, err); return 1; } ! ! if (baneRangeAnywhere == range->type) { ! mid = AIR_EXISTS(range->center) ? range->center : (*minP + *maxP)/2; *minP = AIR_AFFINE(-1, -incParm[0], 0, *minP, mid); *maxP = AIR_AFFINE(0, incParm[0], 1, mid, *maxP); *************** *** 165,186 **** } - baneInc - _baneIncRangeRatio = { - "range-ratio", - baneIncRangeRatio_e, - 1, /* HEY: only one is required, two can be used */ - _baneInc_EmptyHistNew, - NULL, - _baneInc_LearnMinMax, - _baneIncRangeRatio_Ans - }; - baneInc * - baneIncRangeRatio = &_baneIncRangeRatio; - - - /* ----------------- baneIncPercentile -------------------- */ - /* ! ** _baneIncPercentile_Ans ** ** incParm[0]: resolution of histogram generated --- 109,114 ---- } /* ! ** _baneIncAnswer_Percentile ** ** incParm[0]: resolution of histogram generated *************** *** 188,201 **** ** lower and upper ends of range, in a manner dependant on the ** range type - ** incParm[2]: (optional) for baneRangeFloat, center value - ** that we nibble towards. If it doesn't exist, we use the - ** average of the min and max (though perhaps the mode value would - ** be better). For all other range types, we nibble towards 0. */ int ! _baneIncPercentile_Ans(double *minP, double *maxP, ! Nrrd *nhist, double *incParm, ! baneRange *range) { ! char me[]="_baneIncPercentile_Ans", err[AIR_STRLEN_MED]; int *hist, i, histSize, sum; float minIncr, maxIncr, out, outsofar, mid, minIdx, maxIdx; --- 116,125 ---- ** lower and upper ends of range, in a manner dependant on the ** range type */ int ! _baneIncAnswer_Percentile(double *minP, double *maxP, ! Nrrd *nhist, double *incParm, ! baneRange *range) { ! char me[]="_baneIncAnswer_Percentile", err[AIR_STRLEN_MED]; int *hist, i, histSize, sum; float minIncr, maxIncr, out, outsofar, mid, minIdx, maxIdx; *************** *** 220,224 **** fprintf(stderr, "##%s: hist's size=%d, sum=%d --> out = %g\n", me, histSize, sum, out); ! if (range->ans(&min, &max, nhist->axis[0].min, nhist->axis[0].max)) { sprintf(err, "%s:", me); biffAdd(BANE, err); return 1; } --- 144,148 ---- fprintf(stderr, "##%s: hist's size=%d, sum=%d --> out = %g\n", me, histSize, sum, out); ! if (range->answer(&min, &max, nhist->axis[0].min, nhist->axis[0].max)) { sprintf(err, "%s:", me); biffAdd(BANE, err); return 1; } *************** *** 226,231 **** me, nhist->axis[0].min, nhist->axis[0].max, range->name, min, max); ! if (baneRangeFloat_e == range->which) { ! mid = AIR_EXISTS(incParm[2]) ? incParm[2] : (min + max)/2; } else { mid = 0; --- 150,155 ---- me, nhist->axis[0].min, nhist->axis[0].max, range->name, min, max); ! if (baneRangeAnywhere == range->type) { ! mid = AIR_EXISTS(range->center) ? range->center : (min + max)/2; } else { mid = 0; *************** *** 233,237 **** from both ends, but we control the rate of marching according to the distance to the ends. So if min == mid == 0, then ! there is no marching up from below */ } fprintf(stderr, "##%s: hist (%g,%g) --> min,max = (%g,%g) --> mid = %g\n", --- 157,162 ---- from both ends, but we control the rate of marching according to the distance to the ends. So if min == mid == 0, then ! there is no marching up from below ! HOWEVER: the mode of histogram would probably be better ... */ } fprintf(stderr, "##%s: hist (%g,%g) --> min,max = (%g,%g) --> mid = %g\n", *************** *** 279,339 **** } - baneInc - _baneIncPercentile = { - "percentile", - baneIncPercentile_e, - 2, /* HEY: only 2 are required, three can be used */ - _baneInc_HistNew, - _baneInc_LearnMinMax, - _baneInc_HistFill, - _baneIncPercentile_Ans, - }; - baneInc * - baneIncPercentile = &_baneIncPercentile; - - /* ----------------- baneIncStdv -------------------- */ - - Nrrd * - _baneIncStdv_EmptyHistNew(double *incParm) { - Nrrd *hist; - - hist = nrrdNew(); - /* this is a total horrid sham and a hack: we don't need a histogram - at all; but we're going to use axis[1].min to store the sum of - all values, and axis[1].max to store the sum of all squared - values, and axis[1].size to store the number of values. It may - be tempting to use incParm for this, but its only meant for - input and we can't surprise anyone by over-writing values. - - The road to hell ... - */ - hist->axis[1].min = 0.0; - hist->axis[1].max = 0.0; - hist->axis[1].size = 0; - return hist; - } - - void - _baneIncStdv_Pass(Nrrd *hist, double val, double *incParm) { - - _baneInc_LearnMinMax(hist, val, incParm); - hist->axis[1].min += val; - hist->axis[1].max += val*val; - hist->axis[1].size += 1; - } - - /* ! ** _baneIncStdv_Ans() ** ** incParm[0]: range is standard deviation times this - ** incParm[1]: (optional) for baneRangeFloat: if exists, the midpoint - ** of the range, otherwise the mean is used. For all other range - ** types, the range is positioned in the logical way. */ int ! _baneIncStdv_Ans(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { float SS, stdv, mid, mean, width; int count; --- 204,216 ---- } /* ! ** _baneIncAnswer_Stdv() ** ** incParm[0]: range is standard deviation times this */ int ! _baneIncAnswer_Stdv(double *minP, double *maxP, ! Nrrd *hist, double *incParm, ! baneRange *range) { float SS, stdv, mid, mean, width; int count; *************** *** 345,364 **** width = incParm[0]*stdv; fprintf(stderr, "##%s: mean=%g, stdv=%g --> width=%g\n", ! "_baneIncStdv_Ans", mean, stdv, width); ! switch (range->which) { ! case baneRangePos_e: *minP = 0; *maxP = width; break; ! case baneRangeNeg_e: *minP = -width; *maxP = 0; break; ! case baneRangeZeroCent_e: *minP = -width/2; *maxP = width/2; break; ! case baneRangeFloat_e: ! mid = AIR_EXISTS(incParm[1]) ? incParm[1] : mean; *minP = mid - width/2; *maxP = mid + width/2; --- 222,241 ---- width = incParm[0]*stdv; fprintf(stderr, "##%s: mean=%g, stdv=%g --> width=%g\n", ! "_baneIncAnswer_Stdv", mean, stdv, width); ! switch (range->type) { ! case baneRangePositive: *minP = 0; *maxP = width; break; ! case baneRangeNegative: *minP = -width; *maxP = 0; break; ! case baneRangeZeroCentered: *minP = -width/2; *maxP = width/2; break; ! case baneRangeAnywhere: ! mid = AIR_EXISTS(range->center) ? range->center : mean; *minP = mid - width/2; *maxP = mid + width/2; *******... [truncated message content] |