From 3ed0705fd3861f4f29e05a6329508db6f9af3599 Mon Sep 17 00:00:00 2001 From: Taylor Salo Date: Tue, 23 Jan 2024 08:40:39 -0500 Subject: [PATCH] Remove `--ignore_subject_consistency` param from `cubids validate` (#276) * Remove `--ignore_subject_consistency` param. * Simplify command. * Fix style issues. --- cubids/cli.py | 10 ---------- cubids/cubids.py | 2 +- cubids/validator.py | 11 +++++------ cubids/workflows.py | 12 +----------- 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/cubids/cli.py b/cubids/cli.py index 40c2eca8..a55cecb0 100644 --- a/cubids/cli.py +++ b/cubids/cli.py @@ -61,16 +61,6 @@ def _parse_validate(): help="Disregard NIfTI header content during validation", required=False, ) - parser.add_argument( - "--ignore_subject_consistency", - action="store_true", - default=True, - help=( - "Skip checking that any given file for one " - "subject is present for all other subjects" - ), - required=False, - ) parser.add_argument( "--sequential-subjects", action="store", diff --git a/cubids/cubids.py b/cubids/cubids.py index 6fdba68b..842215e0 100644 --- a/cubids/cubids.py +++ b/cubids/cubids.py @@ -150,7 +150,7 @@ def datalad_undo_last_commit(self): Uses git reset --hard to revert to the previous commit. """ if not self.is_datalad_clean(): - raise Exception("Untracked changes present. " "Run clear_untracked_changes first") + raise Exception("Untracked changes present. Run clear_untracked_changes first") reset_proc = subprocess.run(["git", "reset", "--hard", "HEAD~1"], cwd=self.path) reset_proc.check_returncode() diff --git a/cubids/validator.py b/cubids/validator.py index 40a130b8..3f670041 100644 --- a/cubids/validator.py +++ b/cubids/validator.py @@ -11,15 +11,14 @@ logger = logging.getLogger("cubids-cli") -def build_validator_call(path, ignore_headers=False, ignore_subject=True): +def build_validator_call(path, ignore_headers=False): """Build a subprocess command to the bids validator.""" # build docker call - command = ["bids-validator", "--verbose", "--json"] + # CuBIDS automatically ignores subject consistency. + command = ["bids-validator", "--verbose", "--json", "--ignoreSubjectConsistency"] if ignore_headers: command.append("--ignoreNiftiHeaders") - if ignore_subject: - command.append("--ignoreSubjectConsistency") command.append(path) @@ -39,7 +38,7 @@ def build_subject_paths(bids_dir): subjects = glob.glob(bids_dir) if len(subjects) < 1: - raise ValueError("Couldn't find any subjects " "in the specified directory:\n" + bids_dir) + raise ValueError("Couldn't find any subjects in the specified directory:\n" + bids_dir) subjects_dict = {} @@ -94,7 +93,7 @@ def parse_issue(issue_dict): return_dict["files"] = [ get_nested(x, "file", "relativePath") for x in issue_dict.get("files", "") ] - return_dict["type"] = issue_dict.get("key" "") + return_dict["type"] = issue_dict.get("key", "") return_dict["severity"] = issue_dict.get("severity", "") return_dict["description"] = issue_dict.get("reason", "") return_dict["code"] = issue_dict.get("code", "") diff --git a/cubids/workflows.py b/cubids/workflows.py index eea9bfa5..37793981 100644 --- a/cubids/workflows.py +++ b/cubids/workflows.py @@ -37,7 +37,6 @@ def validate( sequential, sequential_subjects, ignore_nifti_headers, - ignore_subject_consistency, ): """Run the bids validator. @@ -49,7 +48,6 @@ def validate( sequential sequential_subjects ignore_nifti_headers - ignore_subject_consistency """ # check status of output_prefix, absolute or relative? abs_path_output = True @@ -69,7 +67,6 @@ def validate( call = build_validator_call( str(bids_dir), ignore_nifti_headers, - ignore_subject_consistency, ) ret = run_validator(call) @@ -148,8 +145,7 @@ def validate( # run the validator nifti_head = ignore_nifti_headers - subj_consist = ignore_subject_consistency - call = build_validator_call(tmpdirname, nifti_head, subj_consist) + call = build_validator_call(tmpdirname, nifti_head) ret = run_validator(call) # parse output if ret.returncode != 0: @@ -228,9 +224,6 @@ def validate( if ignore_nifti_headers: cmd.append("--ignore_nifti_headers") - if ignore_subject_consistency: - cmd.append("--ignore_subject_consistency") - elif container_type == "singularity": cmd = [ "singularity", @@ -250,9 +243,6 @@ def validate( if ignore_nifti_headers: cmd.append("--ignore_nifti_headers") - if ignore_subject_consistency: - cmd.append("--ignore_subject_consistency") - if sequential: cmd.append("--sequential")