-
Notifications
You must be signed in to change notification settings - Fork 16
Create dictionaries for NWB export #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
139fde8
expanding lab tables \for other NWB fields
CBroz1 9c56224
Expand Lab for NWB export
CBroz1 112005e
Keyword, no default
CBroz1 b9804c3
Pub, no default
CBroz1 5987d93
revise assembly of info for nwb export
CBroz1 b600a4a
fix pop empty nwb entries
CBroz1 340458a
edit docker users for buildtest
CBroz1 1d41a74
Add docstrings
CBroz1 a3c0b75
quickfix: dependency import
CBroz1 63bd5f5
pynwb version issues w/h5py resolved recently
CBroz1 ea71fd5
Update author dj neuro -> dj
CBroz1 733d303
Update element_lab/__init__.py
CBroz1 ea67c24
Remove outdated `make_nwb` function
CBroz1 5c4ac32
PEP8 full word funcs. rm equip table
CBroz1 e16b95b
Deleting tempy.py notes file
CBroz1 e21b6c6
Sourcecode as master/part table 1
CBroz1 5c3a076
Sourcecode as master/part table 2
CBroz1 ab18244
Remove notes from nwb.py
CBroz1 4581206
Update element_lab/export/nwb.py
CBroz1 00cf2a2
Update element_lab/export/nwb.py
CBroz1 be59780
Update element_lab/export/nwb.py
CBroz1 c6591ed
Update element_lab/export/nwb.py
CBroz1 405f491
Update element_lab/export/nwb.py
CBroz1 8f3e8fb
Update element_lab/export/nwb.py
CBroz1 263448e
Update element_lab/export/nwb.py
CBroz1 955cef4
Remove lab.Project slices, virus, etc.; PEP8 linting
CBroz1 506c191
Apply Dimitri's suggestions, additional edit forthcoming
CBroz1 465084d
refactor nwb.py: only execute funcs if relevant input
CBroz1 a762b26
Apply Dimitri's suggestions, additional edit forthcoming
CBroz1 fc47e6c
Bump version, changelog notes. Add time_zone to export.
CBroz1 0d393cd
pass Nones intead of empty strings. These do not populate the NWBFile
bendichter 33288d5
Pin pynwb to 1.4.0
CBroz1 8c0373c
Merge from bendichter: pass Nones instead of empty strings
CBroz1 debe13b
@Kabilar's code review: PEP8
CBroz1 2c2240f
dj.part->dj.manual: keyw, pubs, sourcecode
CBroz1 6ddd420
Update version history URL list
CBroz1 fe227e1
Prefix former part tables: add Project in name
CBroz1 2dccbdc
Apply suggestions from @kabilar's code review
CBroz1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +0,0 @@ | ||
| __author__ = "DataJoint NEURO" | ||
| __date__ = "December 15, 2020" | ||
| __version__ = "0.0.1" | ||
| __all__ = ['__author__', '__version__', '__date__'] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from .nwb import elementlab_nwb_dict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| from element_lab import lab | ||
|
|
||
|
|
||
| def lab_to_nwb_dict(lab_key): | ||
| """ | ||
| Generate a dictionary containing all relevant lab and institution info | ||
| :param lab_key: Key specifying one entry in element_lab.lab.Lab | ||
| :return: dictionary with NWB parameters | ||
| """ | ||
| lab_info = (lab.Lab & lab_key).fetch1() | ||
| return dict( | ||
| institution=lab_info.get('institution'), | ||
| lab=lab_info.get('lab_name'), | ||
| ) | ||
|
|
||
|
|
||
| def project_to_nwb_dict(project_key): | ||
| """ | ||
| Generate a dictionary object containing relevant project information | ||
| (e.g., experimental description, related publications, etc.). | ||
| :param project_key: Key specifying one entry in element_lab.lab.Project | ||
| :return: dictionary with NWB parameters | ||
| """ | ||
| project_info = (lab.Project & project_key).fetch1() | ||
| return dict( | ||
| experiment_description=project_info.get('project_description'), | ||
| keywords=(lab.ProjectKeywords() & project_key | ||
| ).fetch('keyword').tolist() or None, | ||
| related_publications=(lab.ProjectPublication() & project_key | ||
| ).fetch('publication').tolist() or None | ||
| ) | ||
|
|
||
|
|
||
| def protocol_to_nwb_dict(protocol_key): | ||
| """ | ||
| Generate a dictionary object containing all protocol title and notes. | ||
| :param protocol_key: Key specifying one entry in element_lab.lab.Protocol | ||
| :return: dictionary with NWB parameters | ||
| """ | ||
| protocol_info = (lab.Protocol & protocol_key).fetch1() | ||
| return dict( | ||
| protocol=protocol_info.get('protocol'), | ||
| notes=protocol_info.get('protocol_description') | ||
| ) | ||
|
|
||
|
|
||
| def element_lab_to_nwb_dict(lab_key=None, project_key=None, protocol_key=None): | ||
| """ | ||
| Generate a dictionary object containing all relevant lab information used | ||
| when generating an NWB file at the session level. | ||
| All parameters optional, but should only specify one of respective type | ||
| Use: mynwbfile = pynwb.NWBFile(identifier="your identifier", | ||
| session_description="your description", | ||
| session_start_time=session_datetime, | ||
| **element_lab_to_nwb_dict( | ||
| lab_key=key1, | ||
| project_key=key2, | ||
| protocol_key=key3)) | ||
|
|
||
| :param lab_key: Key specifying one entry in element_lab.lab.Lab | ||
| :param project_key: Key specifying one entry in element_lab.lab.Project | ||
| :param protocol_key: Key specifying one entry in element_lab.lab.Protocol | ||
| :return: dictionary with NWB parameters | ||
| """ | ||
| # Validate input | ||
| assert any([lab_key, project_key, protocol_key]), 'Must specify one key.' | ||
| assert lab_key is None or len(lab.Lab & lab_key) == 1, \ | ||
| 'Multiple labs error! The lab_key should specify only one lab.' | ||
| assert project_key is None or len(lab.Project & project_key) == 1, \ | ||
| 'Multiple projects error! The project_key should specify only one '\ | ||
| 'project.' | ||
| assert protocol_key is None or len(lab.Protocol & protocol_key) == 1, \ | ||
| 'Multiple protocols error! The protocol_key should specify only one '\ | ||
| 'protocol.' | ||
|
|
||
| element_info = dict() | ||
| if lab_key: | ||
| element_info.update(lab_to_nwb_dict(lab_key)) | ||
| if project_key: | ||
| element_info.update(project_to_nwb_dict(project_key)) | ||
| if protocol_key: | ||
| element_info.update(protocol_to_nwb_dict(protocol_key)) | ||
|
|
||
| return element_info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| """Package metadata.""" | ||
| __version__ = '0.1.0b0' | ||
| __version__ = '0.1.0b1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| datajoint>=0.13.0 | ||
| pynwb==1.4.0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.