Skip to content

Commit

Permalink
Add support for detection and addition of ome/ngff "standard" into as…
Browse files Browse the repository at this point in the history
…sets summary
  • Loading branch information
yarikoptic committed Aug 30, 2024
1 parent 6fc16b8 commit b4d3e4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,18 @@ def _add_asset_to_stats(assetmeta: Dict[str, Any], stats: _stats_type) -> None:
stats["tissuesample"].append(sample)

stats["dataStandard"] = stats.get("dataStandard", [])

def maybe_add_standard(standard: str) -> None:
if standard not in stats["dataStandard"]:
stats["dataStandard"].append(standard)

if "nwb" in assetmeta["encodingFormat"]:
if models.nwb_standard not in stats["dataStandard"]:
stats["dataStandard"].append(models.nwb_standard)
maybe_add_standard(models.nwb_standard)
# TODO: RF assumption that any .json implies BIDS
if set(Path(assetmeta["path"]).suffixes).intersection((".json", ".nii")):
if models.bids_standard not in stats["dataStandard"]:
stats["dataStandard"].append(models.bids_standard)
maybe_add_standard(models.bids_standard)

Check warning on line 390 in dandischema/metadata.py

View check run for this annotation

Codecov / codecov/patch

dandischema/metadata.py#L390

Added line #L390 was not covered by tests
if Path(assetmeta["path"]).suffixes == [".ome", ".zarr"]:
maybe_add_standard(models.ome_ngff_standard)

Check warning on line 392 in dandischema/metadata.py

View check run for this annotation

Codecov / codecov/patch

dandischema/metadata.py#L392

Added line #L392 was not covered by tests


# TODO?: move/bind such helpers as .from_metadata or alike within
Expand Down
6 changes: 6 additions & 0 deletions dandischema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ class StandardsType(BaseType):
identifier="RRID:SCR_016124",
).model_dump(mode="json", exclude_none=True)

ome_ngff_standard = StandardsType(
name="OME/NGFF Standard",
# Seems no dedicated RRID, only for OME itself?
# identifier="RRID:SCR_???",
).model_dump(mode="json", exclude_none=True)


class ContactPoint(DandiBaseModel):
email: Optional[EmailStr] = Field(
Expand Down

0 comments on commit b4d3e4e

Please sign in to comment.