Skip to content

Commit

Permalink
Function for converting NWB file to AssetMeta instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Aug 27, 2020
1 parent fe1f46f commit 7e0e67e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dandi/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,16 @@ def get_metadata(path):
meta["nd_types"] = get_neurodata_types(path)

return meta


def nwb2asset(nwb_path):
from .models import AssetMeta

metadata = get_metadata(nwb_path)
asset = AssetMeta.unvalidated()
for field in asset.__fields__.keys():
try:
setattr(asset, field, metadata[field])
except KeyError:
pass
return asset

0 comments on commit 7e0e67e

Please sign in to comment.