CLI Reference#
The thesis CLI is built with Click. Source: src/thesis/cli.py. Run thesis --help for the auto-generated help text.
Top-level group#
thesis [GLOBAL OPTIONS] <subcommand> [SUBCOMMAND OPTIONS]
Global options must appear before the subcommand.
Flag |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Loguru log level for the file handler. Verbose mode ( |
|
path |
|
Directory for runtime log files. |
|
flag |
off |
Verbose output: shows all events and underlying log records. Sets |
|
flag |
off |
Quiet output: errors and final result only. Sets |
|
|
|
End-of-run summary detail. Overrides |
|
flag |
off |
Disable spinners/progress bars. Auto-disabled for non-TTY or when |
|
flag |
— |
Print the version and exit. |
thesis run#
Execute a registered workflow for one or more patients.
thesis run -w <workflow> [-c <config>] [-p <patient>]... [OPTIONS]
Flag |
Required |
Default |
Description |
|---|---|---|---|
|
(or |
— |
Registered workflow name. Run |
|
(or |
— |
Path to a user-supplied workflow script ( |
|
no |
|
Config name (e.g. |
|
no |
(workflow default) |
Protocol name override. Resolved as: CLI |
|
(or |
— |
Patient ID. Repeat for multiple ( |
|
(or |
off |
Discover and process all numeric patient folders in |
|
no |
— |
Glob pattern for patient-folder discovery (requires |
|
no |
off |
Enable parallel execution via a Nipype meta-workflow. Implied by |
|
no |
— |
Worker count. Overrides |
|
no |
|
Retry attempts per patient on failure. Each retry waits 60 s; in parallel mode the meta-workflow is re-run with Nipype caching so only failed nodes re-execute. |
|
no |
|
Shared assets directory (templates, atlases, ROIs). When omitted it falls back to |
|
no |
(from config) |
Override |
|
no |
|
Override the workflow output directory. |
|
no |
|
Configuration directory. |
|
no |
off |
Write a workflow graph PNG to |
|
no |
off |
Build the workflow (and run preflight verification) but don’t execute it. |
|
no |
(from config) |
|
Where inputs and outputs live#
With the default config, paths resolve relative to the project root. The three location flags map to these defaults:
Flag |
Default |
Holds |
|---|---|---|
|
|
Base directory anchoring discovery and input resolution. |
|
|
Raw vendor inputs the |
|
|
Per-patient workflow outputs. |
So for patient 114823, the default layout is:
data/raw/114823/ # raw vendor inputs (preprocess / --all discovery)
outputs/114823/ # workflow outputs
HCP-style workflows (hcp, mrtrix3, tract_synthseg) read pre-built inputs from the HCP-layout produced by preprocess (under data/processed/<patient_id>/T1w/, including T1w/Diffusion.bedpostX/); the hcp protocol sets paths.inputs_dir: processed/ so discovery points there. Override any of the three flags to relocate a tree without editing config.
Cohort-level workflows#
atlas, learned_atlas, tract_similarity_cohort, tract_similarity_hcp_loo, and tract_similarity_sweep are cohort-level (their WorkflowEntry.is_cohort_level == True). They ignore -p/--patient-id and --all and scan the configured output directory for per-subject outputs.
Examples#
# Single patient
thesis run -w hcp -p 114823 -c default
thesis run -w mrtrix3 -p 114823 -c mrtrix3
# Dry run (build, verify, but don't execute)
thesis run -w hcp -p 114823 -c default --dry-run
# Multiple patients, sequential, with retries
thesis run -w hcp -p 114823 -p 115320 -c default -r 2
# Auto-discover + parallel
thesis run -w hcp --all -c default -j 4
thesis run -w hcp --all --pattern 'P*' -c default
# End-to-end pipeline
thesis run -w full_pipeline -p 114823 -c full_pipeline
thesis run -w full_pipeline -p 114823 -c full_pipeline_mrtrix3 # MRtrix3 backend (tractography.method: mrtrix3)
# Cohort workflows (patient flags ignored)
thesis run -w atlas -c default
thesis run -w tract_similarity_cohort -c default
thesis run -w tract_similarity_sweep -c default
# Tractography hemisphere selection
thesis run -w hcp -p 114823 -c default --hemisphere both-separately
# Inspect workflow graph
thesis run -w hcp -p 114823 -c default --graph --dry-run
thesis list-workflows#
List every registered workflow with description and (when set) default protocol. Auto-imports every thesis.workflows.* submodule to trigger self-registration.
thesis list-workflows [--config <name>] [--config-dir <path>]
Flag |
Default |
Description |
|---|---|---|
|
|
Config to read |
|
|
Configuration directory. |
thesis list-configs#
List available configuration files.
thesis list-configs [--config-dir <path>] [--subdir patients|protocols]
Flag |
Default |
Description |
|---|---|---|
|
|
Configuration directory. |
|
— |
Restrict listing to a subdirectory ( |
thesis show-config#
Print the merged configuration as YAML.
thesis show-config <config_name> [--config-dir <path>]
thesis show-config default
thesis info#
Display version, Python/platform info, dependency status, and external-tool availability (FSL, ANTs).
thesis info
thesis stats collect#
Re-run the post-batch tractography stats collector against an existing output directory and write the result as JSON. The schema matches what batch runs produce automatically under <output_dir>/batch_stats/.
thesis stats collect -o <output-dir> [OPTIONS]
Flag |
Required |
Default |
Description |
|---|---|---|---|
|
yes |
— |
Root directory containing per-subject output subdirectories. |
|
no |
(auto-discover) |
Limit to specific patient IDs. Repeat for multiple. |
|
no |
|
Destination JSON file. |
|
no |
|
Outlier detection threshold in standard deviations. |
|
no |
|
Relative path under each patient directory where the tractography run lives. Use |
|
no |
|
Relative path under each patient directory where |
Examples#
# Default (ProbTrackX2 layout)
thesis stats collect -o data/processed/
# MRtrix3 layout, custom output, looser outlier threshold
thesis stats collect \
-o data/processed/ \
--tractography-relpath tractography/mrtrix3 \
--out reports/mrtrix3_stats.json \
--sd-threshold 3.0
# Limit to specific subjects
thesis stats collect -o data/processed/ -p 114823 -p 115320
Exit codes#
Code |
Meaning |
|---|---|
|
Run completed successfully (all patients succeeded, dry-run completed, or stats written). |
|
One or more patients failed, were blocked (e.g. preflight verification failed), or stats collection found no subjects. |
|
Click usage error (mutually exclusive flags, missing required arg). |
CLI ↔ config mapping#
CLI flag |
YAML key |
Notes |
|---|---|---|
|
|
|
|
|
|
|
|
Implies |
|
|
Also raises log level to DEBUG |
|
|
|
|
|
|
|
|
|
|
(logger only) |
DEBUG/INFO/WARNING/ERROR |
See configuration/output.md for the YAML defaults that the CLI flags override.