Skip to content

Commit

Permalink
RF: detect BIDS based on having dataset_description.json
Browse files Browse the repository at this point in the history
Having .json does not mandate it being BIDS
  • Loading branch information
yarikoptic committed Nov 4, 2024
1 parent 7074582 commit 202b063
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,10 @@ def _add_asset_to_stats(assetmeta: Dict[str, Any], stats: _stats_type) -> None:
if "nwb" in assetmeta["encodingFormat"]:
if models.nwb_standard not in stats["dataStandard"]:
stats["dataStandard"].append(models.nwb_standard)
# TODO: RF assumption that any .json implies BIDS
if set(Path(assetmeta["path"]).suffixes).intersection((".json", ".nii")):
# TODO?: ideally we should have checked if content contains BIDSVersion
# File might be within a folder or a subdataset, so we will not
# restrict to be on the top level only.
if Path(assetmeta["path"]).name == "dataset_description.json":
if models.bids_standard not in stats["dataStandard"]:
stats["dataStandard"].append(models.bids_standard)

Expand Down
25 changes: 25 additions & 0 deletions dandischema/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,31 @@ def test_aggregation_bids() -> None:
],
"blobDateModified": "2021-07-10T18:58:25-04:00",
},
{
"@context": "https://raw.githubusercontent.com/dandi/shortened",
"schemaKey": "Asset",
"repository": "https://dandiarchive.org/",
"dateModified": "2021-10-05T13:08:07.855880-04:00",
"schemaVersion": "0.6.0",
"encodingFormat": "application/json",
"blobDateModified": "2021-10-04T15:58:52.266222-04:00",
"id": "dandiasset:34e30fa6-cf6a-4a32-90cb-b06f6f2f30a6",
"access": [
{"schemaKey": "AccessRequirements", "status": "dandi:OpenAccess"}
],
"path": "dataset_description.json",
"identifier": "34e30fa6-cf6a-4a32-90cb-b06f6f2f30a6",
"contentUrl": [
"https://api.dandiarchive.org/api/assets/shortened",
],
"contentSize": 3377,
"digest": {
"dandi:dandi-etag": "88c82d75b1119393b9ee49adc14714f3-1",
},
},
]
summary = aggregate_assets_summary(data)
assert summary["numberOfFiles"] == 3
assert summary["numberOfSamples"] == 2
assert summary["numberOfSubjects"] == 1
assert any("BIDS" in _.get("name", "") for _ in summary["dataStandard"])

0 comments on commit 202b063

Please sign in to comment.