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 "Applies and removes the measurement frame" |
28 |
|
|
static const char *_tend_unmfInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". When the given tensor volume has a measurement frame associated " |
31 |
|
|
"with it, this will apply the measurement frame transform to all " |
32 |
|
|
"tensors to convert them into world space, and remove the measurement " |
33 |
|
|
"frame from the nrrd."); |
34 |
|
|
|
35 |
|
|
int |
36 |
|
|
tend_unmfMain(int argc, const char **argv, const char *me, |
37 |
|
|
hestParm *hparm) { |
38 |
|
|
int pret; |
39 |
|
2 |
hestOpt *hopt = NULL; |
40 |
|
1 |
char *perr, *err; |
41 |
|
|
airArray *mop; |
42 |
|
|
|
43 |
|
1 |
Nrrd *nin, *nout; |
44 |
|
1 |
char *outS; |
45 |
|
|
|
46 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, NULL, |
47 |
|
|
"input diffusion tensor volume " |
48 |
|
|
"(sorry, can't use usual default of \"-\" for stdin " |
49 |
|
|
"because of hest quirk)", |
50 |
|
1 |
NULL, NULL, nrrdHestNrrd); |
51 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
52 |
|
|
"output tensor volume"); |
53 |
|
|
|
54 |
|
1 |
mop = airMopNew(); |
55 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
56 |
✓✗ |
2 |
USAGE(_tend_unmfInfoL); |
57 |
|
|
PARSE(); |
58 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
59 |
|
|
|
60 |
|
|
nout = nrrdNew(); |
61 |
|
|
airMopAdd(mop, nout, (airMopper)nrrdNuke, airMopAlways); |
62 |
|
|
if (tenMeasurementFrameReduce(nout, nin)) { |
63 |
|
|
airMopAdd(mop, err=biffGetDone(TEN), airFree, airMopAlways); |
64 |
|
|
fprintf(stderr, "%s: trouble:\n%s\n", me, err); |
65 |
|
|
airMopError(mop); return 1; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
69 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
70 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
71 |
|
|
airMopError(mop); return 1; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
airMopOkay(mop); |
75 |
|
|
return 0; |
76 |
|
1 |
} |
77 |
|
|
TEND_CMD(unmf, INFO); |