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 INFO "Scale the anisotropic component of the tensors" |
28 |
|
|
static const char *_tend_anscaleInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". This maintains the isotropic component of the tensor, and fixes " |
31 |
|
|
"either the trace or determinant, " |
32 |
|
|
"while scaling up (or down) the \"deviatoric\" component " |
33 |
|
|
"of the tensor. Good for exaggerating the shape of nearly isotropic " |
34 |
|
|
"tensors."); |
35 |
|
|
|
36 |
|
|
int |
37 |
|
|
tend_anscaleMain(int argc, const char **argv, const char *me, |
38 |
|
|
hestParm *hparm) { |
39 |
|
|
int pret; |
40 |
|
2 |
hestOpt *hopt = NULL; |
41 |
|
1 |
char *perr, *err; |
42 |
|
|
airArray *mop; |
43 |
|
|
|
44 |
|
1 |
Nrrd *nin, *nout; |
45 |
|
1 |
char *outS; |
46 |
|
1 |
float scale; |
47 |
|
1 |
int fixDet, makePositive; |
48 |
|
|
|
49 |
|
1 |
hestOptAdd(&hopt, "s", "scale", airTypeFloat, 1, 1, &scale, NULL, |
50 |
|
|
"Amount by which to scale deviatoric component of tensor."); |
51 |
|
1 |
hestOptAdd(&hopt, "fd", NULL, airTypeInt, 0, 0, &fixDet, NULL, |
52 |
|
|
"instead of fixing the per-sample trace (the default), fix the " |
53 |
|
|
"determinant (ellipsoid volume)"); |
54 |
|
1 |
hestOptAdd(&hopt, "mp", NULL, airTypeInt, 0, 0, &makePositive, NULL, |
55 |
|
|
"after changing the eigenvalues of the tensor, enforce their " |
56 |
|
|
"non-negative-ness. By default, no such constraint is imposed."); |
57 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", |
58 |
|
1 |
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); |
59 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
60 |
|
|
"output image (floating point)"); |
61 |
|
|
|
62 |
|
1 |
mop = airMopNew(); |
63 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
64 |
✓✗ |
2 |
USAGE(_tend_anscaleInfoL); |
65 |
|
|
PARSE(); |
66 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
67 |
|
|
|
68 |
|
|
nout = nrrdNew(); |
69 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
70 |
|
|
if (tenAnisoScale(nout, nin, scale, fixDet, makePositive)) { |
71 |
|
|
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); |
72 |
|
|
fprintf(stderr, "%s: trouble:\n%s\n", me, err); |
73 |
|
|
airMopError(mop); return 1; |
74 |
|
|
} |
75 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
76 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
77 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
78 |
|
|
airMopError(mop); return 1; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
airMopOkay(mop); |
82 |
|
|
return 0; |
83 |
|
1 |
} |
84 |
|
|
TEND_CMD(anscale, INFO); |