diff --git a/dandi/bids_utils.py b/dandi/bids_utils.py index 3e4cdbe09..489599df0 100644 --- a/dandi/bids_utils.py +++ b/dandi/bids_utils.py @@ -11,7 +11,7 @@ def is_valid( Parameters ---------- validation_result: dict - Dictionary as returned by `dandi.bids_validator_xs.validate_bids()`. + Dictionary as returned by `dandi.support.bids.validator.validate_bids()`. allow_missing_files: bool, optional Whether to consider the dataset invalid if any mandatory files are not present. allow_invalid_filenames: bool, optional diff --git a/dandi/cli/cmd_validate.py b/dandi/cli/cmd_validate.py index 553e40a69..9e02aa62b 100644 --- a/dandi/cli/cmd_validate.py +++ b/dandi/cli/cmd_validate.py @@ -7,33 +7,44 @@ @click.command() -@devel_option( +@click.option( "--schema", help="Validate against new BIDS schema version", metavar="VERSION" ) -@click.option("--report", help="Specify path to write a report under.") @click.option( - "--report-flag", + "--report-path", + help="Write report under path, this option implies `--report/-r`.", +) +@click.option( + "--report", "-r", is_flag=True, - help="Whether to write a report under a unique path in the current directory. " - "Only usable if `--report` is not already used.", + help="Whether to write a report under a unique path in the DANDI log directory.", ) @click.argument("paths", nargs=-1, type=click.Path(exists=True, dir_okay=True)) @devel_debug_option() @map_to_click_exceptions def validate_bids( - paths, schema=None, devel_debug=False, report=False, report_flag=False + paths, + schema, + report, + report_path, + devel_debug=False, ): - """Validate BIDS paths.""" + """Validate BIDS paths. + + Notes + ----- + Used from bash, eg: + dandi validate-bids /my/path + """ + from ..bids_utils import is_valid, report_errors from ..validate import validate_bids as validate_bids_ - if report_flag and not report: - report = report_flag - validator_result = validate_bids_( *paths, report=report, + report_path=report_path, schema_version=schema, devel_debug=devel_debug, ) diff --git a/dandi/metadata.py b/dandi/metadata.py index 1225a9697..0d9b645cc 100644 --- a/dandi/metadata.py +++ b/dandi/metadata.py @@ -119,7 +119,7 @@ def get_metadata(path: Union[str, Path]) -> Optional[dict]: # could still be augmented with `_is_nwb` to disambiguate both cases # at the detection level. if _path_in_bids(path): - from .bids_validator_xs import validate_bids + from .validate import validate_bids _meta = validate_bids(path) meta = _meta["match_listing"][0] diff --git a/dandi/support/bids/schemadata/1.7.0+012/rules/associated_data.yaml b/dandi/support/bids/schemadata/1.7.0+012/rules/associated_data.yaml deleted file mode 100644 index 609fcafaa..000000000 --- a/dandi/support/bids/schemadata/1.7.0+012/rules/associated_data.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# This file describes the requirement levels of folders which may appear -# within a dataset folder without following BIDS format. -code: - required: false -derivatives: - required: false -sourcedata: - required: false -stimuli: - required: false diff --git a/dandi/support/bids/schemadata/1.7.0+012/rules/tabular_metadata.yaml b/dandi/support/bids/schemadata/1.7.0+012/rules/tabular_metadata.yaml deleted file mode 100644 index e04d10c1f..000000000 --- a/dandi/support/bids/schemadata/1.7.0+012/rules/tabular_metadata.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# scans.tsv -- suffixes: - - scans - extensions: - - .tsv - - .json - entities: - subject: required - # session is required if session is present in the dataset. - session: optional -# sessions.tsv -# This file may only exist if session is present in the dataset. -- suffixes: - - sessions - extensions: - - .tsv - - .json - entities: - subject: required diff --git a/dandi/support/bids/schemadata/1.7.0+012/README.md b/dandi/support/bids/schemadata/1.7.0+369/README.md similarity index 86% rename from dandi/support/bids/schemadata/1.7.0+012/README.md rename to dandi/support/bids/schemadata/1.7.0+369/README.md index c3d142cba..81e3b9d63 100644 --- a/dandi/support/bids/schemadata/1.7.0+012/README.md +++ b/dandi/support/bids/schemadata/1.7.0+369/README.md @@ -1,9 +1,9 @@ # BIDS-schema -Portions of the BIDS specification are defined using YAML files, in order to +Portions of the BIDS specification are defined using YAML files in order to make the specification machine-readable. -Currently, the portions of the specification that rely on this schema are +Currently the portions of the specification that rely on this schema are the entity tables, entity definitions, filename templates, and metadata tables. Any changes to the specification should be mirrored in the schema. @@ -32,14 +32,14 @@ The types of objects currently supported in the schema are: - suffixes, - metadata, - top-level files, -- and non-BIDS associated folders. +- and non-BIDS associated directories. -Each of these object types has a single file in the `objects/` folder. +Each of these object types has a single file in the `objects/` directory. - `modalities.yaml`: The modalities, or types of technology, used to acquire data in a BIDS dataset. These modalities are not reflected directly in the specification. For example, while both fMRI and DWI data are acquired with an MRI, - in a BIDS dataset they are stored in different folders reflecting the two different `datatypes`. + in a BIDS dataset they are stored in different directories reflecting the two different `datatypes`. - `datatypes.yaml`: Data types supported by the specification. The only information provided in the file is: @@ -48,7 +48,7 @@ Each of these object types has a single file in the `objects/` folder. 1. each datatype's full name 1. a free text description of the datatype. -- `entities.yaml`: Entities (key/value pairs in folder and filenames). +- `entities.yaml`: Entities (key-value pairs in directory and filenames). - `metadata.yaml`: All valid metadata fields that are explicitly supported in BIDS sidecar JSON files. @@ -58,7 +58,7 @@ Each of these object types has a single file in the `objects/` folder. - `top_level_files.yaml`: Valid top-level files which may appear in a BIDS dataset. -- `associated_data.yaml`: Folders that may appear within a dataset folder without following BIDS rules. +- `associated_data.yaml`: Directories that may appear within a dataset directory without following BIDS rules. ### On re-used objects with different definitions @@ -73,7 +73,7 @@ For objects with `snake_case` names, two underscores must be used. There should also be a comment near the object definition in the YAML file describing the nature of the different objects. For example, the TSV column `"reference"` means different things when used for EEG data, as compared to iEEG data. -As such, there are two definitions in `columns.yaml` for the `"reference"` column: `"reference__eeg"` and `"reference_ieeg"`. +As such, there are two definitions in `columns.yaml` for the `"reference"` column: `"reference__eeg"` and `"reference__ieeg"`. ```yaml # reference column for channels.tsv files for EEG data @@ -115,7 +115,7 @@ The `description` field is a freeform description of the modality. ### `datatypes.yaml` This file contains a dictionary in which each datatype is defined. -Keys are the folder names associated with each datatype (for example, `anat` for anatomical MRI), +Keys are the directory names associated with each datatype (for example, `anat` for anatomical MRI), and each associated value is a dictionary with two keys: `name` and `description`. The `name` field is the full name of the datatype. @@ -123,7 +123,7 @@ The `description` field is a freeform description of the datatype. ### `entities.yaml` -This file contains a dictionary in which each entity (key/value pair in filenames) is defined. +This file contains a dictionary in which each entity (key-value pair in filenames) is defined. Keys are long-form versions of the entities, which are distinct from both the entities as they appear in filenames _and_ their full names. For example, the key for the "Contrast Enhancing Agent" entity, which appears in filenames as `ce-