Skip to content

Commit

Permalink
Merge pull request #2678 from MRtrix3/python_cmd_changes
Browse files Browse the repository at this point in the history
Python CLI changes
  • Loading branch information
Lestropie authored May 23, 2024
2 parents eac5823 + c2b2e76 commit cda68bd
Show file tree
Hide file tree
Showing 190 changed files with 8,028 additions and 3,662 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@
.check_syntax.tmp
.check_syntax2.tmp
build/
CMakeLists.txt.user
CMakeLists.txt.user
testing/data/tmp*
testing/data/*-tmp-*
7 changes: 4 additions & 3 deletions cmake/BashTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(add_bash_test)
message(FATAL_ERROR "bash not found")
endif()

set(singleValueArgs FILE_PATH PREFIX WORKING_DIRECTORY)
set(singleValueArgs FILE_PATH PREFIX WORKING_DIRECTORY ENVIRONMENT)
set(multiValueArgs EXEC_DIRECTORIES LABELS)
cmake_parse_arguments(
ARG
Expand All @@ -20,6 +20,7 @@ function(add_bash_test)
set(prefix ${ARG_PREFIX})
set(working_directory ${ARG_WORKING_DIRECTORY})
set(exec_directories ${ARG_EXEC_DIRECTORIES})
set(environment ${ARG_ENVIRONMENT})
set(labels ${ARG_LABELS})

# Regenerate tests when the test script changes
Expand Down Expand Up @@ -47,11 +48,11 @@ function(add_bash_test)
)
set_tests_properties(${test_name}
PROPERTIES
ENVIRONMENT "PATH=${exec_directories}"
ENVIRONMENT "PATH=${exec_directories};${environment}"
)
if(labels)
set_tests_properties(${test_name} PROPERTIES LABELS "${labels}")
endif()

message(VERBOSE "Add bash tests commands for ${test_name}: ${line}")
message(VERBOSE "Added bash test command ${test_name}")
endfunction()
5 changes: 4 additions & 1 deletion cmd/mrregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,11 @@ void run() {
case 2:
affine_estimator = Registration::LP;
break;
default:
case 3:
affine_estimator = Registration::None;
break;
default:
assert(false);
}
}

Expand Down
6 changes: 2 additions & 4 deletions core/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,8 @@ std::string markdown_usage() {
s += std::string(REFERENCES[i]) + "\n\n";
s += std::string(MRTRIX_CORE_REFERENCE) + "\n\n";

s += std::string("---\n\nMRtrix ") + mrtrix_version + ", built " + build_date +
"\n\n"
"\n\n**Author:** " +
AUTHOR + "\n\n**Copyright:** " + COPYRIGHT + "\n\n";
s += std::string("**Author:** ") + AUTHOR + "\n\n";
s += std::string("**Copyright:** ") + COPYRIGHT + "\n\n";

return s;
}
Expand Down
15 changes: 14 additions & 1 deletion core/image_io/pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ void Pipe::unload(const Header &) {
}
}

bool Pipe::delete_piped_images = true;
// ENVVAR name: MRTRIX_PRESERVE_TMPFILE
// ENVVAR This variable decides whether the temporary piped image
// ENVVAR should be preserved rather than the usual behaviour of
// ENVVAR deletion at command completion.
// ENVVAR For example, in case of piped commands from Python API,
// ENVVAR it is necessary to retain the temp files until all
// ENVVAR the piped commands are executed.
namespace {
bool preserve_tmpfile() {
const char *const MRTRIX_PRESERVE_TMPFILE = getenv("MRTRIX_PRESERVE_TMPFILE");
return (MRTRIX_PRESERVE_TMPFILE != nullptr && to<bool>(std::string(MRTRIX_PRESERVE_TMPFILE)));
}
} // namespace
bool Pipe::delete_piped_images = !preserve_tmpfile();

} // namespace MR::ImageIO
42 changes: 21 additions & 21 deletions docs/reference/commands/5ttgen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Usage
Description
-----------

5ttgen acts as a 'master' script for generating a five-tissue-type (5TT) segmented tissue image suitable for use in Anatomically-Constrained Tractography (ACT). A range of different algorithms are available for completing this task. When using this script, the name of the algorithm to be used must appear as the first argument on the command-line after '5ttgen'. The subsequent compulsory arguments and options available depend on the particular algorithm being invoked.
5ttgen acts as a "master" script for generating a five-tissue-type (5TT) segmented tissue image suitable for use in Anatomically-Constrained Tractography (ACT). A range of different algorithms are available for completing this task. When using this script, the name of the algorithm to be used must appear as the first argument on the command-line after "5ttgen". The subsequent compulsory arguments and options available depend on the particular algorithm being invoked.

Each algorithm available also has its own help page, including necessary references; e.g. to see the help page of the 'fsl' algorithm, type '5ttgen fsl'.
Each algorithm available also has its own help page, including necessary references; e.g. to see the help page of the "fsl" algorithm, type "5ttgen fsl".

Options
-------
Expand All @@ -39,9 +39,9 @@ Additional standard options for Python scripts

- **-nocleanup** do not delete intermediate files during script execution, and do not delete scratch directory at script completion.

- **-scratch /path/to/scratch/** manually specify the path in which to generate the scratch directory.
- **-scratch /path/to/scratch/** manually specify an existing directory in which to generate the scratch directory.

- **-continue <ScratchDir> <LastFile>** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.
- **-continue ScratchDir LastFile** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.

Standard options
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -107,16 +107,16 @@ Usage

5ttgen freesurfer input output [ options ]

- *input*: The input FreeSurfer parcellation image (any image containing 'aseg' in its name)
- *input*: The input FreeSurfer parcellation image (any image containing "aseg" in its name)
- *output*: The output 5TT image

Options
-------

Options specific to the 'freesurfer' algorithm
Options specific to the "freesurfer" algorithm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- **-lut** Manually provide path to the lookup table on which the input parcellation image is based (e.g. FreeSurferColorLUT.txt)
- **-lut file** Manually provide path to the lookup table on which the input parcellation image is based (e.g. FreeSurferColorLUT.txt)

Options common to all 5ttgen algorithms
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -130,9 +130,9 @@ Additional standard options for Python scripts

- **-nocleanup** do not delete intermediate files during script execution, and do not delete scratch directory at script completion.

- **-scratch /path/to/scratch/** manually specify the path in which to generate the scratch directory.
- **-scratch /path/to/scratch/** manually specify an existing directory in which to generate the scratch directory.

- **-continue <ScratchDir> <LastFile>** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.
- **-continue ScratchDir LastFile** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.

Standard options
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -204,12 +204,12 @@ Usage
Options
-------

Options specific to the 'fsl' algorithm
Options specific to the "fsl" algorithm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- **-t2 <T2 image>** Provide a T2-weighted image in addition to the default T1-weighted image; this will be used as a second input to FSL FAST
- **-t2 image** Provide a T2-weighted image in addition to the default T1-weighted image; this will be used as a second input to FSL FAST

- **-mask** Manually provide a brain mask, rather than deriving one in the script
- **-mask image** Manually provide a brain mask, rather than deriving one in the script

- **-premasked** Indicate that brain masking has already been applied to the input image

Expand All @@ -225,9 +225,9 @@ Additional standard options for Python scripts

- **-nocleanup** do not delete intermediate files during script execution, and do not delete scratch directory at script completion.

- **-scratch /path/to/scratch/** manually specify the path in which to generate the scratch directory.
- **-scratch /path/to/scratch/** manually specify an existing directory in which to generate the scratch directory.

- **-continue <ScratchDir> <LastFile>** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.
- **-continue ScratchDir LastFile** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.

Standard options
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -319,9 +319,9 @@ Additional standard options for Python scripts

- **-nocleanup** do not delete intermediate files during script execution, and do not delete scratch directory at script completion.

- **-scratch /path/to/scratch/** manually specify the path in which to generate the scratch directory.
- **-scratch /path/to/scratch/** manually specify an existing directory in which to generate the scratch directory.

- **-continue <ScratchDir> <LastFile>** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.
- **-continue ScratchDir LastFile** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.

Standard options
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -393,11 +393,11 @@ Usage
Options
-------

- **-template** Provide an image that will form the template for the generated 5TT image
- **-template image** Provide an image that will form the template for the generated 5TT image

- **-hippocampi** Select method to be used for hippocampi (& amygdalae) segmentation; options are: subfields,first,aseg
- **-hippocampi choice** Select method to be used for hippocampi (& amygdalae) segmentation; options are: subfields,first,aseg

- **-thalami** Select method to be used for thalamic segmentation; options are: nuclei,first,aseg
- **-thalami choice** Select method to be used for thalamic segmentation; options are: nuclei,first,aseg

- **-white_stem** Classify the brainstem as white matter

Expand All @@ -413,9 +413,9 @@ Additional standard options for Python scripts

- **-nocleanup** do not delete intermediate files during script execution, and do not delete scratch directory at script completion.

- **-scratch /path/to/scratch/** manually specify the path in which to generate the scratch directory.
- **-scratch /path/to/scratch/** manually specify an existing directory in which to generate the scratch directory.

- **-continue <ScratchDir> <LastFile>** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.
- **-continue ScratchDir LastFile** continue the script from a previous execution; must provide the scratch directory path, and the name of the last successfully-generated file.

Standard options
^^^^^^^^^^^^^^^^
Expand Down
Loading

0 comments on commit cda68bd

Please sign in to comment.