Skip to content

Commit

Permalink
Remove --ignore_subject_consistency param from cubids validate (#276
Browse files Browse the repository at this point in the history
)

* Remove `--ignore_subject_consistency` param.

* Simplify command.

* Fix style issues.
  • Loading branch information
tsalo authored Jan 23, 2024
1 parent 8e90140 commit 3ed0705
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
10 changes: 0 additions & 10 deletions cubids/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cubids/cubids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 5 additions & 6 deletions cubids/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 = {}

Expand Down Expand Up @@ -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", "")
Expand Down
12 changes: 1 addition & 11 deletions cubids/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def validate(
sequential,
sequential_subjects,
ignore_nifti_headers,
ignore_subject_consistency,
):
"""Run the bids validator.
Expand All @@ -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
Expand All @@ -69,7 +67,6 @@ def validate(
call = build_validator_call(
str(bids_dir),
ignore_nifti_headers,
ignore_subject_consistency,
)
ret = run_validator(call)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand All @@ -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")

Expand Down

0 comments on commit 3ed0705

Please sign in to comment.