Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Required positional parameter "wf" in input and output of `ingress_pipeconfig_paths` function, where a node to reorient templates is added to the `wf`.
- Required positional parameter "orientation" to `resolve_resolution`.
- Optional positional argument "cfg" to `create_lesion_preproc`.
- Allow enabling `overwrite_transform` only when the registration method is `ANTS`.

### Changed

Expand Down
16 changes: 16 additions & 0 deletions CPAC/pipeline/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,22 @@ def schema(config_dict):
" Try turning one option off.\n "
)
raise ExclusiveInvalid(msg)

overwrite = partially_validated["registration_workflows"][
"anatomical_registration"
]["overwrite_transform"]

if (
overwrite["run"]
and "ANTS"
not in partially_validated["registration_workflows"][
"anatomical_registration"
]["registration"]["using"]
):
raise ExclusiveInvalid(
"[!] Overwrite transform method is the same as the anatomical registration method! "
"No need to overwrite transform with the same registration method. Please turn it off or use a different registration method."
)
except KeyError:
pass
try:
Expand Down
30 changes: 30 additions & 0 deletions CPAC/pipeline/test/test_schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,33 @@ def test_pipeline_name():
"""Test that pipeline_name sucessfully sanitizes."""
c = Configuration({"pipeline_setup": {"pipeline_name": ":va:lid name"}})
assert c["pipeline_setup", "pipeline_name"] == "valid_name"


@pytest.mark.parametrize(
"registration_using",
[
list(combo)
for _ in [
list(combinations(["ANTS", "FSL", "FSL-linear"], i)) for i in range(1, 4)
]
for combo in _
],
)
def test_overwrite_transform(registration_using):
"""Test that if overwrite transform method is already a registration method."""
# pylint: disable=invalid-name

d = {
"registration_workflows": {
"anatomical_registration": {
"registration": {"using": registration_using},
"overwrite_transform": {"run": "On", "using": "FSL"},
}
}
}
if "ANTS" in registration_using:
Configuration(d) # validates without exception
else:
with pytest.raises(ExclusiveInvalid) as e:
Configuration(d)
assert "Overwrite transform method is the same" in str(e.value)
3 changes: 3 additions & 0 deletions CPAC/registration/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,9 @@ def overwrite_transform_anat_to_template(wf, cfg, strat_pool, pipe_num, opt=None
"from-template_to-T1w_mode-image_xfm": (merge_inv_xfms, "merged_file"),
}

else:
outputs = {}

return (wf, outputs)


Expand Down