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 "Generate barycentric histograms of anisotropy" |
28 |
|
|
static const char *_tend_anhistInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". The barycentric space used is either one of Westin's " |
31 |
|
|
"triple of spherical, linear, and planar anisotropy. The bin " |
32 |
|
|
"counts in the histogram are weighted by the confidence value."); |
33 |
|
|
|
34 |
|
|
int |
35 |
|
|
tend_anhistMain(int argc, const char **argv, const char *me, |
36 |
|
|
hestParm *hparm) { |
37 |
|
|
int pret; |
38 |
|
2 |
hestOpt *hopt = NULL; |
39 |
|
1 |
char *perr, *err; |
40 |
|
|
airArray *mop; |
41 |
|
|
|
42 |
|
1 |
int version, res, right; |
43 |
|
1 |
Nrrd *nin, *nout, *nwght; |
44 |
|
1 |
char *outS; |
45 |
|
|
|
46 |
|
1 |
hestOptAdd(&hopt, "v", "westin version", airTypeInt, 1, 1, &version, "1", |
47 |
|
|
"Which version of Westin's anisotropy metric triple " |
48 |
|
|
"to use, either \"1\" or \"2\""); |
49 |
|
1 |
hestOptAdd(&hopt, "w", "nweight", airTypeOther, 1, 1, &nwght, "", |
50 |
|
|
"how to weigh contributions to histogram. By default " |
51 |
|
|
"(not using this option), the increment is one bin count per " |
52 |
|
|
"sample, but by giving a nrrd, the value in the nrrd at the " |
53 |
|
|
"corresponding location will be the bin count increment ", |
54 |
|
1 |
NULL, NULL, nrrdHestNrrd); |
55 |
|
1 |
hestOptAdd(&hopt, "r", "res", airTypeInt, 1, 1, &res, NULL, |
56 |
|
|
"resolution of anisotropy plot"); |
57 |
|
1 |
hestOptAdd(&hopt, "right", NULL, airTypeInt, 0, 0, &right, NULL, |
58 |
|
|
"sample a right-triangle-shaped region, instead of " |
59 |
|
|
"a roughly equilateral triangle. "); |
60 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", |
61 |
|
1 |
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); |
62 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
63 |
|
|
"output image (floating point)"); |
64 |
|
|
|
65 |
|
1 |
mop = airMopNew(); |
66 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
67 |
✓✗ |
2 |
USAGE(_tend_anhistInfoL); |
68 |
|
|
PARSE(); |
69 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
70 |
|
|
|
71 |
|
|
nout = nrrdNew(); |
72 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
73 |
|
|
|
74 |
|
|
if (tenAnisoHistogram(nout, nin, nwght, right, version, res)) { |
75 |
|
|
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); |
76 |
|
|
fprintf(stderr, "%s: trouble making histogram:\n%s\n", me, err); |
77 |
|
|
airMopError(mop); return 1; |
78 |
|
|
} |
79 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
80 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
81 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
82 |
|
|
airMopError(mop); return 1; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
airMopOkay(mop); |
86 |
|
|
return 0; |
87 |
|
1 |
} |
88 |
|
|
TEND_CMD(anhist, INFO); |