|
From: <kin...@us...> - 2023-07-07 21:53:35
|
Revision: 7047
http://sourceforge.net/p/teem/code/7047
Author: kindlmann
Date: 2023-07-07 21:53:33 +0000 (Fri, 07 Jul 2023)
Log Message:
-----------
Propaging AIR_STRLEN --> AIR_STRLEN+1, with API CHANGEs to these structs:
tenModel:
char name[AIR_STRLEN_SMALL + 1];
char *(*sprint)(char str[AIR_STRLEN_MED + 1], const double *parm);
tenModelParmDesc:
char name[AIR_STRLEN_SMALL + 1]; /* name */
Modified Paths:
--------------
teem/trunk/src/ten/aniso.c
teem/trunk/src/ten/bimod.c
teem/trunk/src/ten/bvec.c
teem/trunk/src/ten/chan.c
teem/trunk/src/ten/epireg.c
teem/trunk/src/ten/estimate.c
teem/trunk/src/ten/experSpec.c
teem/trunk/src/ten/glyph.c
teem/trunk/src/ten/grads.c
teem/trunk/src/ten/miscTen.c
teem/trunk/src/ten/model1Cylinder.c
teem/trunk/src/ten/model1Stick.c
teem/trunk/src/ten/model1Tensor2.c
teem/trunk/src/ten/model1Unit2D.c
teem/trunk/src/ten/model1Vector2D.c
teem/trunk/src/ten/model2Unit2D.c
teem/trunk/src/ten/modelB0.c
teem/trunk/src/ten/modelBall.c
teem/trunk/src/ten/modelBall1Cylinder.c
teem/trunk/src/ten/modelBall1Stick.c
teem/trunk/src/ten/modelBall1StickEMD.c
teem/trunk/src/ten/modelZero.c
teem/trunk/src/ten/path.c
teem/trunk/src/ten/ten.h
teem/trunk/src/ten/tenModel.c
teem/trunk/src/ten/tendAbout.c
teem/trunk/src/ten/tendBfit.c
teem/trunk/src/ten/tendFlotsam.c
teem/trunk/src/ten/tendGlyph.c
teem/trunk/src/ten/tendSatin.c
teem/trunk/src/ten/tensor.c
teem/trunk/src/ten/test/csim.c
teem/trunk/src/ten/test/tensorDotDat.c
teem/trunk/src/ten/triple.c
Modified: teem/trunk/src/ten/aniso.c
===================================================================
--- teem/trunk/src/ten/aniso.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/aniso.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -1216,12 +1216,12 @@
}
if (nrrdElementNumber(nwght)
!= nrrdElementNumber(nin) / nrrdKindSize(nrrdKind3DMaskedSymMatrix)) {
- char stmp1[AIR_STRLEN_SMALL], stmp2[AIR_STRLEN_SMALL];
+ char stmp[2][AIR_STRLEN_SMALL + 1];
size_t numten;
numten = nrrdElementNumber(nin) / nrrdKindSize(nrrdKind3DMaskedSymMatrix);
biffAddf(TEN, "%s: # elements in weight nrrd (%s) != # tensors (%s)", me,
- airSprintSize_t(stmp1, nrrdElementNumber(nwght)),
- airSprintSize_t(stmp2, numten));
+ airSprintSize_t(stmp[0], nrrdElementNumber(nwght)),
+ airSprintSize_t(stmp[1], numten));
return 1;
}
}
Modified: teem/trunk/src/ten/bimod.c
===================================================================
--- teem/trunk/src/ten/bimod.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/bimod.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -249,7 +249,7 @@
static void
_tenEMBimodalSaveImage(tenEMBimodalParm *biparm) {
- char name[AIR_STRLEN_MED];
+ char name[AIR_STRLEN_MED + 1];
Nrrd *nh, *nm, *nhi, *nmi, *ni;
NrrdRange *range;
const Nrrd *nhmhi[3];
Modified: teem/trunk/src/ten/bvec.c
===================================================================
--- teem/trunk/src/ten/bvec.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/bvec.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -102,7 +102,7 @@
int map[NRRD_DIM_MAX], vecSize, iter;
size_t ii, size[NRRD_DIM_MAX], vecI, vecNum;
char *vec;
- double *out, ss[AIR_STRLEN_SMALL], amp, dec, d_amp, d_dec, error, diff,
+ double *out, ss[AIR_STRLEN_SMALL + 1], amp, dec, d_amp, d_dec, error, diff,
(*vecLup)(const void *v, size_t I);
if (!(nout && nin && bb && ww)) {
@@ -114,10 +114,10 @@
biffAddf(TEN, "%s: nin->dim (%d) not >= 2", me, nin->dim);
return 1;
}
- if (!(nin->axis[0].size < AIR_STRLEN_SMALL)) {
- char stmp[AIR_STRLEN_SMALL];
+ if (!(nin->axis[0].size < AIR_STRLEN_SMALL + 1)) {
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: sorry need nin->axis[0].size (%s) < %d", me,
- airSprintSize_t(stmp, nin->axis[0].size), AIR_STRLEN_SMALL);
+ airSprintSize_t(stmp, nin->axis[0].size), AIR_STRLEN_SMALL + 1);
return 1;
}
Modified: teem/trunk/src/ten/chan.c
===================================================================
--- teem/trunk/src/ten/chan.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/chan.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -60,7 +60,7 @@
tenDWMRIKeyValueParse(Nrrd **ngradP, Nrrd **nbmatP, double *bP, unsigned int **skipP,
unsigned int *skipNumP, const Nrrd *ndwi) {
static const char me[] = "tenDWMRIKeyValueParse";
- char tmpKey[AIR_STRLEN_MED], key[AIR_STRLEN_MED], *val;
+ char tmpKey[AIR_STRLEN_MED + 1], key[AIR_STRLEN_MED + 1], *val;
const char *keyFmt;
int dwiAxis;
unsigned int axi, dwiIdx, dwiNum, valNum, valIdx, parsedNum, nexNum, nexIdx, skipIdx,
@@ -638,7 +638,7 @@
double *emat, *bmat, *vbuf;
NrrdRange *range;
float te, d1, d2;
- char stmp[2][AIR_STRLEN_SMALL];
+ char stmp[2][AIR_STRLEN_SMALL + 1];
if (!(nten && ndwi && _nbmat)) {
/* nerrP and _NB0P can be NULL */
@@ -876,7 +876,7 @@
airArray *mop;
double *bmat;
float *dwi, *ten, (*lup)(const void *, size_t I);
- char stmp[6][AIR_STRLEN_SMALL];
+ char stmp[6][AIR_STRLEN_SMALL + 1];
if (!ndwi || !nT2 || !nten || !_nbmat
|| tenTensorCheck(nten, nrrdTypeFloat, AIR_TRUE, AIR_TRUE)
Modified: teem/trunk/src/ten/epireg.c
===================================================================
--- teem/trunk/src/ten/epireg.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/epireg.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -67,7 +67,7 @@
return 1;
}
if (dwiLen != ngrad->axis[1].size) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: got %u DWIs, but %s gradient directions", me, dwiLen,
airSprintSize_t(stmp, ngrad->axis[1].size));
return 1;
@@ -1244,7 +1244,7 @@
}
*/
if (ninLen != _ngrad->axis[1].size) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: ninLen %u != # grads %s", me, ninLen,
airSprintSize_t(stmp, _ngrad->axis[1].size));
return 1;
Modified: teem/trunk/src/ten/estimate.c
===================================================================
--- teem/trunk/src/ten/estimate.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/estimate.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -1043,7 +1043,7 @@
unsigned int tt, allIdx;
int axmap[4], E;
airArray *mop;
- char stmp[3][AIR_STRLEN_SMALL];
+ char stmp[3][AIR_STRLEN_SMALL + 1];
if (!(tec && ndwi && nB0 && nten)) {
biffAddf(TEN, "%s: got NULL pointer", me);
@@ -1126,7 +1126,7 @@
return 1;
}
if (keyValueSet) {
- char keystr[AIR_STRLEN_MED], valstr[AIR_STRLEN_MED];
+ char keystr[AIR_STRLEN_MED + 1], valstr[AIR_STRLEN_MED + 1];
nrrdKeyValueAdd(ndwi, tenDWMRIModalityKey, tenDWMRIModalityVal);
sprintf(valstr, "%g", bValue);
@@ -1811,7 +1811,7 @@
unsigned int dd;
airArray *mop;
int axmap[4];
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
#if 0
# define NUM 800
Modified: teem/trunk/src/ten/experSpec.c
===================================================================
--- teem/trunk/src/ten/experSpec.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/experSpec.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -327,7 +327,7 @@
int /* Biff: 1 */
tenDWMRIKeyValueFromExperSpecSet(Nrrd *ndwi, const tenExperSpec *espec) {
static const char me[] = "tenDWMRIKeyValueFromExperSpecSet";
- char keystr[AIR_STRLEN_MED], valstr[AIR_STRLEN_MED];
+ char keystr[AIR_STRLEN_MED + 1], valstr[AIR_STRLEN_MED + 1];
double maxb, bb;
unsigned int ii;
Modified: teem/trunk/src/ten/glyph.c
===================================================================
--- teem/trunk/src/ten/glyph.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/glyph.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -74,7 +74,7 @@
static const char me[] = "tenGlyphParmCheck";
int duh;
size_t tenSize[3];
- char stmp[5][AIR_STRLEN_SMALL];
+ char stmp[5][AIR_STRLEN_SMALL + 1];
if (!(parm && nten)) {
biffAddf(TEN, "%s: got NULL pointer", me);
@@ -184,7 +184,7 @@
int lookIdx;
echoObject *eglyph, *inst, *list = NULL, *split, *esquare;
echoPos_t eM[16], originOffset[3], edge0[3], edge1[3];
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
/*
int eret;
double tmp1[3], tmp2[3];
Modified: teem/trunk/src/ten/grads.c
===================================================================
--- teem/trunk/src/ten/grads.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/grads.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -72,7 +72,7 @@
return 1;
}
if (!(3 == ngrad->axis[0].size && 2 == ngrad->dim)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: need a 3xN 2-D array (not a %sx? %u-D array)", me,
airSprintSize_t(stmp, ngrad->axis[0].size), ngrad->dim);
return 1;
@@ -88,7 +88,7 @@
return 1;
}
if (!(minnum <= ngrad->axis[1].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: have only %s gradients, need at least %d", me,
airSprintSize_t(stmp, ngrad->axis[1].size), minnum);
return 1;
@@ -458,7 +458,7 @@
int /* Biff: 1 */
tenGradientDistribute(Nrrd *nout, const Nrrd *nin, tenGradientParm *tgparm) {
static const char me[] = "tenGradientDistribute";
- char filename[AIR_STRLEN_SMALL];
+ char filename[AIR_STRLEN_SMALL + 1];
unsigned int ii, num, iter, oldIdx, newIdx, edgeShrink;
airArray *mop;
Nrrd *npos[2];
Modified: teem/trunk/src/ten/miscTen.c
===================================================================
--- teem/trunk/src/ten/miscTen.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/miscTen.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -41,7 +41,7 @@
return 1;
}
if (!(2 <= nin->dim && 7 == nin->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN,
"%s: need nin->dim >= 2 (not %u), axis[0].size == 7 "
"(not %s)",
@@ -217,7 +217,7 @@
return 1;
}
if (!(6 == nbmat->axis[0].size && 2 == nbmat->dim)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: need a 6xN 2-D array (not a %s x? %d-D array)", me,
airSprintSize_t(stmp, nbmat->axis[0].size), nbmat->dim);
return 1;
Modified: teem/trunk/src/ten/model1Cylinder.c
===================================================================
--- teem/trunk/src/ten/model1Cylinder.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model1Cylinder.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -58,7 +58,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) %gX%g (%g,%g,%g)", parm[0],
parm[1], parm[2], parm[3], parm[4], parm[5]);
return str;
Modified: teem/trunk/src/ten/model1Stick.c
===================================================================
--- teem/trunk/src/ten/model1Stick.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model1Stick.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -52,7 +52,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) %g (%g,%g,%g)", parm[0], parm[1],
parm[2], parm[3], parm[4]);
return str;
Modified: teem/trunk/src/ten/model1Tensor2.c
===================================================================
--- teem/trunk/src/ten/model1Tensor2.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model1Tensor2.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -56,7 +56,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) [%g %g %g; %g %g; %g]", parm[0],
parm[1], parm[2], parm[3],
parm[4], parm[5],
Modified: teem/trunk/src/ten/model1Unit2D.c
===================================================================
--- teem/trunk/src/ten/model1Unit2D.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model1Unit2D.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -45,7 +45,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) th=%g", parm[0], parm[1]);
return str;
}
Modified: teem/trunk/src/ten/model1Vector2D.c
===================================================================
--- teem/trunk/src/ten/model1Vector2D.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model1Vector2D.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -47,7 +47,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) r=%g th=%g", parm[0], parm[1], parm[2]);
return str;
}
Modified: teem/trunk/src/ten/model2Unit2D.c
===================================================================
--- teem/trunk/src/ten/model2Unit2D.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/model2Unit2D.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -53,7 +53,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) (1-f)*th0=%g + (f=%g)*th1=%g",
parm[0], parm[1], parm[2], parm[3]);
return str;
Modified: teem/trunk/src/ten/modelB0.c
===================================================================
--- teem/trunk/src/ten/modelB0.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelB0.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -42,7 +42,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g)", parm[0]);
return str;
}
Modified: teem/trunk/src/ten/modelBall.c
===================================================================
--- teem/trunk/src/ten/modelBall.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelBall.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -44,7 +44,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) %g", parm[0], parm[1]);
return str;
}
Modified: teem/trunk/src/ten/modelBall1Cylinder.c
===================================================================
--- teem/trunk/src/ten/modelBall1Cylinder.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelBall1Cylinder.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -64,7 +64,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) [(1-f) %g + (f=%g) %gX%g (%g,%g,%g)]", parm[0],
parm[1], parm[2], parm[3], parm[4],
parm[5], parm[6], parm[7]);
Modified: teem/trunk/src/ten/modelBall1Stick.c
===================================================================
--- teem/trunk/src/ten/modelBall1Stick.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelBall1Stick.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -59,7 +59,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) (1-f)*%g + (f=%g)*(%g @ (%g,%g,%g))", parm[0],
parm[1], parm[2], parm[3], parm[4], parm[5], parm[6]);
return str;
Modified: teem/trunk/src/ten/modelBall1StickEMD.c
===================================================================
--- teem/trunk/src/ten/modelBall1StickEMD.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelBall1StickEMD.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -56,7 +56,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
sprintf(str, "(%g) %g * (%g + %g*(%g,%g,%g))", parm[0],
parm[1], 1-parm[2], parm[2], parm[3], parm[4], parm[5]);
return str;
Modified: teem/trunk/src/ten/modelZero.c
===================================================================
--- teem/trunk/src/ten/modelZero.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/modelZero.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -43,7 +43,7 @@
}
static char *
-parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
+parmSprint(char str[AIR_STRLEN_MED+1], const double *parm) {
AIR_UNUSED(parm);
sprintf(str, "constant 0");
Modified: teem/trunk/src/ten/path.c
===================================================================
--- teem/trunk/src/ten/path.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/path.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -1034,7 +1034,7 @@
}
}
if (tenInterpN_d(tenOut, tbuff, wght, ninLen, ptype, tip)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: trouble on sample %s", me, airSprintSize_t(stmp, II));
airMopError(mop);
return 1;
Modified: teem/trunk/src/ten/ten.h
===================================================================
--- teem/trunk/src/ten/ten.h 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/ten.h 2023-07-07 21:53:33 UTC (rev 7047)
@@ -1150,13 +1150,13 @@
/* description of *one* parameter in the parameter vector that
defines one instance of a given model */
typedef struct {
- char name[AIR_STRLEN_SMALL]; /* name */
- double min, max; /* bounds */
- int cyclic; /* non-zero if effectively min == max */
- int vec3; /* non-zero if this is a coefficient
- of a UNIT-LENGTH 3-vector */
- unsigned int vecIdx; /* *if* this param is part of vector,
- the index into it, i.e. 0, 1, or 2 */
+ char name[AIR_STRLEN_SMALL + 1]; /* name */
+ double min, max; /* bounds */
+ int cyclic; /* non-zero if effectively min == max */
+ int vec3; /* non-zero if this is a coefficient
+ of a UNIT-LENGTH 3-vector */
+ unsigned int vecIdx; /* *if* this param is part of vector,
+ the index into it, i.e. 0, 1, or 2 */
} tenModelParmDesc;
#define TEN_MODEL_B0_MAX \
@@ -1195,13 +1195,13 @@
** The "parmNum" field below therefore always includes the B0 value
*/
typedef struct tenModel_t {
- char name[AIR_STRLEN_SMALL];
+ char name[AIR_STRLEN_SMALL + 1];
unsigned int parmNum;
const tenModelParmDesc *parmDesc;
/* noise free simulation */
void (*simulate)(double *dwiSim, const double *parm, const tenExperSpec *espec);
/* parameter vector operations */
- char *(*sprint)(char str[AIR_STRLEN_MED], const double *parm);
+ char *(*sprint)(char str[AIR_STRLEN_MED + 1], const double *parm);
double *(*alloc)(void);
void (*rand)(double *parm, airRandMTState *rng, int knownB0);
void (*step)(double *parm1, const double scl, const double *grad, const double *parm0);
Modified: teem/trunk/src/ten/tenModel.c
===================================================================
--- teem/trunk/src/ten/tenModel.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tenModel.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -347,7 +347,7 @@
unsigned int iter, subIter;
double step, bak, opp, val, testval, dist, td;
int done;
- char pstr[AIR_STRLEN_MED];
+ char pstr[AIR_STRLEN_MED + 1];
step = 1;
model->copy(parm, parmInit);
Modified: teem/trunk/src/ten/tendAbout.c
===================================================================
--- teem/trunk/src/ten/tendAbout.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tendAbout.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -26,7 +26,7 @@
static int
tend_aboutMain(int argc, const char **argv, const char *me, hestParm *hparm) {
- char buff[AIR_STRLEN_LARGE], fmt[AIR_STRLEN_MED];
+ char buff[AIR_STRLEN_LARGE + 1], fmt[AIR_STRLEN_MED + 1];
char par1[] = "\t\t\t\t"
"\"tend\" is a command-line interface to much of the functionality "
"in \"ten\", a C library for diffusion image processing. Ten is one "
Modified: teem/trunk/src/ten/tendBfit.c
===================================================================
--- teem/trunk/src/ten/tendBfit.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tendBfit.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -66,7 +66,7 @@
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
if (!(bbLen == nin->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
fprintf(stderr, "%s: got %d b-values but axis 0 size is %s\n", me, bbLen,
airSprintSize_t(stmp, nin->axis[0].size));
airMopError(mop);
@@ -74,7 +74,7 @@
}
if (AIR_EXISTS(_ww[0])) {
if (!(_wwLen == nin->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
fprintf(stderr, "%s: got %d weights but axis 0 size is %s\n", me, _wwLen,
airSprintSize_t(stmp, nin->axis[0].size));
airMopError(mop);
Modified: teem/trunk/src/ten/tendFlotsam.c
===================================================================
--- teem/trunk/src/ten/tendFlotsam.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tendFlotsam.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -43,7 +43,7 @@
** info[2]: 2nd parameter, used occasionally
*/
static int
-fiberStopParse(void *ptr, const char *_str, char err[AIR_STRLEN_HUGE]) {
+fiberStopParse(void *ptr, const char *_str, char err[AIR_STRLEN_HUGE + 1]) {
static const char me[] = "fiberStopParse";
char *str, *opt, *opt2;
double *info;
Modified: teem/trunk/src/ten/tendGlyph.c
===================================================================
--- teem/trunk/src/ten/tendGlyph.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tendGlyph.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -41,16 +41,16 @@
_tendGlyphReadCams(int imgSize[2], limnCamera **camP, unsigned int *numCamsP,
FILE *fin) {
static const char me[] = "_tendGlyphReadCams";
- char line[AIR_STRLEN_HUGE];
+ char line[AIR_STRLEN_HUGE + 1];
int ki;
double di, dn, df, fr[3], at[3], up[3], va, dwell;
airArray *mop, *camA;
- if (!(0 < airOneLine(fin, line, AIR_STRLEN_HUGE) && !strcmp(_LIMNMAGIC, line))) {
+ if (!(0 < airOneLine(fin, line, AIR_STRLEN_HUGE + 1) && !strcmp(_LIMNMAGIC, line))) {
biffAddf(TEN, "%s: couldn't read first line or it wasn't \"%s\"", me, _LIMNMAGIC);
return 1;
}
- if (!(0 < airOneLine(fin, line, AIR_STRLEN_HUGE)
+ if (!(0 < airOneLine(fin, line, AIR_STRLEN_HUGE + 1)
&& 2
== (airStrtrans(airStrtrans(line, '{', ' '), '}', ' '),
sscanf(line, "imgSize %d %d", imgSize + 0, imgSize + 1)))) {
@@ -65,7 +65,7 @@
camA = airArrayNew((void **)camP, numCamsP, sizeof(limnCamera), 1);
airMopAdd(mop, camA, (airMopper)airArrayNix, airMopAlways);
- while (0 < airOneLine(fin, line, AIR_STRLEN_HUGE)) {
+ while (0 < airOneLine(fin, line, AIR_STRLEN_HUGE + 1)) {
airStrtrans(airStrtrans(line, '{', ' '), '}', ' ');
ki = airArrayLenIncr(camA, 1);
if (14
@@ -117,7 +117,7 @@
int ires[2], slice[2], nobg, ambocc, concave;
unsigned int hackci, hacknumcam;
size_t hackmin[3] = {0, 0, 0}, hackmax[3] = {2, 0, 0};
- char *hackFN, hackoutFN[AIR_STRLEN_SMALL];
+ char *hackFN, hackoutFN[AIR_STRLEN_SMALL + 1];
FILE *hackF;
Nrrd *hacknpng, *hacknrgb;
NrrdRange *hackrange;
Modified: teem/trunk/src/ten/tendSatin.c
===================================================================
--- teem/trunk/src/ten/tendSatin.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tendSatin.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -109,7 +109,7 @@
tend_satinGen(Nrrd *nout, float parm, float mina, float maxa, int wsize, float thick,
float scaling, float bnd, float bndRm, float evsc, int torus) {
static const char me[] = "tend_satinGen";
- char buff[AIR_STRLEN_SMALL];
+ char buff[AIR_STRLEN_SMALL + 1];
Nrrd *nconf, *neval, *nevec;
float *conf, *eval, *evec;
size_t xi, yi, zi, size[3];
Modified: teem/trunk/src/ten/tensor.c
===================================================================
--- teem/trunk/src/ten/tensor.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/tensor.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -75,7 +75,7 @@
return 1;
}
if (!(7 == nin->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffMaybeAddf(useBiff, TEN, "%s: axis 0 has size %s, not 7", me,
airSprintSize_t(stmp, nin->axis[0].size));
return 1;
@@ -187,7 +187,7 @@
return 1;
}
if (!(4 == nin->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: axis 0 has size %s, not 4", me,
airSprintSize_t(stmp, nin->axis[0].size));
return 1;
@@ -298,7 +298,7 @@
return 1;
}
if (!(nrrdTypeFloat == tnine->type && 4 == tnine->dim && 9 == tnine->axis[0].size)) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN,
"%s: type not %s (was %s) or dim not 4 (was %d) "
"or first axis size not 9 (was %s)",
@@ -532,7 +532,7 @@
float *out, *conf, *eval, *evec;
int map[4];
/* float teval[3], tevec[9], tmp1[3], tmp2[3]; */
- char stmp[7][AIR_STRLEN_SMALL];
+ char stmp[7][AIR_STRLEN_SMALL + 1];
if (!(nout && nconf && neval && nevec)) {
biffAddf(TEN, "%s: got NULL pointer", me);
@@ -633,7 +633,7 @@
Nrrd *nslice, **ncoeff = NULL;
int ci[4];
airArray *mop;
- char stmp[2][AIR_STRLEN_SMALL];
+ char stmp[2][AIR_STRLEN_SMALL + 1];
if (!(nout && nten)) {
biffAddf(TEN, "%s: got NULL pointer", me);
Modified: teem/trunk/src/ten/test/csim.c
===================================================================
--- teem/trunk/src/ten/test/csim.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/test/csim.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -19,30 +19,26 @@
Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include "../ten.h"
static int
-csimDo(double tm[7], double tcov[21], double rm[3], double rv[3],
- Nrrd *ntbuff, tenEstimateContext *tec, double *dwibuff, double sigma,
- double bvalue, double B0, unsigned int NN, int randrot,
- double _tenOrig[7]) {
- char me[]="csimDo";
+csimDo(double tm[7], double tcov[21], double rm[3], double rv[3], Nrrd *ntbuff,
+ tenEstimateContext *tec, double *dwibuff, double sigma, double bvalue, double B0,
+ unsigned int NN, int randrot, double _tenOrig[7]) {
+ char me[] = "csimDo";
double *tbuff;
unsigned int II, taa, tbb, cc;
- if (!(ntbuff
- && ntbuff->data
- && 2 == ntbuff->dim
- && 7 == ntbuff->axis[0].size
+ if (!(ntbuff && ntbuff->data && 2 == ntbuff->dim && 7 == ntbuff->axis[0].size
&& NN == ntbuff->axis[1].size)) {
- biffAddf(TEN, "%s: ntbuff not allocated for 2-by-%u array of %s", me,
- NN, airEnumStr(nrrdType, nrrdTypeDouble)); return 1;
+ biffAddf(TEN, "%s: ntbuff not allocated for 2-by-%u array of %s", me, NN,
+ airEnumStr(nrrdType, nrrdTypeDouble));
+ return 1;
}
/* find all tensors from simulated DWIs */
tbuff = AIR_CAST(double *, ntbuff->data);
- for (II=0; II<NN; II++) {
+ for (II = 0; II < NN; II++) {
double tenOrig[7], rotf[9], rotb[9], matA[9], matB[9], qq[4], tmp;
ELL_3M_IDENTITY_SET(rotf); /* sssh warnings */
ELL_3M_IDENTITY_SET(rotb); /* sssh warnings */
@@ -52,8 +48,8 @@
double eval[3], evec[9], eps, ma[9], mb[9], rf[9], rb[9];
tenEigensolve_d(eval, evec, _tenOrig);
airNormalRand(&eps, NULL);
- ell_aa_to_3m_d(rf, 0*eps/20, evec + 0);
- TEN_T_SCALE_INCR(_tenOrig, 0*eps/30, _tenOrig);
+ ell_aa_to_3m_d(rf, 0 * eps / 20, evec + 0);
+ TEN_T_SCALE_INCR(_tenOrig, 0 * eps / 30, _tenOrig);
TEN_T2M(ma, _tenOrig);
ELL_3M_TRANSPOSE(rb, rf);
ELL_3M_MUL(mb, ma, rf);
@@ -61,8 +57,8 @@
TEN_M2T(_tenOrig, ma);
}
TEN_T2M(matA, _tenOrig);
- airNormalRand(qq+0, qq+1);
- airNormalRand(qq+2, qq+3);
+ airNormalRand(qq + 0, qq + 1);
+ airNormalRand(qq + 2, qq + 3);
ELL_4V_NORM(qq, qq, tmp);
ell_q_to_3m_d(rotf, qq);
ELL_3M_TRANSPOSE(rotb, rotf);
@@ -72,10 +68,10 @@
} else {
TEN_T_COPY(tenOrig, _tenOrig);
}
- if (tenEstimate1TensorSimulateSingle_d(tec, dwibuff, sigma,
- bvalue, B0, tenOrig)
+ if (tenEstimate1TensorSimulateSingle_d(tec, dwibuff, sigma, bvalue, B0, tenOrig)
|| tenEstimate1TensorSingle_d(tec, tbuff, dwibuff)) {
- biffAddf(TEN, "%s: trouble on exp %u/%u", me, II, NN); return 1;
+ biffAddf(TEN, "%s: trouble on exp %u/%u", me, II, NN);
+ return 1;
}
if (randrot) {
TEN_T2M(matA, tbuff);
@@ -104,7 +100,7 @@
tbuff = AIR_CAST(double *, ntbuff->data);
TEN_T_SET(tm, 0, 0, 0, 0, 0, 0, 0);
ELL_3V_SET(rm, 0, 0, 0);
- for (II=0; II<NN; II++) {
+ for (II = 0; II < NN; II++) {
TEN_T_INCR(tm, tbuff);
rm[0] += sqrt(_tenAnisoTen_d[tenAniso_S](tbuff));
rm[1] += _tenAnisoTen_d[tenAniso_FA](tbuff);
@@ -114,27 +110,27 @@
rm[0] /= NN;
rm[1] /= NN;
rm[2] /= NN;
- TEN_T_SCALE(tm, 1.0/NN, tm);
+ TEN_T_SCALE(tm, 1.0 / NN, tm);
/* accumulate covariance tensor, and R_i variances */
- for (cc=0; cc<21; cc++) {
+ for (cc = 0; cc < 21; cc++) {
tcov[cc] = 0;
}
ELL_3V_SET(rv, 0, 0, 0);
tbuff = AIR_CAST(double *, ntbuff->data);
- for (II=0; II<NN; II++) {
+ for (II = 0; II < NN; II++) {
double r[3];
r[0] = sqrt(_tenAnisoTen_d[tenAniso_S](tbuff));
r[1] = _tenAnisoTen_d[tenAniso_FA](tbuff);
r[2] = _tenAnisoTen_d[tenAniso_Mode](tbuff);
cc = 0;
- rv[0] += (r[0] - rm[0])*(r[0] - rm[0])/(NN-1);
- rv[1] += (r[1] - rm[1])*(r[1] - rm[1])/(NN-1);
- rv[2] += (r[2] - rm[2])*(r[2] - rm[2])/(NN-1);
- for (taa=0; taa<6; taa++) {
- for (tbb=taa; tbb<6; tbb++) {
- tcov[cc] += (10000*(tbuff[taa+1]-tm[taa+1])
- *10000*(tbuff[tbb+1]-tm[tbb+1])/(NN-1));
+ rv[0] += (r[0] - rm[0]) * (r[0] - rm[0]) / (NN - 1);
+ rv[1] += (r[1] - rm[1]) * (r[1] - rm[1]) / (NN - 1);
+ rv[2] += (r[2] - rm[2]) * (r[2] - rm[2]) / (NN - 1);
+ for (taa = 0; taa < 6; taa++) {
+ for (tbb = taa; tbb < 6; tbb++) {
+ tcov[cc] += (10000 * (tbuff[taa + 1] - tm[taa + 1]) * 10000
+ * (tbuff[tbb + 1] - tm[tbb + 1]) / (NN - 1));
cc++;
}
}
@@ -150,14 +146,14 @@
main(int argc, const char *argv[]) {
const char *me;
char *err;
- hestOpt *hopt=NULL;
+ hestOpt *hopt = NULL;
airArray *mop;
char *outTenS, *outCovarS, *outRmvS;
int seed, E;
unsigned int NN;
- Nrrd *_ninTen, *ninTen, *ngrad, *_ninB0, *ninB0, *nmask,
- *noutCovar, *noutTen, *noutRmv, *ntbuff;
+ Nrrd *_ninTen, *ninTen, *ngrad, *_ninB0, *ninB0, *nmask, *noutCovar, *noutTen,
+ *noutRmv, *ntbuff;
float sigma, bval;
size_t sizeX, sizeY, sizeZ;
tenEstimateContext *tec;
@@ -172,25 +168,24 @@
hestOptAdd(&hopt, "seed", "seed", airTypeInt, 1, 1, &seed, "42",
"seed value for RNG which creates noise");
hestOptAdd(&hopt, "r", "reference field", airTypeOther, 1, 1, &_ninB0, NULL,
- "reference anatomical scan, with no diffusion weighting",
- NULL, NULL, nrrdHestNrrd);
+ "reference anatomical scan, with no diffusion weighting", NULL, NULL,
+ nrrdHestNrrd);
hestOptAdd(&hopt, "rr", NULL, airTypeOther, 0, 0, &randrot, NULL,
"randomize gradient set orientation");
hestOptAdd(&hopt, "g", "grad list", airTypeOther, 1, 1, &ngrad, "",
- "gradient list, one row per diffusion-weighted image",
- NULL, NULL, nrrdHestNrrd);
+ "gradient list, one row per diffusion-weighted image", NULL, NULL,
+ nrrdHestNrrd);
hestOptAdd(&hopt, "b", "b", airTypeFloat, 1, 1, &bval, "1000",
"b value for simulated scan");
hestOptAdd(&hopt, "sigma", "sigma", airTypeFloat, 1, 1, &sigma, "0.0",
"Rician noise parameter");
- hestOptAdd(&hopt, "ot", "filename", airTypeString, 1, 1, &outTenS,
- "tout.nrrd", "file to write output tensor nrrd to");
- hestOptAdd(&hopt, "oc", "filename", airTypeString, 1, 1, &outCovarS,
- "cout.nrrd", "file to write output covariance nrrd to");
- hestOptAdd(&hopt, "or", "filename", airTypeString, 1, 1, &outRmvS,
- "rout.nrrd", "file to write output R_i means, variances to");
- hestParseOrDie(hopt, argc-1, argv+1, NULL,
- me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestOptAdd(&hopt, "ot", "filename", airTypeString, 1, 1, &outTenS, "tout.nrrd",
+ "file to write output tensor nrrd to");
+ hestOptAdd(&hopt, "oc", "filename", airTypeString, 1, 1, &outCovarS, "cout.nrrd",
+ "file to write output covariance nrrd to");
+ hestOptAdd(&hopt, "or", "filename", airTypeString, 1, 1, &outRmvS, "rout.nrrd",
+ "file to write output R_i means, variances to");
+ hestParseOrDie(hopt, argc - 1, argv + 1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
@@ -209,14 +204,12 @@
sizeX = _ninTen->axis[1].size;
sizeY = _ninTen->axis[2].size;
sizeZ = _ninTen->axis[3].size;
- if (!(3 == _ninB0->dim &&
- sizeX == _ninB0->axis[0].size &&
- sizeY == _ninB0->axis[1].size &&
- sizeZ == _ninB0->axis[2].size)) {
- char stmp[3][AIR_STRLEN_SMALL];
- fprintf(stderr, "%s: given B0 (%u-D) volume not 3-D %sx%sx%s",
- me, _ninB0->dim, airSprintSize_t(stmp[0], sizeX),
- airSprintSize_t(stmp[1], sizeY), airSprintSize_t(stmp[2], sizeZ));
+ if (!(3 == _ninB0->dim && sizeX == _ninB0->axis[0].size
+ && sizeY == _ninB0->axis[1].size && sizeZ == _ninB0->axis[2].size)) {
+ char stmp[3][AIR_STRLEN_SMALL + 1];
+ fprintf(stderr, "%s: given B0 (%u-D) volume not 3-D %sx%sx%s", me, _ninB0->dim,
+ airSprintSize_t(stmp[0], sizeX), airSprintSize_t(stmp[1], sizeY),
+ airSprintSize_t(stmp[2], sizeZ));
airMopError(mop);
return 1;
}
@@ -236,18 +229,16 @@
ntbuff = nrrdNew();
airMopAdd(mop, ntbuff, (airMopper)nrrdNuke, airMopOnError);
- if (nrrdConvert(ninTen, _ninTen, nrrdTypeDouble)
- || nrrdSlice(nmask, ninTen, 0, 0)
+ if (nrrdConvert(ninTen, _ninTen, nrrdTypeDouble) || nrrdSlice(nmask, ninTen, 0, 0)
|| nrrdConvert(ninB0, _ninB0, nrrdTypeDouble)
- || nrrdMaybeAlloc_va(noutTen, nrrdTypeDouble, 4,
- AIR_CAST(size_t, 7), sizeX, sizeY, sizeZ)
- || nrrdMaybeAlloc_va(noutCovar, nrrdTypeDouble, 4,
- AIR_CAST(size_t, 21), sizeX, sizeY, sizeZ)
- || nrrdMaybeAlloc_va(noutRmv, nrrdTypeDouble, 4,
- AIR_CAST(size_t, 6), sizeX, sizeY, sizeZ)
- || nrrdMaybeAlloc_va(ntbuff, nrrdTypeDouble, 2,
- AIR_CAST(size_t, 7), NN)) {
- airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
+ || nrrdMaybeAlloc_va(noutTen, nrrdTypeDouble, 4, AIR_CAST(size_t, 7), sizeX, sizeY,
+ sizeZ)
+ || nrrdMaybeAlloc_va(noutCovar, nrrdTypeDouble, 4, AIR_CAST(size_t, 21), sizeX,
+ sizeY, sizeZ)
+ || nrrdMaybeAlloc_va(noutRmv, nrrdTypeDouble, 4, AIR_CAST(size_t, 6), sizeX, sizeY,
+ sizeZ)
+ || nrrdMaybeAlloc_va(ntbuff, nrrdTypeDouble, 2, AIR_CAST(size_t, 7), NN)) {
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble setting up tec:\n%s\n", me, err);
airMopError(mop);
return 1;
@@ -263,7 +254,7 @@
if (!E) E |= tenEstimateThresholdSet(tec, 0, 0);
if (!E) E |= tenEstimateUpdate(tec);
if (E) {
- airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble setting up tec:\n%s\n", me, err);
airMopError(mop);
return 1;
@@ -275,29 +266,27 @@
if (1) {
unsigned int II;
unsigned int nsamp;
- double *inTen, *outTen, *outCovar, *outRmv,
- *dwibuff, (*lup)(const void *, size_t);
- char doneStr[AIR_STRLEN_SMALL];
+ double *inTen, *outTen, *outCovar, *outRmv, *dwibuff, (*lup)(const void *, size_t);
+ char doneStr[AIR_STRLEN_SMALL + 1];
dwibuff = AIR_CAST(double *, calloc(ngrad->axis[1].size, sizeof(double)));
airMopAdd(mop, dwibuff, airFree, airMopAlways);
- nsamp = AIR_UINT(sizeX*sizeY*sizeZ);
+ nsamp = AIR_UINT(sizeX * sizeY * sizeZ);
inTen = AIR_CAST(double *, ninTen->data);
- lup = nrrdDLookup[nrrdTypeDouble];
+ lup = nrrdDLookup[nrrdTypeDouble];
outTen = AIR_CAST(double *, noutTen->data);
outCovar = AIR_CAST(double *, noutCovar->data);
outRmv = AIR_CAST(double *, noutRmv->data);
fprintf(stderr, "!%s: simulating ... ", me);
fflush(stderr);
- for (II=0; II<nsamp; II++) {
+ for (II = 0; II < nsamp; II++) {
if (!(II % sizeX)) {
fprintf(stderr, "%s", airDoneStr(0, II, nsamp, doneStr));
fflush(stderr);
}
- if (csimDo(outTen, outCovar, outRmv + 0, outRmv + 3, ntbuff,
- tec, dwibuff, sigma,
+ if (csimDo(outTen, outCovar, outRmv + 0, outRmv + 3, ntbuff, tec, dwibuff, sigma,
bval, lup(ninB0->data, II), NN, randrot, inTen)) {
- airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble:\n%s\n", me, err);
airMopError(mop);
return 1;
@@ -318,14 +307,11 @@
|| nrrdAxisInfoCopy(noutTen, ninTen, axmap, NRRD_AXIS_INFO_SIZE_BIT)
|| nrrdAxisInfoCopy(noutCovar, ninTen, axmap, NRRD_AXIS_INFO_SIZE_BIT)
|| nrrdAxisInfoCopy(noutRmv, ninTen, axmap, NRRD_AXIS_INFO_SIZE_BIT)
- || nrrdBasicInfoCopy(noutTen, ninTen,
- NRRD_BASIC_INFO_ALL ^ NRRD_BASIC_INFO_SPACE)
+ || nrrdBasicInfoCopy(noutTen, ninTen, NRRD_BASIC_INFO_ALL ^ NRRD_BASIC_INFO_SPACE)
|| nrrdBasicInfoCopy(noutCovar, ninTen,
NRRD_BASIC_INFO_ALL ^ NRRD_BASIC_INFO_SPACE)
- || nrrdBasicInfoCopy(noutRmv, ninTen,
- NRRD_BASIC_INFO_ALL ^ NRRD_BASIC_INFO_SPACE)
- || nrrdSave(outTenS, noutTen, NULL)
- || nrrdSave(outCovarS, noutCovar, NULL)
+ || nrrdBasicInfoCopy(noutRmv, ninTen, NRRD_BASIC_INFO_ALL ^ NRRD_BASIC_INFO_SPACE)
+ || nrrdSave(outTenS, noutTen, NULL) || nrrdSave(outCovarS, noutCovar, NULL)
|| nrrdSave(outRmvS, noutRmv, NULL)) {
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble saving output:\n%s\n", me, err);
Modified: teem/trunk/src/ten/test/tensorDotDat.c
===================================================================
--- teem/trunk/src/ten/test/tensorDotDat.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/test/tensorDotDat.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -19,7 +19,6 @@
Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include "../ten.h"
const char *info = ("Compute the makings of a new tensor.dat file.");
@@ -28,14 +27,14 @@
main(int argc, const char *argv[]) {
const char *me;
char *err;
- hestOpt *hopt=NULL;
+ hestOpt *hopt = NULL;
airArray *mop;
int E, optimizeEdge, workToDo;
unsigned int ii, numRange[2], seedRange[2], seed, seedDone;
double *log, minAngle, minEdge, pot, potNorm, time0, time1;
- char *outStr, logFilename[AIR_STRLEN_MED], gradFilename[AIR_STRLEN_MED],
- keyStr[AIR_STRLEN_MED], valStr[AIR_STRLEN_MED];
+ char *outStr, logFilename[AIR_STRLEN_MED + 1], gradFilename[AIR_STRLEN_MED + 1],
+ keyStr[AIR_STRLEN_MED + 1], valStr[AIR_STRLEN_MED + 1];
tenGradientParm *tgparm;
Nrrd *nlog, *ngrad;
size_t size[2];
@@ -62,16 +61,14 @@
hestOptAdd(&hopt, "p", "exponent", airTypeUInt, 1, 1, &(tgparm->expo), "1",
"the exponent p that defines the 1/r^p potential energy "
"(Coulomb is 1)");
- hestOptAdd(&hopt, "step", "step", airTypeDouble, 1, 1, &(tgparm->initStep),
- "1", "time increment in solver");
- hestOptAdd(&hopt, "miniter", "# iters", airTypeInt, 1, 1,
- &(tgparm->minIteration), "0",
+ hestOptAdd(&hopt, "step", "step", airTypeDouble, 1, 1, &(tgparm->initStep), "1",
+ "time increment in solver");
+ hestOptAdd(&hopt, "miniter", "# iters", airTypeInt, 1, 1, &(tgparm->minIteration), "0",
"required minimum number of simulation iterations");
- hestOptAdd(&hopt, "maxiter", "# iters", airTypeInt, 1, 1,
- &(tgparm->maxIteration), "1000000",
- "max number of simulations iterations");
- hestOptAdd(&hopt, "minvelo", "vel", airTypeDouble, 1, 1,
- &(tgparm->minVelocity), "0.00000000001",
+ hestOptAdd(&hopt, "maxiter", "# iters", airTypeInt, 1, 1, &(tgparm->maxIteration),
+ "1000000", "max number of simulations iterations");
+ hestOptAdd(&hopt, "minvelo", "vel", airTypeDouble, 1, 1, &(tgparm->minVelocity),
+ "0.00000000001",
"low threshold on mean velocity of repelling points, "
"at which point repulsion phase of algorithm terminates.");
hestOptAdd(&hopt, "dp", "potential change", airTypeDouble, 1, 1,
@@ -85,8 +82,7 @@
"the (small) improvement in length of mean gradient "
"which triggers termination (as further improvements "
"are unlikely. ");
- hestOptAdd(&hopt, "minmean", "len", airTypeDouble, 1, 1,
- &(tgparm->minMean), "0.0005",
+ hestOptAdd(&hopt, "minmean", "len", airTypeDouble, 1, 1, &(tgparm->minMean), "0.0005",
"if length of mean gradient falls below this, finish "
"the balancing phase");
hestOptAdd(&hopt, "oe", NULL, airTypeInt, 0, 0, &optimizeEdge, NULL,
@@ -95,20 +91,19 @@
hestOptAdd(&hopt, "odir", "out", airTypeString, 1, 1, &outStr, ".",
"output directory for all grad files and logs, you should "
"leave off the trailing /");
- hestParseOrDie(hopt, argc-1, argv+1, NULL,
- me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE);
+ hestParseOrDie(hopt, argc - 1, argv + 1, NULL, me, info, AIR_TRUE, AIR_TRUE, AIR_TRUE);
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways);
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways);
if (0 == seedRange[0]) {
fprintf(stderr, "%s: sorry, initial seed must be non-zero\n", me);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
- if (!( numRange[0] <= numRange[1]
- && numRange[0] >= 6 )) {
- fprintf(stderr, "%s: number range [%u,%u] invalid\n", me,
- numRange[0], numRange[1]);
- airMopError(mop); return 1;
+ if (!(numRange[0] <= numRange[1] && numRange[0] >= 6)) {
+ fprintf(stderr, "%s: number range [%u,%u] invalid\n", me, numRange[0], numRange[1]);
+ airMopError(mop);
+ return 1;
}
/* in master log (per gradient set):
@@ -130,34 +125,32 @@
free(biffGetDone(NRRD));
/* create a log nrrd of the correct size */
size[0] = 9;
- size[1] = numRange[1]+1;
+ size[1] = numRange[1] + 1;
if (nrrdMaybeAlloc_nva(nlog, nrrdTypeDouble, 2, size)) {
- airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble making log:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
} else {
/* we could open the log, see if its the right size */
- if (!( nrrdTypeDouble == nlog->type
- && 2 == nlog->dim
- && 9 == nlog->axis[0].size
- && numRange[1]+1 == nlog->axis[1].size )) {
- fprintf(stderr, "%s: given log (%s %u-D %ux%ux?) doesn't match "
- "desired (%s 2-D 9x%u)\n", me,
- airEnumStr(nrrdType, nlog->type),
- nlog->dim,
- AIR_UINT(nlog->axis[0].size),
- AIR_UINT(nlog->axis[1].size),
- airEnumStr(nrrdType, nrrdTypeDouble),
- numRange[1]+1);
- airMopError(mop); return 1;
+ if (!(nrrdTypeDouble == nlog->type && 2 == nlog->dim && 9 == nlog->axis[0].size
+ && numRange[1] + 1 == nlog->axis[1].size)) {
+ fprintf(stderr,
+ "%s: given log (%s %u-D %ux%ux?) doesn't match "
+ "desired (%s 2-D 9x%u)\n",
+ me, airEnumStr(nrrdType, nlog->type), nlog->dim,
+ AIR_UINT(nlog->axis[0].size), AIR_UINT(nlog->axis[1].size),
+ airEnumStr(nrrdType, nrrdTypeDouble), numRange[1] + 1);
+ airMopError(mop);
+ return 1;
}
}
/* nlog is the right size */
/* initialize log's first column and key/value pairs, and (re)save */
log = AIR_CAST(double *, nlog->data);
- for (ii=numRange[0]; ii<=numRange[1]; ii++) {
- log[0 + 9*ii] = ii;
+ for (ii = numRange[0]; ii <= numRange[1]; ii++) {
+ log[0 + 9 * ii] = ii;
}
E = 0;
if (!E) strcpy(keyStr, "maxiter");
@@ -177,9 +170,10 @@
if (!E) E |= nrrdKeyValueAdd(nlog, keyStr, valStr);
if (!E) E |= nrrdSave(logFilename, nlog, NULL);
if (E) {
- airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble writing log:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
/* in master log (per gradient set):
@@ -195,11 +189,10 @@
*/
workToDo = AIR_FALSE;
- for (seed=seedRange[0];
- seedRange[1] < seedRange[0] || seed <= seedRange[1];
+ for (seed = seedRange[0]; seedRange[1] < seedRange[0] || seed <= seedRange[1];
seed++) {
- for (ii=numRange[0]; ii<=numRange[1]; ii++) {
- seedDone = AIR_UINT(log[1 + 9*ii]);
+ for (ii = numRange[0]; ii <= numRange[1]; ii++) {
+ seedDone = AIR_UINT(log[1 + 9 * ii]);
/* if no seeds have been tried, seedDone will be zero */
if (seedDone >= seed) {
/* have already tried this seed, move on */
@@ -210,37 +203,39 @@
fprintf(stderr, "%s ================ %u %u\n", me, ii, tgparm->seed);
time0 = airTime();
if (tenGradientGenerate(ngrad, ii, tgparm)) {
- airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(TEN), airFree, airMopAlways);
fprintf(stderr, "%s: trouble making distribution:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
time1 = airTime();
- tenGradientMeasure(&potNorm, &minAngle, &minEdge,
- ngrad, tgparm, AIR_TRUE);
+ tenGradientMeasure(&potNorm, &minAngle, &minEdge, ngrad, tgparm, AIR_TRUE);
if (!seedDone
- || ((optimizeEdge && minEdge > log[5 + 9*ii])
- || potNorm < log[4 + 9*ii])) {
+ || ((optimizeEdge && minEdge > log[5 + 9 * ii])
+ || potNorm < log[4 + 9 * ii])) {
/* this gradient set is best so far */
tenGradientMeasure(&pot, NULL, NULL, ngrad, tgparm, AIR_FALSE);
- log[2 + 9*ii] = tgparm->seed;
- log[3 + 9*ii] = pot;
- log[4 + 9*ii] = potNorm;
- log[5 + 9*ii] = minEdge;
- log[6 + 9*ii] = tenGradientIdealEdge(ii, AIR_FALSE);
- log[7 + 9*ii] = tgparm->itersUsed;
- log[8 + 9*ii] = time1 - time0;
+ log[2 + 9 * ii] = tgparm->seed;
+ log[3 + 9 * ii] = pot;
+ log[4 + 9 * ii] = potNorm;
+ log[5 + 9 * ii] = minEdge;
+ log[6 + 9 * ii] = tenGradientIdealEdge(ii, AIR_FALSE);
+ log[7 + 9 * ii] = tgparm->itersUsed;
+ log[8 + 9 * ii] = time1 - time0;
sprintf(gradFilename, "%s/%03u-%04u.nrrd", outStr, ii, tgparm->expo);
if (nrrdSave(gradFilename, ngrad, NULL)) {
- airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
- log[1 + 9*ii] = tgparm->seed;
+ log[1 + 9 * ii] = tgparm->seed;
if (nrrdSave(logFilename, nlog, NULL)) {
- airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways);
+ airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: trouble writing log:\n%s\n", me, err);
- airMopError(mop); return 1;
+ airMopError(mop);
+ return 1;
}
}
}
Modified: teem/trunk/src/ten/triple.c
===================================================================
--- teem/trunk/src/ten/triple.c 2023-07-07 21:43:30 UTC (rev 7046)
+++ teem/trunk/src/ten/triple.c 2023-07-07 21:53:33 UTC (rev 7047)
@@ -486,7 +486,7 @@
return 1;
}
if (3 != nin->axis[0].size) {
- char stmp[AIR_STRLEN_SMALL];
+ char stmp[AIR_STRLEN_SMALL + 1];
biffAddf(TEN, "%s: need axis[0].size 3, not %s", me,
airSprintSize_t(stmp, nin->axis[0].size));
return 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|