Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RF: detect BIDS based on having dataset_description.json #263

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def add_if_missing(standard: dict) -> None:
if "nwb" in assetmeta["encodingFormat"]:
add_if_missing(models.nwb_standard)
# TODO: RF assumption that any .json implies BIDS
if set(Path(assetmeta["path"]).suffixes).intersection((".json", ".nii")):
if Path(assetmeta["path"]).name == "dataset_description.json":
add_if_missing(models.bids_standard)
if Path(assetmeta["path"]).suffixes == [".ome", ".zarr"]:
add_if_missing(models.ome_ngff_standard)
Expand Down
67 changes: 25 additions & 42 deletions dandischema/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ def test_aggregation_bids() -> None:
{"status": "dandi:OpenAccess", "schemaKey": "AccessRequirements"}
],
"digest": {
"dandi:sha2-256": "a91db138c2842c9d3f5bbe30497065c6293dcab0b77"
"f774a917ab09fb1fd8eef",
"dandi:dandi-etag": "7e002a08bef16abb5954d1c2a3fce0a2-574",
},
"@context": "https://raw.githubusercontent.com/dandi/schema/master/"
Expand All @@ -557,32 +555,13 @@ def test_aggregation_bids() -> None:
"contentUrl": [
"https://api.dandiarchive.org/api/assets/6668d37f-e842-4b73-8c20"
"-082a1dd0d31a/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/ace/16c/ace16cf2"
"-3eaf-4d64-9e3b-5c6a981cb8ec",
],
"identifier": "6668d37f-e842-4b73-8c20-082a1dd0d31a",
"repository": "https://dandiarchive.org/",
"contentSize": 38474544973,
"dateModified": "2021-07-22T23:59:16.060551-04:00",
"schemaVersion": "0.4.4",
"encodingFormat": "application/x-zarr",
"wasGeneratedBy": [
{
"id": "urn:uuid:aef77d59-7a7f-4320-9d4b-9b03f3e25e54",
"name": "Metadata generation",
"schemaKey": "Activity",
"description": "Metadata generated by DANDI cli",
"wasAssociatedWith": [
{
"url": "https://github.com/dandi/dandi-cli",
"name": "DANDI Command Line Interface",
"version": "0.23.2",
"schemaKey": "Software",
"identifier": "RRID:SCR_019009",
}
],
}
],
"blobDateModified": "2021-07-11T16:34:31-04:00",
},
{
Expand All @@ -593,8 +572,6 @@ def test_aggregation_bids() -> None:
{"status": "dandi:OpenAccess", "schemaKey": "AccessRequirements"}
],
"digest": {
"dandi:sha2-256": "3d89ba29211c55c5a299f24ab64ac7d93750c8f7614"
"b360bf9a58266031b3752",
"dandi:dandi-etag": "954aab90c420c621cc70d17e74a65116-921",
},
"@context": "https://raw.githubusercontent.com/dandi/schema/master/"
Expand All @@ -603,37 +580,43 @@ def test_aggregation_bids() -> None:
"contentUrl": [
"https://api.dandiarchive.org/api/assets/84dd580f-8d4a-43f8-bda3"
"-6fb53fb5d3a2/download/",
"https://dandiarchive.s3.amazonaws.com/blobs/3e4/c7f/3e4c7f03"
"-4280-426d-9cba-3b53d616a44c",
],
"identifier": "84dd580f-8d4a-43f8-bda3-6fb53fb5d3a2",
"repository": "https://dandiarchive.org/",
"contentSize": 61774316916,
"dateModified": "2021-10-01T18:28:16.038990-04:00",
"schemaVersion": "0.6.0",
"encodingFormat": "application/x-zarr",
"wasGeneratedBy": [
{
"id": "urn:uuid:8f69a248-0e6a-4fa1-8369-ae1cc63d59d8",
"name": "Metadata generation",
"schemaKey": "Activity",
"description": "Metadata generated by DANDI cli",
"wasAssociatedWith": [
{
"url": "https://github.com/dandi/dandi-cli",
"name": "DANDI Command Line Interface",
"version": "0.27.3",
"schemaKey": "Software",
"identifier": "RRID:SCR_019009",
}
],
}
],
"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 sum("BIDS" in _.get("name", "") for _ in summary["dataStandard"]) == 1
assert (
sum(_.get("name", "").startswith("OME/NGFF") for _ in summary["dataStandard"])
== 1
Expand Down