Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions cubids/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def _parse_validate():
nargs="+",
required=False,
)
parser.add_argument(
"--local-validator",
action="store_true",
default=False,
help="Lets user run a locally installed BIDS validator. Default is set to False ",
required=False,
)
return parser


Expand Down
7 changes: 5 additions & 2 deletions cubids/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
logger = logging.getLogger("cubids-cli")


def build_validator_call(path, ignore_headers=False):
def build_validator_call(path, local_validator=False, ignore_headers=False):
"""Build a subprocess command to the bids validator."""
# New schema BIDS validator doesn't have option to ignore subject consistency.
# Build the deno command to run the BIDS validator.
command = ["deno", "run", "-A", "jsr:@bids/validator", path, "--verbose", "--json"]
if local_validator:
command = ["bids-validator", path, "--verbose", "--json"]
else:
command = ["deno", "run", "-A", "jsr:@bids/validator", path, "--verbose", "--json"]

if ignore_headers:
command.append("--ignoreNiftiHeaders")
Expand Down
6 changes: 5 additions & 1 deletion cubids/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def validate(
container,
sequential,
sequential_subjects,
local_validator,
ignore_nifti_headers,
):
"""Run the bids validator.
Expand All @@ -55,6 +56,8 @@ def validate(
Run the validator sequentially.
sequential_subjects : :obj:`list` of :obj:`str`
Filter the sequential run to only include the listed subjects.
local_validator : :obj:`bool`
Use the local bids validator.
ignore_nifti_headers : :obj:`bool`
Ignore NIfTI headers when validating.
"""
Expand All @@ -75,6 +78,7 @@ def validate(
# run on full dataset
call = build_validator_call(
str(bids_dir),
local_validator,
ignore_nifti_headers,
)
ret = run_validator(call)
Expand Down Expand Up @@ -154,7 +158,7 @@ def validate(

# run the validator
nifti_head = ignore_nifti_headers
call = build_validator_call(tmpdirname, nifti_head)
call = build_validator_call(tmpdirname, local_validator, nifti_head)
ret = run_validator(call)
# parse output
if ret.returncode != 0:
Expand Down
Loading