diff --git a/docs/bids_app/workflow.rst b/docs/bids_app/workflow.rst index ee1c7ae2..96646c0c 100644 --- a/docs/bids_app/workflow.rst +++ b/docs/bids_app/workflow.rst @@ -14,10 +14,10 @@ To get access to these additions, the base Snakefile for a snakebids workflow sh inputs = snakebids.generate_inputs( bids_dir=config["bids_dir"], pybids_inputs=config["pybids_inputs"], + skip_bids_validation=config["skip_bids_validation"], derivatives=config.get("derivatives", None), participant_label=config.get("participant_label", None), exclude_participant_label=config.get("exclude_participant_label", None) - ) #this adds constraints to the bids naming diff --git a/docs/running_snakebids/overview.md b/docs/running_snakebids/overview.md index d78ab291..085bed42 100644 --- a/docs/running_snakebids/overview.md +++ b/docs/running_snakebids/overview.md @@ -19,6 +19,8 @@ Indexing of large datasets can be a time-consuming process. Snakebids, through ` 1. Uncomment the lines in `snakebids.yml` containing `pybids_db_dir` and `pybids_db_reset`. 1. The variables can be updated directly in this file or through the CLI by using `-pybidsdb-dir {dir}` to specify the database path and `--reset-db` to indicate that the database should be updated. _Note: CLI arguments take precendence if both CLI and config variables are set._ +Input BIDS datasets are also validated via the bids-validator. By default, this feature uses the command-line (node.js) version of the [validator](https://www.npmjs.com/package/bids-validator). If this is not found to be installed on the system, the `pybids` version of validation will be performed instead. To opt-out validation, one can invoke `--skip-bids-validation`. + Workflow mode ============= diff --git a/snakebids/core/input_generation.py b/snakebids/core/input_generation.py index 0185bf14..b73cce86 100644 --- a/snakebids/core/input_generation.py +++ b/snakebids/core/input_generation.py @@ -135,10 +135,10 @@ def generate_inputs( be specified if participant_label is specified skip_bids_validation : bool, optional - If True, will not perform validation of the input dataset. Otherwise, + If True, will not perform validation of the input dataset. Otherwise, validation is first attempted by performing a system call to `bids-validator` - (e.g. node version), which is has more comprehensive coverage, before falling - back on the python version of the validator. + (e.g. node version), which is has more comprehensive coverage, before falling + back on the python version of the validator. use_bids_inputs : bool, optional If True, opts in to the new :class:`BidsDataset` output, otherwise returns the @@ -268,12 +268,15 @@ def generate_inputs( participant_label, exclude_participant_label ) - # Attempt to validate with node bids-validator, if needed - validated = _validate_input_dir if not skip_bids_validation else None + # Attempt to validate with node bids-validator + validated = ( + _validate_bids_dir + if not skip_bids_validation and not _all_custom_paths(pybids_inputs) + else None + ) - # Generates a BIDSLayout # If not skipping validation, set validate indicator to opposite of output - # from _validate_input_dir, otherwise do not validate + # from _validate_bids_dir, otherwise do not validate layout = ( _gen_bids_layout( bids_dir=bids_dir, @@ -390,7 +393,7 @@ def _gen_bids_layout( ) -def _validate_input_dir( +def _validate_bids_dir( bids_dir: Union[Path, str], ) -> bool: """Perform validation of dataset. Initial attempt at validation performed diff --git a/snakebids/tests/test_generate_inputs.py b/snakebids/tests/test_generate_inputs.py index d459c9bd..d45f7448 100644 --- a/snakebids/tests/test_generate_inputs.py +++ b/snakebids/tests/test_generate_inputs.py @@ -29,7 +29,7 @@ _generate_filters, _get_lists_from_bids, _parse_custom_path, - _validate_input_dir, + _validate_bids_dir, generate_inputs, ) from snakebids.exceptions import ConfigError, PybidsError @@ -1004,7 +1004,7 @@ def start(self, tmpdir): def test_check_validator(self): """Test validator defaults to pybids (i.e. False)""" - assert _validate_input_dir(self.bids_dir) == False + assert _validate_bids_dir(self.bids_dir) == False def test_pybids_validation_fail(self): with pytest.raises(BIDSValidationError):