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

Uniqueness of object_ids in generated analysis nwb files #953

Open
samuelbray32 opened this issue May 3, 2024 · 3 comments
Open

Uniqueness of object_ids in generated analysis nwb files #953

samuelbray32 opened this issue May 3, 2024 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@samuelbray32
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Describe the solution you'd like
A retroactive solution needs to:

  • alter the object_ids of existing files
  • correct the stored datajoint checksum/hash
  • correct any spyglass utilities that use this to find data

A forward solution needs to:

  • ensure unique object ids are created when creating a new analysis file

Describe alternatives you've considered
Would need dandi to change restriction policy on overlapping uuid. Since the same uuid do redundantly refer to duplicated data in different nwb files this might not be unreasonable.

@samuelbray32 samuelbray32 added bug Something isn't working enhancement New feature or request labels May 3, 2024
@samuelbray32
Copy link
Collaborator Author

@rly do you have any thoughts on altering uuids in existing nwb files?

@samuelbray32
Copy link
Collaborator Author

Good news: Dandi naming tools only require that the top level filename be unique. This can be achieved by editing the h5 file

@rly
Copy link
Collaborator

rly commented May 6, 2024

@samuelbray32 re: forward solution. Are new analysis NWB files created via the export function? You can generate new object IDs for each object in the nwbfile by calling nwbfile.generate_new_id() before export.

Ref: https://hdmf.readthedocs.io/en/stable/export.html#what-happens-to-object-ids-when-i-export

For older files, yes, you would need to edit the existing NWB file via h5py and do the following steps as you mentioned. For editing, you could do something like:

import h5py
from uuid import uuid4

path = "..."
def replace_object_id(name, obj):
    if isinstance(obj, (h5py.Group, h5py.Dataset)):
         if "object_id" in obj.attrs.keys():
             obj.attrs["object_id"] = str(uuid4())

with h5py.File(path, "r+") as f:
    f.attrs["object_id"] = str(uuid4())
    f.visititems(replace_object_id)

@samuelbray32 samuelbray32 self-assigned this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants