|
From: <kin...@us...> - 2004-02-27 10:32:33
|
Update of /cvsroot/teem/teem/src/ten In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13768 Modified Files: GNUmakefile chan.c epireg.c miscTen.c ten.h tendGrads.c Log Message: added tenGradientGenerate and tenGradientDistributed, which are accessed via "tend grads" Index: GNUmakefile =================================================================== RCS file: /cvsroot/teem/teem/src/ten/GNUmakefile,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** GNUmakefile 26 Feb 2004 18:42:23 -0000 1.37 --- GNUmakefile 27 Feb 2004 10:23:55 -0000 1.38 *************** *** 47,51 **** $(L).PUBLIC_HEADERS = ten.h tenMacros.h $(L).PRIVATE_HEADERS = privateTen.h ! $(L).OBJS = tensor.o chan.o aniso.o glyph.o enumsTen.o miscTen.o mod.o \ tenGage.o fiberMethods.o fiber.o epireg.o defaultsTen.o bimod.o \ tendFlotsam.o tendGrads.o tendAnplot.o tendAnvol.o tendEval.o \ --- 47,51 ---- $(L).PUBLIC_HEADERS = ten.h tenMacros.h $(L).PRIVATE_HEADERS = privateTen.h ! $(L).OBJS = tensor.o chan.o aniso.o glyph.o enumsTen.o grads.o miscTen.o mod.o \ tenGage.o fiberMethods.o fiber.o epireg.o defaultsTen.o bimod.o \ tendFlotsam.o tendGrads.o tendAnplot.o tendAnvol.o tendEval.o \ Index: chan.c =================================================================== RCS file: /cvsroot/teem/teem/src/ten/chan.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** chan.c 7 Jan 2004 15:34:31 -0000 1.29 --- chan.c 27 Feb 2004 10:23:56 -0000 1.30 *************** *** 44,48 **** airArray *mop; ! if (!(nbmat && _ngrad && !tenGradCheck(_ngrad))) { sprintf(err, "%s: got NULL pointer or invalid arg", me); biffAdd(TEN, err); return 1; --- 44,48 ---- airArray *mop; ! if (!(nbmat && _ngrad && !tenGradientCheck(_ngrad, nrrdTypeUnknown, 1))) { sprintf(err, "%s: got NULL pointer or invalid arg", me); biffAdd(TEN, err); return 1; Index: epireg.c =================================================================== RCS file: /cvsroot/teem/teem/src/ten/epireg.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** epireg.c 16 Jan 2004 17:35:12 -0000 1.24 --- epireg.c 27 Feb 2004 10:23:56 -0000 1.25 *************** *** 60,64 **** biffAdd(TEN, err); return 1; } ! if (tenGradCheck(ngrad)) { sprintf(err, "%s: problem with given gradient list", me); biffAdd(TEN, err); return 1; --- 60,64 ---- biffAdd(TEN, err); return 1; } ! if (tenGradientCheck(ngrad, nrrdTypeUnknown, 6 /* <-- HEY: not sure */)) { sprintf(err, "%s: problem with given gradient list", me); biffAdd(TEN, err); return 1; Index: miscTen.c =================================================================== RCS file: /cvsroot/teem/teem/src/ten/miscTen.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** miscTen.c 7 Jan 2004 15:34:31 -0000 1.21 --- miscTen.c 27 Feb 2004 10:23:56 -0000 1.22 *************** *** 183,208 **** int - tenGradCheck(Nrrd *ngrad) { - char me[]="tenGradCheck", err[AIR_STRLEN_MED]; - - if (nrrdCheck(ngrad)) { - sprintf(err, "%s: basic validity check failed", me); - biffMove(TEN, err, NRRD); return 1; - } - if (!( 3 == ngrad->axis[0].size && 2 == ngrad->dim )) { - sprintf(err, "%s: need a 3xN 2-D array (not a %dxN %d-D array)", - me, ngrad->axis[0].size, ngrad->dim); - biffAdd(TEN, err); return 1; - } - if (!( 6 <= ngrad->axis[1].size )) { - sprintf(err, "%s: have only %d gradients, need at least 6", - me, ngrad->axis[1].size); - biffAdd(TEN, err); return 1; - } - - return 0; - } - - int tenBMatrixCheck(Nrrd *nbmat) { char me[]="tenBMatrixCheck", err[AIR_STRLEN_MED]; --- 183,186 ---- Index: ten.h =================================================================== RCS file: /cvsroot/teem/teem/src/ten/ten.h,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** ten.h 26 Feb 2004 18:42:23 -0000 1.76 --- ten.h 27 Feb 2004 10:23:56 -0000 1.77 *************** *** 380,384 **** minVelocity, jitter; ! int snap, single, minIteration, maxIteration; } tenGradientParm; --- 380,384 ---- minVelocity, jitter; ! int srand, snap, single, minIteration, maxIteration; } tenGradientParm; *************** *** 395,398 **** --- 395,405 ---- /* grads.c */ + TEEM_API tenGradientParm *tenGradientParmNew(void); + TEEM_API tenGradientParm *tenGradientParmNix(tenGradientParm *tgparm); + TEEM_API int tenGradientCheck(Nrrd *ngrad, int type, int minnum); + TEEM_API int tenGradientRandom(Nrrd *ngrad, int num, int srand); + TEEM_API int tenGradientJitter(Nrrd *nout, Nrrd *nin, double dist); + TEEM_API int tenGradientDistribute(Nrrd *nout, Nrrd *nin, tenGradientParm *tgparm); + TEEM_API int tenGradientGenerate(Nrrd *nout, int num, tenGradientParm *tgparm); /* enumsTen.c */ *************** *** 457,461 **** TEEM_API int tenEvqVolume(Nrrd *nout, Nrrd *nin, int which, int aniso, int scaleByAniso); - TEEM_API int tenGradCheck(Nrrd *ngrad); TEEM_API int tenBMatrixCheck(Nrrd *nbmat); TEEM_API int _tenFindValley(float *valP, Nrrd *nhist, float tweak); --- 464,467 ---- Index: tendGrads.c =================================================================== RCS file: /cvsroot/teem/teem/src/ten/tendGrads.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tendGrads.c 26 Feb 2004 18:44:50 -0000 1.1 --- tendGrads.c 27 Feb 2004 10:23:56 -0000 1.2 *************** *** 25,29 **** (INFO ", based on a simulation of anti-podal point pairs repelling each other " ! "on the unit sphere surface. "); int --- 25,30 ---- (INFO ", based on a simulation of anti-podal point pairs repelling each other " ! "on the unit sphere surface. This can either distribute more uniformly a given " ! "set of gradients, or it can make a new distribution from scratch. "); int *************** *** 34,46 **** airArray *mop; ! Nrrd *ngrad, *nout; char *outS; ! ! hestOptAdd(&hopt, "i", "grads", airTypeOther, 1, 1, &ngrad, NULL, ! "array of gradient directions", NULL, NULL, nrrdHestNrrd); ! hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", ! "output B matrix"); mop = airMopNew(); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(_tend_gradsInfoL); --- 35,76 ---- airArray *mop; ! int num, E, nosrand; ! Nrrd *nin, *nout; char *outS; ! tenGradientParm *tgparm; mop = airMopNew(); + tgparm = tenGradientParmNew(); + airMopAdd(mop, tgparm, (airMopper)tenGradientParmNix, airMopAlways); + + hestOptAdd(&hopt, "n", "# dir", airTypeInt, 1, 1, &num, "6", + "desired number of diffusion gradient directions"); + hestOptAdd(&hopt, "i", "grads", airTypeOther, 1, 1, &nin, "", + "initial gradient directions to start with, instead " + "of default random initial directions (overrides \"-n\")", + NULL, NULL, nrrdHestNrrd); + hestOptAdd(&hopt, "nosrand", NULL, airTypeInt, 0, 0, &nosrand, NULL, + "do NOT call srand() to initialize random number generator"); + hestOptAdd(&hopt, "dt", "dt", airTypeDouble, 1, 1, &(tgparm->dt), "0.05", + "time increment in solver"); + hestOptAdd(&hopt, "drag", "drag", airTypeDouble, 1, 1, &(tgparm->drag), "0.01", + "viscous drag, to keep things stable"); + hestOptAdd(&hopt, "charge", "charge", airTypeDouble, 1, 1, &(tgparm->charge), "0.2", + "amount of charge on each particle"); + hestOptAdd(&hopt, "single", NULL, airTypeInt, 0, 0, &(tgparm->single), NULL, + "instead of the default behavior of tracking a pair of " + "antipodal points (appropriate for determining DWI gradients), " + "use only single points (appropriate for who knows what)."); + hestOptAdd(&hopt, "snap", "interval", airTypeInt, 1, 1, &(tgparm->snap), "0", + "specifies an interval between which snapshots of the point " + "positions should be saved out. By default (not using this " + "option), there is no such snapshot behavior"); + hestOptAdd(&hopt, "jitter", "jitter", airTypeDouble, 1, 1, &(tgparm->jitter), "0.05", + "amount by which to perturb points when given an input nrrd"); + hestOptAdd(&hopt, "maxiter", "# iters", airTypeInt, 1, 1, + &(tgparm->maxIteration), "1000000", + "max number of iterations for which to run the simulation"); + hestOptAdd(&hopt, "o", "filename", airTypeString, 1, 1, &outS, "-", + "file to write output nrrd to"); airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); USAGE(_tend_gradsInfoL); *************** *** 50,53 **** --- 80,92 ---- airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); + tgparm->srand = !nosrand; + E = (nin + ? tenGradientDistribute(nout, nin, tgparm) + : tenGradientGenerate(nout, num, tgparm)); + if (E) { + airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); + fprintf(stderr, "%s: trouble making distribution:\n%s\n", me, err); + airMopError(mop); return 1; + } if (nrrdSave(outS, nout, NULL)) { |