Skip to content

Commit

Permalink
doc: clear up commandline confusion in mri_segment
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoopes committed Apr 20, 2021
1 parent 56ef910 commit ec2c723
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 56 deletions.
40 changes: 22 additions & 18 deletions mri_segment/mri_segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ int main(int argc, char *argv[])
DiagInit(NULL, NULL, NULL) ;
ErrorInit(NULL, NULL, NULL) ;

for ( ; argc > 1 && ISOPTION(*argv[1]) ; argc--, argv++)
{
for ( ; argc > 1 && ISOPTION(*argv[1]) ; argc--, argv++) {
nargs = get_option(argc, argv) ;
argc -= nargs ;
argv += nargs ;
}

if (argc < 3)
{
usage_exit(1);
}
// the argument parsing here is a little old fashioned (options must come before
// positionals), so let's throw an error to prevent confusion
if (argc < 3) fs::fatal() << "Must provide input and output files. Use --help for more info.";
if (argc > 3) fs::fatal() << "Too many arguments provided. Flagged options must be used before"
" positional arguments. Use --help for more info.";

then.reset() ;
input_file_name = argv[1] ;
Expand Down Expand Up @@ -189,18 +189,22 @@ int main(int argc, char *argv[])
// This is the old code that tries to do the initial segmentation purely based on
// thresholding without reference to the aseg
mri_labels = MRIclone(mri_src, NULL) ;
if (auto_detect_stats && !wm_low_set) /* widen range to allow for more variability */
wm_low -= 10 ;

printf(" WHITE_MATTER_MEAN %d\n",WHITE_MATTER_MEAN);
printf(" wsize %d\n",wsize);

if(scan_type == MRI_MGH_MPRAGE)
printf("assuming input volume is MGH (Van der Kouwe) MP-RAGE\n") ;
printf(" wm_low %g\n",wm_low);
printf(" wm_hi %g\n",wm_hi);
printf(" gray_low %g\n",gray_low);
printf(" gray_hi %g\n",gray_hi);

// widen range to allow for more variability
if (auto_detect_stats && !wm_low_set) {
int decrease = 10;
std::cout << "Widening wm low from " << wm_low << " to " << (wm_low - decrease) << std::endl;
wm_low -= decrease;
}

if(scan_type == MRI_MGH_MPRAGE) printf("assuming input volume is MGH (Van der Kouwe) MP-RAGE\n") ;

std::cout << "wm mean: " << WHITE_MATTER_MEAN << std::endl;
std::cout << "wsize: " << wsize << std::endl;
std::cout << "wm low: " << wm_low << std::endl;
std::cout << "wm hi: " << wm_hi << std::endl;
std::cout << "gray low: " << gray_low << std::endl;
std::cout << "gray hi: " << gray_hi << std::endl;
fflush(stdout);fflush(stderr);

// This is just a simple trinarization:
Expand Down
46 changes: 8 additions & 38 deletions mri_segment/mri_segment.help.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE help [
<!ENTITY lt "#38;#60;">
<!ENTITY gt "&#62;">
<!ENTITY amp "&#38;#38;">
<!ELEMENT help (name , synopsis , description , arguments+ , outputs* , example* , bugs* , reporting* , see-also*)*>
<!ELEMENT name (#PCDATA)>
<!ELEMENT synopsis (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT arguments (positional* , required-flagged* , optional-flagged*)*>
<!ELEMENT positional (intro* , argument* , explanation*)*>
<!ELEMENT required-flagged (intro* , argument* , explanation*)*>
<!ELEMENT optional-flagged (intro* , argument* , explanation*)*>
<!ELEMENT intro (#PCDATA)>
<!ELEMENT argument (#PCDATA)>
<!ELEMENT explanation (#PCDATA)>
<!ELEMENT outputs (output* , explanation*)>
<!ELEMENT output (#PCDATA)>
<!ELEMENT example (#PCDATA)>
<!ELEMENT bugs (#PCDATA)>
<!ELEMENT reporting (#PCDATA)>
<!ELEMENT see-also (#PCDATA)>
]>

<help>

<name>mri_segment</name>
<synopsis>mri_segment &lt;classifierfile&gt; &lt;invol&gt; &lt;outvol&gt;</synopsis>
<description>This program segments white matter from the input volume. The input volume should be normalized such that white matter voxels are ~110-valued, and the volume is conformed to 256^3. This can be accomplished by: mri_normalize invol outvol -conform</description>
<synopsis>mri_segment [options] &lt;invol&gt; &lt;outvol&gt;</synopsis>
<description>This program segments white matter from the input volume. The input volume should be normalized such that white matter voxels are ~110-valued, and the volume is conformed to 256^3. This can be accomplished by `mri_normalize -conform invol outvol`. Note that flagged options must be provided before positional arguments.</description>

<arguments>
<positional>
<argument>&lt;classifierfile&gt;</argument>
<explanation>classifier file</explanation>
<argument>&lt;invol&gt;</argument>
<explanation>input volume</explanation>
<argument>&lt;outvol&gt;</argument>
<explanation>output volume</explanation>
</positional>
<required-flagged>
</required-flagged>

<optional-flagged>
<argument>-no1d_remove &lt;s&gt;;</argument>
<explanation>don't run code that removes 1D strands from segmentation</explanation>
Expand All @@ -59,7 +34,7 @@
<argument>-ghi,-gray_hi &lt;h&gt;</argument>
<explanation>set the gray matter high limit (default=100.000)</explanation>
<argument>-wlo,-wm_low &lt;l&gt;</argument>
<explanation>set the white matter low limit (default=90.000)</explanation>
<explanation>set the white matter low limit (default=80.000)</explanation>
<argument>-wm_low_factor &lt;f&gt;</argument>
<explanation>wm_low = f*gray_mean + (1-f)*white_mean;</explanation>
<argument>-whi,-wm_hi &lt;h&gt;</argument>
Expand Down Expand Up @@ -94,7 +69,7 @@
<explanation>set len for plane of least variance (default=3)</explanation>
<argument>-dat datfile</argument>
<explanation>set datfile (default is segment.dat)</explanation>
<argument>-seg segmenationvolume SegErodeMM WMBiasFactor</argument>
<argument>-seg segmenation volume SegErodeMM WMBiasFactor</argument>
<explanation>Uses segmentation (eg, aseg.presurf.mgz) to set thresholds</explanation>
<argument>-diagno diagno</argument>
<explanation>Set diagnostic number</explanation>
Expand All @@ -106,10 +81,5 @@
<explanation>usage</explanation>
</optional-flagged>
</arguments>
<outputs>
<output>&lt;outvol&gt;</output>
<explanation>output volume</explanation>
</outputs>
<reporting>Report bugs to &lt;[email protected]&gt;</reporting>
</help>

</help>

0 comments on commit ec2c723

Please sign in to comment.