GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/ten/modelBall1StickEMD.c Lines: 0 25 0.0 %
Date: 2017-05-26 Branches: 0 42 0.0 %

Line Branch Exec Source
1
/*
2
  Teem: Tools to process and visualize scientific data and images             .
3
  Copyright (C) 2013, 2012, 2011, 2010, 2009  University of Chicago
4
  Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
5
  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
6
7
  This library is free software; you can redistribute it and/or
8
  modify it under the terms of the GNU Lesser General Public License
9
  (LGPL) as published by the Free Software Foundation; either
10
  version 2.1 of the License, or (at your option) any later version.
11
  The terms of redistributing and/or modifying this software also
12
  include exceptions to the LGPL that facilitate static linking.
13
14
  This library is distributed in the hope that it will be useful,
15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
  Lesser General Public License for more details.
18
19
  You should have received a copy of the GNU Lesser General Public License
20
  along with this library; if not, write to Free Software Foundation, Inc.,
21
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
*/
23
24
#include "ten.h"
25
#include "privateTen.h"
26
27
#define PARM_NUM 6
28
static const tenModelParmDesc
29
parmDesc[] = {
30
  /* 0 */ {"B0", 0.0, TEN_MODEL_B0_MAX, AIR_FALSE, AIR_FALSE, 0},
31
  /* 1 */ {"diffusivity", 0.0, TEN_MODEL_DIFF_MAX, AIR_FALSE, AIR_FALSE, 0},
32
  /* 2 */ {"fraction", 0.0, 1.0, AIR_FALSE, AIR_FALSE, 0},
33
  /* 3 */ {"x", -1.0, 1.0, AIR_FALSE, AIR_TRUE, 0},
34
  /* 4 */ {"y", -1.0, 1.0, AIR_FALSE, AIR_TRUE, 1},
35
  /* 5 */ {"z", -1.0, 1.0, AIR_FALSE, AIR_TRUE, 2}
36
};
37
38
static void
39
simulate(double *dwiSim, const double *parm, const tenExperSpec *espec) {
40
  unsigned int ii;
41
  double b0, diff, frac, vec[3];
42
43
  b0 = parm[0];
44
  diff = parm[1];
45
  frac = parm[2];
46
  vec[0] = parm[3];
47
  vec[1] = parm[4];
48
  vec[2] = parm[5];
49
  for (ii=0; ii<espec->imgNum; ii++) {
50
    double dwiBall, dwiStck, dot;
51
    dwiBall = exp(-espec->bval[ii]*diff);
52
    dot = ELL_3V_DOT(vec, espec->grad + 3*ii);
53
    dwiStck = exp(-espec->bval[ii]*diff*dot*dot);
54
    dwiSim[ii] = b0*((1-frac)*dwiBall + frac*dwiStck);
55
  }
56
  return;
57
}
58
59
static char *
60
parmSprint(char str[AIR_STRLEN_MED], const double *parm) {
61
  sprintf(str, "(%g) %g * (%g + %g*(%g,%g,%g))", parm[0],
62
          parm[1], 1-parm[2], parm[2], parm[3], parm[4], parm[5]);
63
  return str;
64
}
65
66
_TEN_PARM_ALLOC
67
_TEN_PARM_RAND
68
_TEN_PARM_STEP
69
_TEN_PARM_DIST
70
_TEN_PARM_COPY
71
_TEN_PARM_CONVERT_NOOP
72
73
_TEN_SQE
74
_TEN_SQE_GRAD_CENTDIFF
75
_TEN_SQE_FIT(tenModelBall1StickEMD)
76
77
_TEN_NLL
78
_TEN_NLL_GRAD_STUB
79
_TEN_NLL_FIT_STUB
80
81
tenModel
82
_tenModelBall1StickEMD = {
83
  TEN_MODEL_STR_BALL1STICKEMD,
84
  _TEN_MODEL_FIELDS
85
};
86
const tenModel *const tenModelBall1StickEMD = &_tenModelBall1StickEMD;