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 "Slice 3D tensors to get slab/image of 3D/2D tensors" |
28 |
|
|
static const char *_tend_sliceInfoL = |
29 |
|
|
(INFO |
30 |
|
|
". "); |
31 |
|
|
|
32 |
|
|
int |
33 |
|
|
tend_sliceMain(int argc, const char **argv, const char *me, |
34 |
|
|
hestParm *hparm) { |
35 |
|
|
int pret; |
36 |
|
2 |
hestOpt *hopt = NULL; |
37 |
|
1 |
char *perr, *err; |
38 |
|
|
airArray *mop; |
39 |
|
|
|
40 |
|
1 |
char *outS; |
41 |
|
1 |
int axis, pos, dim; |
42 |
|
1 |
Nrrd *nin, *nout; |
43 |
|
|
|
44 |
|
1 |
hestOptAdd(&hopt, "a", "axis", airTypeInt, 1, 1, &axis, NULL, |
45 |
|
|
"axis along which to slice"); |
46 |
|
1 |
hestOptAdd(&hopt, "p", "pos", airTypeInt, 1, 1, &pos, NULL, |
47 |
|
|
"position to slice at"); |
48 |
|
1 |
hestOptAdd(&hopt, "d", "dim", airTypeInt, 1, 1, &dim, "3", |
49 |
|
|
"dimension of desired tensor output, can be either 2 or 3"); |
50 |
|
1 |
hestOptAdd(&hopt, "i", "nin", airTypeOther, 1, 1, &nin, "-", |
51 |
|
1 |
"input diffusion tensor volume", NULL, NULL, nrrdHestNrrd); |
52 |
|
1 |
hestOptAdd(&hopt, "o", "nout", airTypeString, 1, 1, &outS, "-", |
53 |
|
|
"output tensor slice"); |
54 |
|
|
|
55 |
|
1 |
mop = airMopNew(); |
56 |
|
1 |
airMopAdd(mop, hopt, (airMopper)hestOptFree, airMopAlways); |
57 |
✓✗ |
2 |
USAGE(_tend_sliceInfoL); |
58 |
|
|
PARSE(); |
59 |
|
|
airMopAdd(mop, hopt, (airMopper)hestParseFree, airMopAlways); |
60 |
|
|
airMopAdd(mop, nout=nrrdNew(), (airMopper)nrrdNuke, airMopAlways); |
61 |
|
|
|
62 |
|
|
if (tenSlice(nout, nin, axis, pos, dim)) { |
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 |
|
|
if (nrrdSave(outS, nout, NULL)) { |
68 |
|
|
airMopAdd(mop, err=biffGetDone(NRRD), airFree, airMopAlways); |
69 |
|
|
fprintf(stderr, "%s: trouble writing:\n%s\n", me, err); |
70 |
|
|
airMopError(mop); return 1; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
airMopOkay(mop); |
74 |
|
|
return 0; |
75 |
|
1 |
} |
76 |
|
|
TEND_CMD(slice, INFO); |
77 |
|
|
|