Skip to content

Commit

Permalink
add N4 option to specify number of resolutions and iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoopes committed Sep 19, 2020
1 parent dcf4971 commit f5d43e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions AntsN4BiasFieldCorrectionFs/AntsN4BiasFieldCorrectionFs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ int main(int argc, char **argv)
parser.addArgument("-i", "--input", 1, String, true);
parser.addArgument("-o", "--output", 1, String, true);
parser.addArgument("-s", "--shrink", 1, Int, false);
parser.addArgument("-t", "--iters", '+', Int, false);
parser.parse(argc, argv);

std::string inputname = parser.retrieve<std::string>("input");
Expand Down Expand Up @@ -60,10 +61,13 @@ int main(int argc, char **argv)
CorrecterType::Pointer correcter = CorrecterType::New();

// convergence options
CorrecterType::VariableSizeArrayType maximumNumberOfIterations(4);
maximumNumberOfIterations.Fill(50);
// set number of iterations (default is 50x50x50x50)
std::vector<int> numIters = {50, 50, 50, 50};
if (parser.exists("iters")) numIters = parser.retrieve<std::vector<int>>("iters");
CorrecterType::VariableSizeArrayType maximumNumberOfIterations(numIters.size());
for (unsigned int d = 0; d < numIters.size(); d++) maximumNumberOfIterations[d] = numIters[d];
correcter->SetMaximumNumberOfIterations(maximumNumberOfIterations);
correcter->SetNumberOfFittingLevels(4);
correcter->SetNumberOfFittingLevels(numIters.size());
correcter->SetConvergenceThreshold(0.0);

// shrink the image to save time
Expand Down
14 changes: 8 additions & 6 deletions AntsN4BiasFieldCorrectionFs/AntsN4BiasFieldCorrectionFs.help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<description>Runs N4 (nonparameteric, nonuniform normalization) retrospective bias correction on an image. This programs wraps the AntsN4BiasFieldCorrection utility available in the ANTs package (see http://stnava.github.io/ANTs).</description>
<arguments>
<required-flagged>
<argument>-i, --input invol</argument>
<explanation>input volume file</explanation>
<argument>-o, --output outvol</argument>
<explanation>corrected volume file</explanation>
<argument>-i, --input FILE</argument>
<explanation>Input volume file.</explanation>
<argument>-o, --output FILE</argument>
<explanation>Corrected volume file.</explanation>
</required-flagged>
<optional-flagged>
<argument>--shrink</argument>
<explanation>resample factor to decrease computation time (default is 4)</explanation>
<argument>-s, --shrink INT</argument>
<explanation>Resample factor to decrease computation time. Default is 4.</explanation>
<argument>-t, --iters INT [INT...]</argument>
<explanation>Number of resolutions and max iterations per resolution. Default is `50 50 50 50`, which indicates 4 fitting levels with 50 iterations each.</explanation>
</optional-flagged>
</arguments>
</help>

0 comments on commit f5d43e9

Please sign in to comment.