|
3 | 3 |
|
4 | 4 | help1 = r"""[nitorch] register |
5 | 5 |
|
6 | | -usage: |
7 | | - nitorch register [options] |
| 6 | +usage: |
| 7 | + nitorch register [options] |
8 | 8 | @loss [NAME] [FACTOR] @@fix *FILE @@mov *FILE ... |
9 | 9 | @affine [NAME] [FACTOR] @@optim [NAME] ... |
10 | 10 | @nonlin [NAME] [FACTOR] @@optim [NAME] ... |
11 | 11 | @optim [NAME] ... |
12 | | - |
| 12 | +
|
13 | 13 | nitorch register -h [LEVEL] |
14 | 14 | LEVEL can be: |
15 | 15 | [1] This help |
|
20 | 20 |
|
21 | 21 | help2 = r"""[nitorch] register |
22 | 22 |
|
23 | | -usage: |
24 | | - nitorch register [options] |
| 23 | +usage: |
| 24 | + nitorch register [options] |
25 | 25 | @loss [NAME] [FACTOR] @@fix *FILE @@mov *FILE ... |
26 | 26 | @affine [NAME] [FACTOR] @@optim [NAME] ... |
27 | 27 | @nonlin [NAME] [FACTOR] @@optim [NAME] ... |
|
30 | 30 |
|
31 | 31 | @loss options: |
32 | 32 | NAME can take values (with specific sub-options): |
33 | | - [mi, nmi] Mutual information (can be normalized) |
| 33 | + [mi, nmi] Mutual information (can be normalized) |
34 | 34 | mse, l2 Mean squared error (can be weighted) |
35 | 35 | mad, l1 Median absolute deviation (can be weighted) |
36 | 36 | tuk, tukey Tukey's biweight function (can be weighted) |
|
55 | 55 | [v, svf] Stationary velocity field |
56 | 56 | g, shoot Geodesic shooting |
57 | 57 | d, smalldef Dense deformation field |
58 | | - |
| 58 | +
|
59 | 59 | @optim options: |
60 | 60 | NAME can take values: |
61 | 61 | [i, interleaved] Interleaved optimization of affine and nonlin |
62 | 62 | s, sequential Sequential optimization of affine, then nonlin |
63 | | - |
| 63 | +
|
64 | 64 | @@optim options: |
65 | 65 | NAME can take values: |
66 | 66 | gn, gauss-newton Second-order method. Not all losses can be used. |
|
77 | 77 | -h, --help [LEVEL] Display this help: [1=minimal], 2=normal, 3=more details |
78 | 78 | -v, --verbose [LVL] Level of verbosity [1=print], 2=plot |
79 | 79 | -r, --framerate Framerate of plotting function, in Hz [1] |
80 | | - |
| 80 | +
|
81 | 81 | """ |
82 | 82 |
|
83 | 83 | help3 = r"""[nitorch] register |
84 | 84 |
|
85 | | -usage: |
86 | | - nitorch register [options] |
| 85 | +usage: |
| 86 | + nitorch register [options] |
87 | 87 | @loss [NAME] [FACTOR] ... |
88 | 88 | @@fix *FILE [-o *FILE] [-r *FILE] [-p *LVL] ... |
89 | 89 | @@mov *FILE [-o *FILE] [-r *FILE] [-p *LVL] ... |
|
93 | 93 | @@optim [NAME] ... |
94 | 94 | @optim [NAME] ... |
95 | 95 | @pyramid [NAME] ... |
96 | | - |
| 96 | +
|
97 | 97 | @loss options: |
98 | 98 | FACTOR must be a scalar value [1] |
99 | 99 | NAME can take values (with specific sub-options): |
100 | | - [mi, nmi] Mutual information (can be normalized) |
| 100 | + [mi, nmi] Mutual information (can be normalized) |
101 | 101 | -m, --norm NAME Normalization: [studholme], arithmetic, geometric, no |
102 | 102 | -b, --bins VAL [VAL] Number of bins in the joint histogram [32] |
103 | 103 | -f, --fwhm VAL Full width half-max of histogram smoothing [1] |
|
106 | 106 | -w, --weight [VAL] Weight (= Gaussian precision): [auto] |
107 | 107 | mad, l1 Median absolute deviation (can be weighted) |
108 | 108 | -w, --weight [VAL] Weight (= Laplace precision): [auto] |
109 | | - -j, --joint Joint weight map across channels [false] |
| 109 | + -j, --joint Joint weight map across channels [false] |
110 | 110 | tuk, tukey Tukey's biweight function (can be weighted) |
111 | 111 | -w, --weight [VAL] Weight (= Laplace precision): [auto] |
112 | | - -j, --joint Joint weight map across channels [false] |
| 112 | + -j, --joint Joint weight map across channels [false] |
113 | 113 | cc, ncc Correlation coefficient (= Normalized cross correlation) |
114 | 114 | lcc, lncc Local correlation coefficient |
115 | 115 | -p, --patch *VAL [UNIT] Patch size [10] and unit: vox, mm, [pct] |
|
131 | 131 | -z, --slicewise [AXIS=-1] Make loss slice-wise [False] |
132 | 132 |
|
133 | 133 | @@fix/mov options: |
134 | | - *FILES must be one or several filenames, which will be concatenated |
| 134 | + *FILES must be one or several filenames, which will be concatenated |
135 | 135 | across the channel dimension. |
136 | 136 | -o, --output [PATH] Path to the output with minimal reslicing: [True={base}.moved.{ext}] |
137 | 137 | -r, --resliced [PATH] Path to the output resliced to the other image's space: [False], True={base}.resliced.{ext} |
|
150 | 150 | -x, --missing *VAL Values that should be considered missing [0] |
151 | 151 | --no-missing No value should be considered missing |
152 | 152 | --mind [FWHM=1 [RADIUS=0]] Compute MIND features |
| 153 | + -c, --channels *C Channels to load. Can be a range start:stop:step [:] |
153 | 154 |
|
154 | 155 | @affine options: |
155 | 156 | FACTOR must be a scalar value [1] and is a global penalty factor |
|
191 | 192 | -n, --max-iter Maximum number of iterations |
192 | 193 | -t, --tolerance Tolerance for early stopping |
193 | 194 | s, sequential Sequential optimization of affine, then nonlin |
194 | | - |
| 195 | +
|
195 | 196 | @@optim options: |
196 | 197 | The default solver is chosen based on the loss. |
197 | | - Usually, losses that define a Hessian are solved by Gauss-Newton, |
198 | | - and the others by LBFGS for the affine component and Nesterov with |
| 198 | + Usually, losses that define a Hessian are solved by Gauss-Newton, |
| 199 | + and the others by LBFGS for the affine component and Nesterov with |
199 | 200 | Wolfe line search for the nonlinear component. |
200 | | - |
| 201 | +
|
201 | 202 | NAME can take values (with options): |
202 | 203 | gn, gauss-newton Second-order method. Not all losses can be used. |
203 | 204 | -m, --marquardt Levenberg-Marquardt regularization [auto] |
|
249 | 250 | -o, --output-dir Output directory [same as input files] |
250 | 251 | -h, --help [LEVEL] Display this help: 0=minimal, [1=normal], 2=more details |
251 | 252 | -v, --verbose [LVL] Level of verbosity [0] |
252 | | - |
| 253 | +
|
253 | 254 | """ |
254 | 255 |
|
255 | 256 | help = {1: help1, 2: help2, 3: help3} |
@@ -286,8 +287,10 @@ def parse_range(x): |
286 | 287 | start, stop, step = x |
287 | 288 | start = int(start or 0) |
288 | 289 | step = int(step or 1) |
289 | | - stop = int(stop) |
290 | | - return range(start, stop, step) |
| 290 | + if stop == '': |
| 291 | + return slice(start, None, step) |
| 292 | + else: |
| 293 | + return range(start, int(stop), step) |
291 | 294 |
|
292 | 295 |
|
293 | 296 | # Main options |
@@ -440,6 +443,7 @@ def _convert(x): |
440 | 443 | action=cli.Actions.store_value([]), help='No missing values') |
441 | 444 | file.add_option('mind', '--mind', nargs='*2', default=[], convert=float, |
442 | 445 | action=cli.Actions.store_value([1, 2])) |
| 446 | +file.add_option('channels', ('-c', '--channels'), nargs='1*', convert=parse_range, default=[slice(None)]) |
443 | 447 | fix = cli.Group('fix', '@@fix', n=1) |
444 | 448 | fix.copy_from(file) |
445 | 449 | mov = cli.Group('mov', '@@mov', n=1) |
|
0 commit comments