Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly check for -p none and --custom-confounds #1222

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions xcp_d/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,14 @@ def _validate_parameters(opts, build_log, parser):
"you must enable cifti processing (--file-format cifti)."
)

# Warn if the user combines custom confounds with the 'none' parameter set
if opts.params == "none" and opts.custom_confounds:
build_log.warning(
"Custom confounds were provided, but --nuisance-regressors was set to none. "
"Overriding the 'none' value and setting to 'custom'."
)
opts.params = "custom"

if error_messages:
error_message_str = "Errors detected in parameter parsing:\n\t- " + "\n\t- ".join(
error_messages
Expand Down
17 changes: 17 additions & 0 deletions xcp_d/tests/test_cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def base_opts():
"mode": "linc",
"file_format": "auto",
"input_type": "auto",
"params": "36P",
"high_pass": 0.01,
"low_pass": 0.1,
"bandpass_filter": True,
Expand Down Expand Up @@ -127,6 +128,22 @@ def test_validate_parameters_06(base_opts, base_parser, capsys):
assert "In order to perform surface normalization" in stderr


def test_validate_parameters_07(base_opts, base_parser, caplog, tmp_path_factory):
"""Test parser._validate_parameters custom confounds + none."""
tmpdir = tmp_path_factory.mktemp("test_validate_parameters_07")
confounds_path = Path(os.path.join(tmpdir, "confounds.tsv"))
confounds_path.touch() # create the file

opts = deepcopy(base_opts)
opts.params = "none"
opts.custom_confounds = confounds_path

opts = parser._validate_parameters(deepcopy(opts), build_log, parser=base_parser)

assert opts.params == "custom"
assert "Overriding the 'none' value and setting to 'custom'" in caplog.text


def test_validate_parameters_motion_filtering(base_opts, base_parser, caplog, capsys):
"""Test parser._validate_parameters."""
opts = deepcopy(base_opts)
Expand Down