From 139fde880926e3dd2226faf98bfc4ba53b76b1b9 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Mon, 22 Nov 2021 12:36:19 -0600 Subject: [PATCH 01/37] expanding lab tables \for other NWB fields --- element_lab/export/__init__.py | 1 + element_lab/export/nwb.py | 31 ++++++++++++++++++++++++++++++ element_lab/lab.py | 35 +++++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 element_lab/export/__init__.py create mode 100644 element_lab/export/nwb.py diff --git a/element_lab/export/__init__.py b/element_lab/export/__init__.py new file mode 100644 index 0000000..4fbe0ec --- /dev/null +++ b/element_lab/export/__init__.py @@ -0,0 +1 @@ +from .nwb import lab_to_nwb \ No newline at end of file diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py new file mode 100644 index 0000000..7d5a519 --- /dev/null +++ b/element_lab/export/nwb.py @@ -0,0 +1,31 @@ +import numpy as np +from datetime import datetime +from dateutil.tz import tzlocal +from pynwb import NWBFile + +from element_lab import lab + +def lab_to_nwb(lab_key): + lab_query = lab.Lab & lab_key + lab_query = lab_query.join(lab.Lab.Protocol, left=True) + lab_query = lab_query.join(lab.Lab.Project, left=True) + lab_info = lab.query.fetch1() + + return NWBFile( + data_collection='', + experiment_description=lab_info.pop('project_description'), + institution=lab_info.pop('institution'), + keywords=list(lab.Project.keywords.fetch()), + lab=lab_info.pop('lab_name'), + notes=lab_info.pop('protocol_description'), + pharmacology=lab_info.pop('pharmacology'), + protocol=lab_info.pop('protocol'), + related_publications=list(lab.Project.publication.fetch()), + session_id='', # why is NWB asking for this at this level? + slices=lab_info.pop('slices'), + souce_script=lab_info.pop('repositoryurl'), + file_name=lab_info.pop('repositoryname'), + stimulus=lab_info.pop('stimulus'), + surgery=lab_info.pop('surgery'), + virus=lab_info.pop('virus') + ) diff --git a/element_lab/lab.py b/element_lab/lab.py index c71bf12..ebdcc2b 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -16,7 +16,7 @@ def activate(schema_name, create_schema=True, create_tables=True): @schema class Lab(dj.Lookup): definition = """ - lab : varchar(24) # Abbreviated lab name + lab : varchar(24) # Abbreviated lab name --- lab_name : varchar(255) # full lab name institution : varchar(255) @@ -77,7 +77,7 @@ class Protocol(dj.Lookup): protocol : varchar(16) --- -> ProtocolType - protocol_description='' : varchar(255) + protocol_description='' : varchar(255) """ @@ -86,9 +86,38 @@ class Project(dj.Lookup): definition = """ project : varchar(32) --- - project_description='' : varchar(1024) + project_description='' : varchar(1024) + # Below included for archival export (e.g., NWB) + repositoryurl='' : varchar(256) # URL to code for replication + repositoryname='' : varchar(32) # name of repository + pharmacology = '' : varchar(2048) # Drugs used, how/when administered + viruses='' : varchar(2048) # ID, source, date made, injection loc, volume + slices='' : varchar(2048) # If slicing, preparation thickness, orientation, temperature, and bath solution + stimulus='' : varchar(2048) # Generation method, how/when/where presented + surgery=:'' : varchar(2048) # Description of surger(y/ies), who performed, when relative to other events """ + class Keywords(dj.Part): + definition = """ + # Project keywords, exported dataset meta info + -> master + keyword='' : varchar(32) + """ + + class Publication(dj.Part): + definition = """ + # Project's resulting publications + -> master + publication='' : varchar(256) + """ + + class Sourcecode(dj.Part): + definition = """ + # URL to source code for replication + # included as source_script in NWB export + -> master + """ + @schema class ProjectUser(dj.Manual): From 9c562243aac7f5e57717059dd8b205afc50a595c Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Mon, 29 Nov 2021 14:24:35 -0600 Subject: [PATCH 02/37] Expand Lab for NWB export --- element_lab/export/nwb.py | 6 +++--- element_lab/lab.py | 5 +++++ requirements.txt | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 7d5a519..f45b169 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -6,12 +6,12 @@ from element_lab import lab def lab_to_nwb(lab_key): - lab_query = lab.Lab & lab_key + lab_query = lab.Lab & lab_key lab_query = lab_query.join(lab.Lab.Protocol, left=True) lab_query = lab_query.join(lab.Lab.Project, left=True) - lab_info = lab.query.fetch1() + lab_info = lab.query.fetch1() - return NWBFile( + return NWBFile( data_collection='', experiment_description=lab_info.pop('project_description'), institution=lab_info.pop('institution'), diff --git a/element_lab/lab.py b/element_lab/lab.py index ebdcc2b..c392686 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -84,6 +84,7 @@ class Protocol(dj.Lookup): @schema class Project(dj.Lookup): definition = """ + -> Lab project : varchar(32) --- project_description='' : varchar(1024) @@ -118,6 +119,10 @@ class Sourcecode(dj.Part): -> master """ + def make_nwb(cls, lab_key): + from .export import lab_to_nwb + return lab_to_nwb(lab_key) + @schema class ProjectUser(dj.Manual): diff --git a/requirements.txt b/requirements.txt index fc7a8e6..ca4b36b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ datajoint>=0.13.0 +pynwb==1.4.0 \ No newline at end of file From 112005ef1e4bbca4e78b73edc8fd4fa2f0bb5aa9 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 30 Nov 2021 10:54:11 -0600 Subject: [PATCH 03/37] Keyword, no default Co-authored-by: Thinh Nguyen --- element_lab/lab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element_lab/lab.py b/element_lab/lab.py index c392686..98fbc23 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -102,7 +102,7 @@ class Keywords(dj.Part): definition = """ # Project keywords, exported dataset meta info -> master - keyword='' : varchar(32) + keyword: varchar(32) """ class Publication(dj.Part): From b9804c367881bb7f700206b60210129b083f61d7 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 30 Nov 2021 10:56:45 -0600 Subject: [PATCH 04/37] Pub, no default Co-authored-by: Thinh Nguyen --- element_lab/lab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element_lab/lab.py b/element_lab/lab.py index 98fbc23..fb33167 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -109,7 +109,7 @@ class Publication(dj.Part): definition = """ # Project's resulting publications -> master - publication='' : varchar(256) + publication: varchar(256) """ class Sourcecode(dj.Part): From 5987d934be880e9fb36569cff823e9f0db45a081 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Wed, 1 Dec 2021 15:26:06 -0600 Subject: [PATCH 05/37] revise assembly of info for nwb export --- element_lab/__init__.py | 4 +- element_lab/export/__init__.py | 2 +- element_lab/export/nwb.py | 93 ++++++++++++++++++++++++---------- element_lab/lab.py | 14 +++-- 4 files changed, 78 insertions(+), 35 deletions(-) diff --git a/element_lab/__init__.py b/element_lab/__init__.py index 6334b3e..19048a1 100644 --- a/element_lab/__init__.py +++ b/element_lab/__init__.py @@ -1,4 +1,4 @@ __author__ = "DataJoint NEURO" -__date__ = "December 15, 2020" -__version__ = "0.0.1" +__date__ = "December, 2021" +__version__ = "0.1.0b0" __all__ = ['__author__', '__version__', '__date__'] \ No newline at end of file diff --git a/element_lab/export/__init__.py b/element_lab/export/__init__.py index 4fbe0ec..4d89787 100644 --- a/element_lab/export/__init__.py +++ b/element_lab/export/__init__.py @@ -1 +1 @@ -from .nwb import lab_to_nwb \ No newline at end of file +from .nwb import * \ No newline at end of file diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index f45b169..9942773 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,31 +1,68 @@ -import numpy as np from datetime import datetime -from dateutil.tz import tzlocal -from pynwb import NWBFile - from element_lab import lab -def lab_to_nwb(lab_key): - lab_query = lab.Lab & lab_key - lab_query = lab_query.join(lab.Lab.Protocol, left=True) - lab_query = lab_query.join(lab.Lab.Project, left=True) - lab_info = lab.query.fetch1() - - return NWBFile( - data_collection='', - experiment_description=lab_info.pop('project_description'), - institution=lab_info.pop('institution'), - keywords=list(lab.Project.keywords.fetch()), - lab=lab_info.pop('lab_name'), - notes=lab_info.pop('protocol_description'), - pharmacology=lab_info.pop('pharmacology'), - protocol=lab_info.pop('protocol'), - related_publications=list(lab.Project.publication.fetch()), - session_id='', # why is NWB asking for this at this level? - slices=lab_info.pop('slices'), - souce_script=lab_info.pop('repositoryurl'), - file_name=lab_info.pop('repositoryname'), - stimulus=lab_info.pop('stimulus'), - surgery=lab_info.pop('surgery'), - virus=lab_info.pop('virus') - ) +''' +Broz 120121: packages lab, project and protocol data as dicts + Updated session nwb export function then reads items + if they exist, populates. If not, blank - not best practice. + How to populate only NWB items for which we have user entries? +''' + +def lab_to_nwb_dict(lab_key=None): + if lab_key is not None: + lab_info = (lab.Lab & lab_key).fetch1() + return dict( + institution=(lab_info['institution'] + if 'institution' in lab_info else ''), + lab=(lab_info['lab_name'] + if 'lab_name' in lab_info else '') + ) + else: return {} + + +def proj_to_nwb_dict(project_key=None): + if project_key is not None: + proj_info = (lab.Project & project_key).fetch1() + proj_keyw = (lab.Project.Keywords() & project_key).fetch('keyword').tolist() + proj_pubs = (lab.Project.Publication() & project_key).fetch('publication').tolist() + return dict( + experiment_description=(proj_info['project_description'] + if 'project_description' in proj_info else ''), + keywords=proj_keyw, + pharmacology=(proj_info['pharmacology'] + if 'pharmacology' in proj_info else ''), + related_publications=proj_pubs, + slices=(proj_info['slices'] + if 'slices' in proj_info else ''), + source_script=(proj_info['repositoryurl'] + if 'repositoryurl' in proj_info else ''), + stimulus=(list(proj_info['stimulus']) + if 'stimulus' in proj_info else []), + surgery=(proj_info['surgery'] + if 'surgery' in proj_info else ''), + virus=(proj_info['virus'] + if 'virus' in proj_info else '') + ) + else: return {} + + +def prot_to_nwb_dict(protocol_key=None): + if protocol_key is not None: + prot_info = (lab.Protocol & protocol_key).fetch1() + return dict( + # data_collection='', + protocol=(prot_info['protocol'] + if 'protocol' in prot_info else ''), + notes=(prot_info['protocol_description'] + if 'project_description' in prot_info else '') + ) + else: return {} + +def elemlab_to_nwb_dict(lab_key=None,project_key=None,protocol_key=None): + return dict( + lab_to_nwb_dict(lab_key), + **proj_to_nwb_dict(project_key), + **prot_to_nwb_dict(protocol_key) + ) + + diff --git a/element_lab/lab.py b/element_lab/lab.py index fb33167..c5e7987 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -24,6 +24,10 @@ class Lab(dj.Lookup): time_zone : varchar(64) """ + def make_nwb(cls, lab_key): + from .export import lab_to_nwb + return lab_to_nwb(lab_key) + @schema class Location(dj.Lookup): @@ -80,6 +84,9 @@ class Protocol(dj.Lookup): protocol_description='' : varchar(255) """ + def make_nwb(cls, lab_key): + from .export import lab_to_nwb + return lab_to_nwb(lab_key) @schema class Project(dj.Lookup): @@ -95,7 +102,7 @@ class Project(dj.Lookup): viruses='' : varchar(2048) # ID, source, date made, injection loc, volume slices='' : varchar(2048) # If slicing, preparation thickness, orientation, temperature, and bath solution stimulus='' : varchar(2048) # Generation method, how/when/where presented - surgery=:'' : varchar(2048) # Description of surger(y/ies), who performed, when relative to other events + surgery='' : varchar(2048) # Description of surger(y/ies), who performed, when relative to other events """ class Keywords(dj.Part): @@ -117,11 +124,10 @@ class Sourcecode(dj.Part): # URL to source code for replication # included as source_script in NWB export -> master + codeurl: varchar(256) """ - def make_nwb(cls, lab_key): - from .export import lab_to_nwb - return lab_to_nwb(lab_key) + @schema From b600a4a76f11f1dff6259bedb346d945606d06da Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Wed, 1 Dec 2021 17:45:32 -0600 Subject: [PATCH 06/37] fix pop empty nwb entries --- element_lab/export/nwb.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 9942773..40c2995 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,13 +1,6 @@ from datetime import datetime from element_lab import lab -''' -Broz 120121: packages lab, project and protocol data as dicts - Updated session nwb export function then reads items - if they exist, populates. If not, blank - not best practice. - How to populate only NWB items for which we have user entries? -''' - def lab_to_nwb_dict(lab_key=None): if lab_key is not None: lab_info = (lab.Lab & lab_key).fetch1() @@ -36,12 +29,16 @@ def proj_to_nwb_dict(project_key=None): if 'slices' in proj_info else ''), source_script=(proj_info['repositoryurl'] if 'repositoryurl' in proj_info else ''), - stimulus=(list(proj_info['stimulus']) - if 'stimulus' in proj_info else []), surgery=(proj_info['surgery'] if 'surgery' in proj_info else ''), virus=(proj_info['virus'] if 'virus' in proj_info else '') + + ## AttributeError: 'str' object has no attribute 'parent' + ## Broz: I thought these were notes about the stimulus? + ## Error indicates trying to process stim file itself? + # stimulus=(list(proj_info['stimulus']) + # if 'stimulus' in proj_info else []) ) else: return {} @@ -59,10 +56,14 @@ def prot_to_nwb_dict(protocol_key=None): else: return {} def elemlab_to_nwb_dict(lab_key=None,project_key=None,protocol_key=None): - return dict( + elem_info=dict( lab_to_nwb_dict(lab_key), **proj_to_nwb_dict(project_key), **prot_to_nwb_dict(protocol_key) ) + for k in list(elem_info): # Drop blank entries + if len(elem_info[k]) == 0: elem_info.pop(k) + return elem_info + From 340458a8fdb32235c3221a50187ed8f4d0587844 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Thu, 2 Dec 2021 10:28:30 -0600 Subject: [PATCH 07/37] edit docker users for buildtest --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4fbcfc9..c144a40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,9 @@ ARG PKG_NAME ARG PKG_VERSION FROM datajoint/${IMAGE}:py${PY_VER}-${DISTRO} -COPY --chown=dja:anaconda ./requirements.txt ./setup.py \ +COPY --chown=anaconda:anaconda ./requirements.txt ./setup.py \ /main/ -COPY --chown=dja:anaconda ./${PKG_NAME} /main/${PKG_NAME} +COPY --chown=anaconda:anaconda ./${PKG_NAME} /main/${PKG_NAME} RUN \ cd /main && \ pip install . && \ From 1d41a74fd53c866b708815ead4b9e21e9a81c948 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Mon, 6 Dec 2021 15:14:46 -0600 Subject: [PATCH 08/37] Add docstrings --- element_lab/export/nwb.py | 41 ++++++++++++++++++++++++++++++++++++++- element_lab/lab.py | 30 +++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 40c2995..5bc4e93 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,7 +1,11 @@ from datetime import datetime -from element_lab import lab def lab_to_nwb_dict(lab_key=None): + """ + Generate a dictionary object containing all relevant lab and institution information. + :param lab_key: Key specifying one entry in element_lab.lab.Lab + :return: dictionary with NWB parameters + """ if lab_key is not None: lab_info = (lab.Lab & lab_key).fetch1() return dict( @@ -14,6 +18,12 @@ def lab_to_nwb_dict(lab_key=None): def proj_to_nwb_dict(project_key=None): + """ + 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 + """ if project_key is not None: proj_info = (lab.Project & project_key).fetch1() proj_keyw = (lab.Project.Keywords() & project_key).fetch('keyword').tolist() @@ -44,6 +54,11 @@ def proj_to_nwb_dict(project_key=None): def prot_to_nwb_dict(protocol_key=None): + """ + 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 + """ if protocol_key is not None: prot_info = (lab.Protocol & protocol_key).fetch1() return dict( @@ -56,13 +71,37 @@ def prot_to_nwb_dict(protocol_key=None): else: return {} def elemlab_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. + Use: mynwbfile = NWBfile(identifier="your identifier", + session_description="your description", + session_start_time=session_datetime, + elemlab_to_nwb_dict(lab_key=key1,project_key=key2,protocol_key=key3)) + Note: The lab, project and protocol keys should specify one of their respective types. + + :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 + if lab_key is not None: assert len(lab.Lab & lab_key) == 1, \ + f'Multiple labs error! The lab_key should specify only one lab.' + if project_key is not None: assert len(lab.Project & project_key) == 1, \ + f'Multiple projects error! The project_key should specify only one project.' + if protocol_key is not None: assert len(lab.Protocol & protocol_key) == 1, \ + f'Multiple protocols error! The protocol_key should specify only one protocol.' + elem_info=dict( lab_to_nwb_dict(lab_key), **proj_to_nwb_dict(project_key), **prot_to_nwb_dict(protocol_key) ) + for k in list(elem_info): # Drop blank entries if len(elem_info[k]) == 0: elem_info.pop(k) + return elem_info diff --git a/element_lab/lab.py b/element_lab/lab.py index c5e7987..c049f3e 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -84,14 +84,9 @@ class Protocol(dj.Lookup): protocol_description='' : varchar(255) """ - def make_nwb(cls, lab_key): - from .export import lab_to_nwb - return lab_to_nwb(lab_key) - @schema class Project(dj.Lookup): definition = """ - -> Lab project : varchar(32) --- project_description='' : varchar(1024) @@ -148,3 +143,28 @@ class Source(dj.Lookup): contact_details='' : varchar(255) source_description='' : varchar(255) """ + +@schema +class Equipment(dj.Manual): + definition = """ + # Equipment information + equipment_id: varchar(16) + --- + manufacturer: varchar(32) + description: varchar(255) + """ + + class EphysEquipment(dj.Part): + definition = """ + ->master # Needs more here + """ + + class CaImgEquipment(dj.Part): + definition = """ + ->master # Needs more here + caimg_equip_type: varchar(32) + --- + caimg_equip_descrip: varchar(255) + excitation_lambda: float + emission_lambda: float + """ \ No newline at end of file From a3c0b75bd4443530d461dd6ed1eacff3fa9755c6 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Mon, 6 Dec 2021 17:06:10 -0600 Subject: [PATCH 09/37] quickfix: dependency import --- element_lab/export/nwb.py | 1 + 1 file changed, 1 insertion(+) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 5bc4e93..fcc1116 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,4 +1,5 @@ from datetime import datetime +from element_lab import lab def lab_to_nwb_dict(lab_key=None): """ From 63bd5f55738da080441e3747a40e247f84a1a34c Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Fri, 17 Dec 2021 09:17:29 -0600 Subject: [PATCH 10/37] pynwb version issues w/h5py resolved recently previously, installation would take a while resolving dependency conflicts --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ca4b36b..0de5e98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ datajoint>=0.13.0 -pynwb==1.4.0 \ No newline at end of file +pynwb From ea71fd59ba60d7f4a38050a7fe0c72bea9004df2 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 21 Dec 2021 09:14:22 -0600 Subject: [PATCH 11/37] Update author dj neuro -> dj Co-authored-by: Kabilar Gunalan --- element_lab/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element_lab/__init__.py b/element_lab/__init__.py index 19048a1..3b19b8d 100644 --- a/element_lab/__init__.py +++ b/element_lab/__init__.py @@ -1,4 +1,4 @@ -__author__ = "DataJoint NEURO" +__author__ = "DataJoint" __date__ = "December, 2021" __version__ = "0.1.0b0" __all__ = ['__author__', '__version__', '__date__'] \ No newline at end of file From 733d303310db71a66ba108f10611c07cea17c137 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Thu, 23 Dec 2021 16:25:19 -0600 Subject: [PATCH 12/37] Update element_lab/__init__.py Co-authored-by: Kabilar Gunalan --- element_lab/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element_lab/__init__.py b/element_lab/__init__.py index 3b19b8d..844e3aa 100644 --- a/element_lab/__init__.py +++ b/element_lab/__init__.py @@ -1,4 +1,4 @@ __author__ = "DataJoint" __date__ = "December, 2021" -__version__ = "0.1.0b0" +__version__ = "0.1.0b1" __all__ = ['__author__', '__version__', '__date__'] \ No newline at end of file From ea67c24eec5bbc657a5367abe1e300ddb3e97599 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Thu, 23 Dec 2021 16:27:42 -0600 Subject: [PATCH 13/37] Remove outdated `make_nwb` function Good catch @kabilar! This was a holdover from my first pass. Now, `element-lab` only has functions for making dicts that feed into a users session-level nwb --- element_lab/lab.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/element_lab/lab.py b/element_lab/lab.py index c049f3e..8716f1d 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -24,11 +24,6 @@ class Lab(dj.Lookup): time_zone : varchar(64) """ - def make_nwb(cls, lab_key): - from .export import lab_to_nwb - return lab_to_nwb(lab_key) - - @schema class Location(dj.Lookup): definition = """ @@ -167,4 +162,4 @@ class CaImgEquipment(dj.Part): caimg_equip_descrip: varchar(255) excitation_lambda: float emission_lambda: float - """ \ No newline at end of file + """ From 5c4ac3296825c5a08c265e0a13dd489049c285b3 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Tue, 28 Dec 2021 16:41:27 -0600 Subject: [PATCH 14/37] PEP8 full word funcs. rm equip table --- element_lab/export/__init__.py | 2 +- element_lab/export/nwb.py | 12 ++++++------ element_lab/lab.py | 28 ---------------------------- temp.py | 2 ++ 4 files changed, 9 insertions(+), 35 deletions(-) create mode 100644 temp.py diff --git a/element_lab/export/__init__.py b/element_lab/export/__init__.py index 4d89787..a97b5ef 100644 --- a/element_lab/export/__init__.py +++ b/element_lab/export/__init__.py @@ -1 +1 @@ -from .nwb import * \ No newline at end of file +from .nwb import elementlab_nwb_dict \ No newline at end of file diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index fcc1116..511e4ec 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -18,7 +18,7 @@ def lab_to_nwb_dict(lab_key=None): else: return {} -def proj_to_nwb_dict(project_key=None): +def project_to_nwb_dict(project_key=None): """ Generate a dictionary object containing relevant project information (e.g., experimental description, related publications, etc.). @@ -54,7 +54,7 @@ def proj_to_nwb_dict(project_key=None): else: return {} -def prot_to_nwb_dict(protocol_key=None): +def protocol_to_nwb_dict(protocol_key=None): """ Generate a dictionary object containing all protocol title and notes. :param protocol_key: Key specifying one entry in element_lab.lab.Protocol @@ -71,14 +71,14 @@ def prot_to_nwb_dict(protocol_key=None): ) else: return {} -def elemlab_to_nwb_dict(lab_key=None,project_key=None,protocol_key=None): +def elementlab_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. Use: mynwbfile = NWBfile(identifier="your identifier", session_description="your description", session_start_time=session_datetime, - elemlab_to_nwb_dict(lab_key=key1,project_key=key2,protocol_key=key3)) + elementlab_nwb_dict(lab_key=key1,project_key=key2,protocol_key=key3)) Note: The lab, project and protocol keys should specify one of their respective types. :param lab_key: Key specifying one entry in element_lab.lab.Lab @@ -96,8 +96,8 @@ def elemlab_to_nwb_dict(lab_key=None,project_key=None,protocol_key=None): elem_info=dict( lab_to_nwb_dict(lab_key), - **proj_to_nwb_dict(project_key), - **prot_to_nwb_dict(protocol_key) + **project_to_nwb_dict(project_key), + **protocol_to_nwb_dict(protocol_key) ) for k in list(elem_info): # Drop blank entries diff --git a/element_lab/lab.py b/element_lab/lab.py index 8716f1d..9c947db 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -117,9 +117,6 @@ class Sourcecode(dj.Part): codeurl: varchar(256) """ - - - @schema class ProjectUser(dj.Manual): definition = """ @@ -138,28 +135,3 @@ class Source(dj.Lookup): contact_details='' : varchar(255) source_description='' : varchar(255) """ - -@schema -class Equipment(dj.Manual): - definition = """ - # Equipment information - equipment_id: varchar(16) - --- - manufacturer: varchar(32) - description: varchar(255) - """ - - class EphysEquipment(dj.Part): - definition = """ - ->master # Needs more here - """ - - class CaImgEquipment(dj.Part): - definition = """ - ->master # Needs more here - caimg_equip_type: varchar(32) - --- - caimg_equip_descrip: varchar(255) - excitation_lambda: float - emission_lambda: float - """ diff --git a/temp.py b/temp.py new file mode 100644 index 0000000..c5f9f5f --- /dev/null +++ b/temp.py @@ -0,0 +1,2 @@ +import datajoint as dj + From e16b95b2eea724bc2bc1fabb8da9a7686c07b7f5 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 28 Dec 2021 16:50:14 -0600 Subject: [PATCH 15/37] Deleting tempy.py notes file --- temp.py | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 temp.py diff --git a/temp.py b/temp.py deleted file mode 100644 index c5f9f5f..0000000 --- a/temp.py +++ /dev/null @@ -1,2 +0,0 @@ -import datajoint as dj - From e21b6c6355b9bf2d70465d754551dbabdb5e7143 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Mon, 10 Jan 2022 09:36:05 -0600 Subject: [PATCH 16/37] Sourcecode as master/part table 1 Co-authored-by: Kabilar Gunalan --- element_lab/lab.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/element_lab/lab.py b/element_lab/lab.py index 9c947db..d87a89e 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -86,8 +86,6 @@ class Project(dj.Lookup): --- project_description='' : varchar(1024) # Below included for archival export (e.g., NWB) - repositoryurl='' : varchar(256) # URL to code for replication - repositoryname='' : varchar(32) # name of repository pharmacology = '' : varchar(2048) # Drugs used, how/when administered viruses='' : varchar(2048) # ID, source, date made, injection loc, volume slices='' : varchar(2048) # If slicing, preparation thickness, orientation, temperature, and bath solution From 5c3a0762fee69caa4e953973647952554f858fab Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Mon, 10 Jan 2022 09:36:21 -0600 Subject: [PATCH 17/37] Sourcecode as master/part table 2 Co-authored-by: Kabilar Gunalan --- element_lab/lab.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/element_lab/lab.py b/element_lab/lab.py index d87a89e..7fe20cb 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -107,12 +107,12 @@ class Publication(dj.Part): publication: varchar(256) """ - class Sourcecode(dj.Part): + class SourceCode(dj.Part): definition = """ - # URL to source code for replication - # included as source_script in NWB export -> master - codeurl: varchar(256) + repository_url : varchar(256) # URL to source code for replication + --- + repository_name='' : varchar(32) """ @schema From ab18244c8ab2bcda90622540d200e69a78e06f14 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Mon, 10 Jan 2022 09:41:29 -0600 Subject: [PATCH 18/37] Remove notes from nwb.py --- element_lab/export/nwb.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 511e4ec..e499228 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -44,12 +44,6 @@ def project_to_nwb_dict(project_key=None): if 'surgery' in proj_info else ''), virus=(proj_info['virus'] if 'virus' in proj_info else '') - - ## AttributeError: 'str' object has no attribute 'parent' - ## Broz: I thought these were notes about the stimulus? - ## Error indicates trying to process stim file itself? - # stimulus=(list(proj_info['stimulus']) - # if 'stimulus' in proj_info else []) ) else: return {} From 45812067e6fb9b65bc59fc3f946ab16d1612ddb5 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:15:31 -0600 Subject: [PATCH 19/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index e499228..f80c815 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -30,8 +30,7 @@ def project_to_nwb_dict(project_key=None): proj_keyw = (lab.Project.Keywords() & project_key).fetch('keyword').tolist() proj_pubs = (lab.Project.Publication() & project_key).fetch('publication').tolist() return dict( - experiment_description=(proj_info['project_description'] - if 'project_description' in proj_info else ''), + experiment_description=(proj_info.get('project_description', ''), keywords=proj_keyw, pharmacology=(proj_info['pharmacology'] if 'pharmacology' in proj_info else ''), From 00cf2a22a9fe308148f91655b72166a211c701ad Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:15:53 -0600 Subject: [PATCH 20/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index f80c815..0acac59 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -32,8 +32,7 @@ def project_to_nwb_dict(project_key=None): return dict( experiment_description=(proj_info.get('project_description', ''), keywords=proj_keyw, - pharmacology=(proj_info['pharmacology'] - if 'pharmacology' in proj_info else ''), + pharmacology=proj_info.get('pharmacology', ''), related_publications=proj_pubs, slices=(proj_info['slices'] if 'slices' in proj_info else ''), From be5978055952ba44f55304afc353f90ee37938cf Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:16:01 -0600 Subject: [PATCH 21/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 0acac59..1c9b66e 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -34,8 +34,7 @@ def project_to_nwb_dict(project_key=None): keywords=proj_keyw, pharmacology=proj_info.get('pharmacology', ''), related_publications=proj_pubs, - slices=(proj_info['slices'] - if 'slices' in proj_info else ''), + slices=proj_info.get('slices', ''), source_script=(proj_info['repositoryurl'] if 'repositoryurl' in proj_info else ''), surgery=(proj_info['surgery'] From c6591ed522d7f7e959bc36dbeb9bcb1e67112a91 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:17:11 -0600 Subject: [PATCH 22/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 1c9b66e..3b69987 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -35,8 +35,7 @@ def project_to_nwb_dict(project_key=None): pharmacology=proj_info.get('pharmacology', ''), related_publications=proj_pubs, slices=proj_info.get('slices', ''), - source_script=(proj_info['repositoryurl'] - if 'repositoryurl' in proj_info else ''), + source_script=proj_info.get('repositoryurl', ''), surgery=(proj_info['surgery'] if 'surgery' in proj_info else ''), virus=(proj_info['virus'] From 405f4912027614a236f5a29582b94c03a358e8ed Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:17:31 -0600 Subject: [PATCH 23/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 3b69987..22b9ad4 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -77,8 +77,8 @@ def elementlab_nwb_dict(lab_key=None,project_key=None,protocol_key=None): :return: dictionary with NWB parameters """ ## Validate input - if lab_key is not None: assert len(lab.Lab & lab_key) == 1, \ - f'Multiple labs error! The lab_key should specify only one lab.' + if lab_key is not None: + assert len(lab.Lab & lab_key) == 1, 'Multiple labs error! The lab_key should specify only one lab.' if project_key is not None: assert len(lab.Project & project_key) == 1, \ f'Multiple projects error! The project_key should specify only one project.' if protocol_key is not None: assert len(lab.Protocol & protocol_key) == 1, \ From 8f3e8fb6d4ff69357dcc50b5adb2a1bc0c1dd4f4 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:17:46 -0600 Subject: [PATCH 24/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 22b9ad4..e88d0dd 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -36,8 +36,7 @@ def project_to_nwb_dict(project_key=None): related_publications=proj_pubs, slices=proj_info.get('slices', ''), source_script=proj_info.get('repositoryurl', ''), - surgery=(proj_info['surgery'] - if 'surgery' in proj_info else ''), + surgery=(proj_info.get('surgery', ''), virus=(proj_info['virus'] if 'virus' in proj_info else '') ) From 263448e13b670e08f55ab648387f9e5b52fe7644 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Tue, 11 Jan 2022 10:17:59 -0600 Subject: [PATCH 25/37] Update element_lab/export/nwb.py Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index e88d0dd..cce7a5e 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -37,8 +37,7 @@ def project_to_nwb_dict(project_key=None): slices=proj_info.get('slices', ''), source_script=proj_info.get('repositoryurl', ''), surgery=(proj_info.get('surgery', ''), - virus=(proj_info['virus'] - if 'virus' in proj_info else '') + virus=proj_info.get('virus', '') ) else: return {} From 955cef4d960bb10fccfb6b823b33817394c15b13 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Tue, 11 Jan 2022 12:11:52 -0600 Subject: [PATCH 26/37] Remove lab.Project slices, virus, etc.; PEP8 linting Per [element-session issue #9](https://github.com/datajoint/element-session/issues/9), removing references to and export of lab.py. Also reformatted to remove lines over 79 char --- element_lab/export/nwb.py | 79 +++++++++++++++++++++------------------ element_lab/lab.py | 33 ++++++++-------- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index cce7a5e..771b378 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,21 +1,20 @@ -from datetime import datetime from element_lab import lab + def lab_to_nwb_dict(lab_key=None): """ - Generate a dictionary object containing all relevant lab and institution information. + 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 """ if lab_key is not None: lab_info = (lab.Lab & lab_key).fetch1() return dict( - institution=(lab_info['institution'] - if 'institution' in lab_info else ''), - lab=(lab_info['lab_name'] - if 'lab_name' in lab_info else '') + institution=lab_info.get('institution', ''), + lab=lab_info.get('lab_name', '') ) - else: return {} + else: + return {} def project_to_nwb_dict(project_key=None): @@ -27,19 +26,17 @@ def project_to_nwb_dict(project_key=None): """ if project_key is not None: proj_info = (lab.Project & project_key).fetch1() - proj_keyw = (lab.Project.Keywords() & project_key).fetch('keyword').tolist() - proj_pubs = (lab.Project.Publication() & project_key).fetch('publication').tolist() + proj_keyw = (lab.Project.Keywords() & project_key + ).fetch('keyword').tolist() + proj_pubs = (lab.Project.Publication() & project_key + ).fetch('publication').tolist() return dict( - experiment_description=(proj_info.get('project_description', ''), + experiment_description=(proj_info.get('project_description', '')), keywords=proj_keyw, - pharmacology=proj_info.get('pharmacology', ''), - related_publications=proj_pubs, - slices=proj_info.get('slices', ''), - source_script=proj_info.get('repositoryurl', ''), - surgery=(proj_info.get('surgery', ''), - virus=proj_info.get('virus', '') + related_publications=proj_pubs ) - else: return {} + else: + return {} def protocol_to_nwb_dict(protocol_key=None): @@ -53,45 +50,53 @@ def protocol_to_nwb_dict(protocol_key=None): return dict( # data_collection='', protocol=(prot_info['protocol'] - if 'protocol' in prot_info else ''), + if 'protocol' in prot_info else ''), notes=(prot_info['protocol_description'] - if 'project_description' in prot_info else '') + if 'project_description' in prot_info else '') ) - else: return {} + else: + return {} + -def elementlab_nwb_dict(lab_key=None,project_key=None,protocol_key=None): +def elementlab_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. + 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 = NWBfile(identifier="your identifier", session_description="your description", session_start_time=session_datetime, - elementlab_nwb_dict(lab_key=key1,project_key=key2,protocol_key=key3)) - Note: The lab, project and protocol keys should specify one of their respective types. + elementlab_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 + # Validate input if lab_key is not None: - assert len(lab.Lab & lab_key) == 1, 'Multiple labs error! The lab_key should specify only one lab.' - if project_key is not None: assert len(lab.Project & project_key) == 1, \ - f'Multiple projects error! The project_key should specify only one project.' - if protocol_key is not None: assert len(lab.Protocol & protocol_key) == 1, \ - f'Multiple protocols error! The protocol_key should specify only one protocol.' + assert len(lab.Lab & lab_key + ) == 1, ('Multiple labs error! The lab_key should specify ' + + 'only one lab.') + if project_key is not None: + assert len(lab.Project & project_key + ) == 1, ('Multiple projects error! The project_key should' + + ' specify only one project.') + if protocol_key is not None: + assert len(lab.Protocol & protocol_key + ) == 1, ('Multiple protocols error! The protocol_key should' + + ' specify only one protocol.') - elem_info=dict( + elem_info = dict( lab_to_nwb_dict(lab_key), **project_to_nwb_dict(project_key), **protocol_to_nwb_dict(protocol_key) ) - for k in list(elem_info): # Drop blank entries - if len(elem_info[k]) == 0: elem_info.pop(k) + # Drop blank entries + for k in list(elem_info): + if len(elem_info[k]) == 0: + elem_info.pop(k) return elem_info - - - diff --git a/element_lab/lab.py b/element_lab/lab.py index 7fe20cb..cead5a2 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -6,11 +6,15 @@ def activate(schema_name, create_schema=True, create_tables=True): """ activate(schema_name, create_schema=True, create_tables=True) - :param schema_name: schema name on the database server to activate the `lab` element - :param create_schema: when True (default), create schema in the database if it does not yet exist. - :param create_tables: when True (default), create tables in the database if they do not yet exist. + :param schema_name: schema name on the database server to activate the + `lab` element + :param create_schema: when True (default), create schema in the + database if it does not yet exist. + :param create_tables: when True (default), create tables in the + database if they do not yet exist. """ - schema.activate(schema_name, create_schema=create_schema, create_tables=create_tables) + schema.activate(schema_name, create_schema=create_schema, + create_tables=create_tables) @schema @@ -24,6 +28,7 @@ class Lab(dj.Lookup): time_zone : varchar(64) """ + @schema class Location(dj.Lookup): definition = """ @@ -79,18 +84,13 @@ class Protocol(dj.Lookup): protocol_description='' : varchar(255) """ + @schema class Project(dj.Lookup): definition = """ project : varchar(32) --- project_description='' : varchar(1024) - # Below included for archival export (e.g., NWB) - pharmacology = '' : varchar(2048) # Drugs used, how/when administered - viruses='' : varchar(2048) # ID, source, date made, injection loc, volume - slices='' : varchar(2048) # If slicing, preparation thickness, orientation, temperature, and bath solution - stimulus='' : varchar(2048) # Generation method, how/when/where presented - surgery='' : varchar(2048) # Description of surger(y/ies), who performed, when relative to other events """ class Keywords(dj.Part): @@ -110,11 +110,12 @@ class Publication(dj.Part): class SourceCode(dj.Part): definition = """ -> master - repository_url : varchar(256) # URL to source code for replication + repository_url : varchar(256) # URL to source code for replication --- - repository_name='' : varchar(32) + repository_name='' : varchar(32) """ + @schema class ProjectUser(dj.Manual): definition = """ @@ -127,9 +128,9 @@ class ProjectUser(dj.Manual): class Source(dj.Lookup): definition = """ # source or supplier of animals - source : varchar(32) # abbreviated source name + source : varchar(32) # abbreviated source name --- - source_name : varchar(255) - contact_details='' : varchar(255) - source_description='' : varchar(255) + source_name : varchar(255) + contact_details='' : varchar(255) + source_description='' : varchar(255) """ From 506c19166c0b86b4bbab31ef30abde4d9ec5f012 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Wed, 12 Jan 2022 12:34:56 -0600 Subject: [PATCH 27/37] Apply Dimitri's suggestions, additional edit forthcoming Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 771b378..fda44b8 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -76,17 +76,12 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): """ # Validate input if lab_key is not None: - assert len(lab.Lab & lab_key - ) == 1, ('Multiple labs error! The lab_key should specify ' - + 'only one lab.') - if project_key is not None: - assert len(lab.Project & project_key - ) == 1, ('Multiple projects error! The project_key should' - + ' specify only one project.') - if protocol_key is not None: - assert len(lab.Protocol & protocol_key - ) == 1, ('Multiple protocols error! The protocol_key should' - + ' specify only one protocol.') + assert 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! protocol_key should specify only one protocol.' elem_info = dict( lab_to_nwb_dict(lab_key), @@ -95,8 +90,6 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): ) # Drop blank entries - for k in list(elem_info): - if len(elem_info[k]) == 0: - elem_info.pop(k) + elem_info = {k: v for k, v in elem_info.items() if v} return elem_info From 465084dff15a90b5fb7fde9146414674fe0a6c72 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Wed, 12 Jan 2022 12:52:35 -0600 Subject: [PATCH 28/37] refactor nwb.py: only execute funcs if relevant input --- element_lab/export/nwb.py | 85 ++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index fda44b8..3bc6d07 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -1,61 +1,52 @@ from element_lab import lab -def lab_to_nwb_dict(lab_key=None): +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 """ - if lab_key is not None: - lab_info = (lab.Lab & lab_key).fetch1() - return dict( - institution=lab_info.get('institution', ''), - lab=lab_info.get('lab_name', '') - ) - else: - return {} + 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=None): +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 """ - if project_key is not None: - proj_info = (lab.Project & project_key).fetch1() - proj_keyw = (lab.Project.Keywords() & project_key - ).fetch('keyword').tolist() - proj_pubs = (lab.Project.Publication() & project_key - ).fetch('publication').tolist() - return dict( - experiment_description=(proj_info.get('project_description', '')), - keywords=proj_keyw, - related_publications=proj_pubs - ) - else: - return {} + proj_info = (lab.Project & project_key).fetch1() + proj_keyw = (lab.Project.Keywords() & project_key + ).fetch('keyword').tolist() + proj_pubs = (lab.Project.Publication() & project_key + ).fetch('publication').tolist() + return dict( + experiment_description=(proj_info.get('project_description', '')), + keywords=proj_keyw, + related_publications=proj_pubs + ) -def protocol_to_nwb_dict(protocol_key=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 """ - if protocol_key is not None: - prot_info = (lab.Protocol & protocol_key).fetch1() - return dict( - # data_collection='', - protocol=(prot_info['protocol'] - if 'protocol' in prot_info else ''), - notes=(prot_info['protocol_description'] - if 'project_description' in prot_info else '') - ) - else: - return {} + prot_info = (lab.Protocol & protocol_key).fetch1() + return dict( + # data_collection='', + protocol=(prot_info['protocol'] + if 'protocol' in prot_info else ''), + notes=(prot_info['protocol_description'] + if 'project_description' in prot_info else '') + ) def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): @@ -75,19 +66,23 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): :return: dictionary with NWB parameters """ # Validate input - if lab_key is not None: - assert len(lab.Lab & lab_key) == 1, 'Multiple labs error! '\ - 'The lab_key should specify only one lab.' + 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.' + '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! protocol_key should specify only one protocol.' + 'Multiple protocols error! protocol_key should specify only one '\ + 'protocol.' - elem_info = dict( - lab_to_nwb_dict(lab_key), - **project_to_nwb_dict(project_key), - **protocol_to_nwb_dict(protocol_key) - ) + elem_info = dict() + if lab_key: + elem_info.update(**lab_to_nwb_dict(lab_key)) + if project_key: + elem_info.update(**project_to_nwb_dict(project_key)) + if protocol_key: + elem_info.update(**protocol_to_nwb_dict(protocol_key)) # Drop blank entries elem_info = {k: v for k, v in elem_info.items() if v} From a762b26329d297332a765ccca09620645af8ad00 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Thu, 13 Jan 2022 09:59:21 -0600 Subject: [PATCH 29/37] Apply Dimitri's suggestions, additional edit forthcoming Thanks Dimitri! Co-authored-by: Dimitri Yatsenko --- element_lab/export/nwb.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 3bc6d07..5b83d9b 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -41,12 +41,8 @@ def protocol_to_nwb_dict(protocol_key): """ prot_info = (lab.Protocol & protocol_key).fetch1() return dict( - # data_collection='', - protocol=(prot_info['protocol'] - if 'protocol' in prot_info else ''), - notes=(prot_info['protocol_description'] - if 'project_description' in prot_info else '') - ) + protocol=prot_info.get('protocol', ''), + notes=prot_info.get('protocol_description', '')) def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): @@ -78,11 +74,11 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): elem_info = dict() if lab_key: - elem_info.update(**lab_to_nwb_dict(lab_key)) + elem_info.update(lab_to_nwb_dict(lab_key)) if project_key: - elem_info.update(**project_to_nwb_dict(project_key)) + elem_info.update(project_to_nwb_dict(project_key)) if protocol_key: - elem_info.update(**protocol_to_nwb_dict(protocol_key)) + elem_info.update(protocol_to_nwb_dict(protocol_key)) # Drop blank entries elem_info = {k: v for k, v in elem_info.items() if v} From fc47e6c7927e65bc613e46981d8a959f32936408 Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Thu, 13 Jan 2022 12:25:36 -0600 Subject: [PATCH 30/37] Bump version, changelog notes. Add time_zone to export. - removed duplicative version docs across __init__.py and version.py - Discussed timezone on element-session [nwb export PR](https://github.com/datajoint/element-session/pull/7#discussion_r776106803) --- CHANGELOG.md | 5 +++++ element_lab/__init__.py | 4 ---- element_lab/export/nwb.py | 3 ++- element_lab/lab.py | 2 +- element_lab/version.py | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32ee07a..4e6f008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention. +## [0.1.0b1] - 2022-01-13 +### Added ++ Tools to generate dictionaries for NWB export + + ## [0.1.0b0] - 2021-05-07 ### Added + First beta release diff --git a/element_lab/__init__.py b/element_lab/__init__.py index 844e3aa..e69de29 100644 --- a/element_lab/__init__.py +++ b/element_lab/__init__.py @@ -1,4 +0,0 @@ -__author__ = "DataJoint" -__date__ = "December, 2021" -__version__ = "0.1.0b1" -__all__ = ['__author__', '__version__', '__date__'] \ No newline at end of file diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 5b83d9b..145c210 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -10,7 +10,8 @@ def lab_to_nwb_dict(lab_key): lab_info = (lab.Lab & lab_key).fetch1() return dict( institution=lab_info.get('institution', ''), - lab=lab_info.get('lab_name', '') + lab=lab_info.get('lab_name', ''), + time_zone=lab_info.get('time_zone', ''), ) diff --git a/element_lab/lab.py b/element_lab/lab.py index cead5a2..e193a45 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -25,7 +25,7 @@ class Lab(dj.Lookup): lab_name : varchar(255) # full lab name institution : varchar(255) address : varchar(255) - time_zone : varchar(64) + time_zone : varchar(64) # 'UTC±X' format for NWB export """ diff --git a/element_lab/version.py b/element_lab/version.py index 5d6e909..c36d94e 100644 --- a/element_lab/version.py +++ b/element_lab/version.py @@ -1,2 +1,2 @@ """Package metadata.""" -__version__ = '0.1.0b0' \ No newline at end of file +__version__ = '0.1.0b1' From 0d393cd0fb0b22b60f7ac0d8635b9e980e7cc043 Mon Sep 17 00:00:00 2001 From: bendichter Date: Wed, 26 Jan 2022 16:17:43 -0500 Subject: [PATCH 31/37] pass Nones intead of empty strings. These do not populate the NWBFile --- element_lab/export/nwb.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 145c210..57a603b 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -9,9 +9,8 @@ def lab_to_nwb_dict(lab_key): """ lab_info = (lab.Lab & lab_key).fetch1() return dict( - institution=lab_info.get('institution', ''), - lab=lab_info.get('lab_name', ''), - time_zone=lab_info.get('time_zone', ''), + institution=lab_info.get('institution'), + lab=lab_info.get('lab_name'), ) @@ -23,14 +22,10 @@ def project_to_nwb_dict(project_key): :return: dictionary with NWB parameters """ proj_info = (lab.Project & project_key).fetch1() - proj_keyw = (lab.Project.Keywords() & project_key - ).fetch('keyword').tolist() - proj_pubs = (lab.Project.Publication() & project_key - ).fetch('publication').tolist() return dict( - experiment_description=(proj_info.get('project_description', '')), - keywords=proj_keyw, - related_publications=proj_pubs + experiment_description=proj_info.get('project_description'), + keywords=(lab.Project.Keywords() & project_key).fetch('keyword').tolist() or None, + related_publications=(lab.Project.Publication() & project_key).fetch('publication').tolist() or None ) @@ -42,8 +37,9 @@ def protocol_to_nwb_dict(protocol_key): """ prot_info = (lab.Protocol & protocol_key).fetch1() return dict( - protocol=prot_info.get('protocol', ''), - notes=prot_info.get('protocol_description', '')) + protocol=prot_info.get('protocol'), + notes=prot_info.get('protocol_description') + ) def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): @@ -54,8 +50,12 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): Use: mynwbfile = NWBfile(identifier="your identifier", session_description="your description", session_start_time=session_datetime, - elementlab_nwb_dict(lab_key=key1,project_key=key2, - protocol_key=key3)) + **elementlab_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 @@ -81,7 +81,4 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): if protocol_key: elem_info.update(protocol_to_nwb_dict(protocol_key)) - # Drop blank entries - elem_info = {k: v for k, v in elem_info.items() if v} - return elem_info From 33288d5b60b2b2ecbea005854d32eaf455e27545 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Thu, 27 Jan 2022 14:51:33 -0600 Subject: [PATCH 32/37] Pin pynwb to 1.4.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0de5e98..91e70c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ datajoint>=0.13.0 -pynwb +pynwb==1.4.0 From debe13bd54b2a66a81ad99c79b2740a2c0111d46 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Fri, 28 Jan 2022 11:46:25 -0600 Subject: [PATCH 33/37] @Kabilar's code review: PEP8 Co-authored-by: Kabilar Gunalan --- CHANGELOG.md | 2 +- element_lab/export/nwb.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6f008..d61b172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and ## [0.1.0b1] - 2022-01-13 ### Added -+ Tools to generate dictionaries for NWB export ++ Added functions to generate dictionaries for NWB export. ## [0.1.0b0] - 2021-05-07 diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 57a603b..37ce7f4 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -21,9 +21,9 @@ def project_to_nwb_dict(project_key): :param project_key: Key specifying one entry in element_lab.lab.Project :return: dictionary with NWB parameters """ - proj_info = (lab.Project & project_key).fetch1() + project_info = (lab.Project & project_key).fetch1() return dict( - experiment_description=proj_info.get('project_description'), + experiment_description=project_info.get('project_description'), keywords=(lab.Project.Keywords() & project_key).fetch('keyword').tolist() or None, related_publications=(lab.Project.Publication() & project_key).fetch('publication').tolist() or None ) @@ -35,14 +35,14 @@ def protocol_to_nwb_dict(protocol_key): :param protocol_key: Key specifying one entry in element_lab.lab.Protocol :return: dictionary with NWB parameters """ - prot_info = (lab.Protocol & protocol_key).fetch1() + protocol_info = (lab.Protocol & protocol_key).fetch1() return dict( - protocol=prot_info.get('protocol'), - notes=prot_info.get('protocol_description') + protocol=protocol_info.get('protocol'), + notes=protocol_info.get('protocol_description') ) -def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): +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. @@ -59,7 +59,7 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): :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 + :param protocol_key: Key specifying one entry in element_lab.lab.Protocol :return: dictionary with NWB parameters """ # Validate input @@ -70,15 +70,15 @@ def elementlab_nwb_dict(lab_key=None, project_key=None, protocol_key=None): '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! protocol_key should specify only one '\ + 'Multiple protocols error! The protocol_key should specify only one '\ 'protocol.' - elem_info = dict() + element_info = dict() if lab_key: - elem_info.update(lab_to_nwb_dict(lab_key)) + element_info.update(lab_to_nwb_dict(lab_key)) if project_key: - elem_info.update(project_to_nwb_dict(project_key)) + element_info.update(project_to_nwb_dict(project_key)) if protocol_key: - elem_info.update(protocol_to_nwb_dict(protocol_key)) + element_info.update(protocol_to_nwb_dict(protocol_key)) - return elem_info + return element_info From 2c2240f0e569a656862ca76aeaa74d524891449d Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Fri, 28 Jan 2022 11:56:46 -0600 Subject: [PATCH 34/37] dj.part->dj.manual: keyw, pubs, sourcecode --- element_lab/export/nwb.py | 9 ++++---- element_lab/lab.py | 46 +++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 37ce7f4..eedd47d 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -24,8 +24,9 @@ def project_to_nwb_dict(project_key): project_info = (lab.Project & project_key).fetch1() return dict( experiment_description=project_info.get('project_description'), - keywords=(lab.Project.Keywords() & project_key).fetch('keyword').tolist() or None, - related_publications=(lab.Project.Publication() & project_key).fetch('publication').tolist() or None + keywords=(lab.Keywords() & project_key).fetch('keyword').tolist() or None, + related_publications=(lab.Publication() & project_key + ).fetch('publication').tolist() or None ) @@ -53,9 +54,7 @@ def element_lab_to_nwb_dict(lab_key=None, project_key=None, protocol_key=None): **elementlab_nwb_dict( lab_key=key1, project_key=key2, - protocol_key=key3, - ) - ) + 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 diff --git a/element_lab/lab.py b/element_lab/lab.py index e193a45..bbcc733 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -93,27 +93,31 @@ class Project(dj.Lookup): project_description='' : varchar(1024) """ - class Keywords(dj.Part): - definition = """ - # Project keywords, exported dataset meta info - -> master - keyword: varchar(32) - """ - - class Publication(dj.Part): - definition = """ - # Project's resulting publications - -> master - publication: varchar(256) - """ - - class SourceCode(dj.Part): - definition = """ - -> master - repository_url : varchar(256) # URL to source code for replication - --- - repository_name='' : varchar(32) - """ + +class Keywords(dj.Manual): + definition = """ + # Project keywords, exported dataset meta info + -> Project + keyword: varchar(32) + """ + + +class Publication(dj.Manual): + definition = """ + # Project's resulting publications + -> Project + publication: varchar(256) + """ + + +class SourceCode(dj.Manual): + definition = """ + # URL to source code for replication + -> Project + repository_url : varchar(256) + --- + repository_name='' : varchar(32) + """ @schema From 6ddd4205e211fbcd0a3f91046320f6d589638563 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Fri, 28 Jan 2022 11:58:01 -0600 Subject: [PATCH 35/37] Update version history URL list --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d61b172..4189cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,6 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and + Added GitHub Action release process + Added `lab` schema - +[0.1.0b1]: https://github.com/datajoint/element-lab/compare/0.1.0b0...0.1.0b1 [0.1.0b0]: https://github.com/datajoint/element-lab/compare/0.1.0a1...0.1.0b0 [0.1.0a1]: https://github.com/datajoint/element-lab/releases/tag/0.1.0a1 From fe227e1e4b7feae1712b82d6bc0a530c63d0d09f Mon Sep 17 00:00:00 2001 From: Chris Broz Date: Fri, 28 Jan 2022 12:51:11 -0600 Subject: [PATCH 36/37] Prefix former part tables: add Project in name --- element_lab/export/nwb.py | 5 +++-- element_lab/lab.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index eedd47d..1217e29 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -24,8 +24,9 @@ def project_to_nwb_dict(project_key): project_info = (lab.Project & project_key).fetch1() return dict( experiment_description=project_info.get('project_description'), - keywords=(lab.Keywords() & project_key).fetch('keyword').tolist() or None, - related_publications=(lab.Publication() & project_key + keywords=(lab.ProjectKeywords() & project_key + ).fetch('keyword').tolist() or None, + related_publications=(lab.ProjectPublication() & project_key ).fetch('publication').tolist() or None ) diff --git a/element_lab/lab.py b/element_lab/lab.py index bbcc733..10c9ef5 100644 --- a/element_lab/lab.py +++ b/element_lab/lab.py @@ -94,7 +94,7 @@ class Project(dj.Lookup): """ -class Keywords(dj.Manual): +class ProjectKeywords(dj.Manual): definition = """ # Project keywords, exported dataset meta info -> Project @@ -102,7 +102,7 @@ class Keywords(dj.Manual): """ -class Publication(dj.Manual): +class ProjectPublication(dj.Manual): definition = """ # Project's resulting publications -> Project @@ -110,7 +110,7 @@ class Publication(dj.Manual): """ -class SourceCode(dj.Manual): +class ProjectSourceCode(dj.Manual): definition = """ # URL to source code for replication -> Project From 2dccbdccfabf470d8402399d04b374c217eb2941 Mon Sep 17 00:00:00 2001 From: Chris Brozdowski Date: Fri, 28 Jan 2022 13:02:51 -0600 Subject: [PATCH 37/37] Apply suggestions from @kabilar's code review Co-authored-by: Kabilar Gunalan --- CHANGELOG.md | 2 +- element_lab/export/nwb.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4189cff..681b714 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention. -## [0.1.0b1] - 2022-01-13 +## [0.1.0b1] - 2022-01-28 ### Added + Added functions to generate dictionaries for NWB export. diff --git a/element_lab/export/nwb.py b/element_lab/export/nwb.py index 1217e29..8aac6ed 100644 --- a/element_lab/export/nwb.py +++ b/element_lab/export/nwb.py @@ -49,10 +49,10 @@ 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 = NWBfile(identifier="your identifier", + Use: mynwbfile = pynwb.NWBFile(identifier="your identifier", session_description="your description", session_start_time=session_datetime, - **elementlab_nwb_dict( + **element_lab_to_nwb_dict( lab_key=key1, project_key=key2, protocol_key=key3))