nwb.py
session_to_nwb(session_key, lab_key=None, project_key=None, protocol_key=None, additional_nwbfile_kwargs=None)
¶
Return subject and session metadata as NWBFile object
Gather session- and subject-level metadata and use it to create an NWBFile. If there is no subject_to_nwb export function in the current namespace, subject_id will be inferred from the set of primary attributes in the Subject table upstream of Session.
Example
session_to_nwb( session_key={'subject': 'subject5', 'session_datetime': datetime.datetime(2020, 5, 12, 4, 13, 7)}, lab_key={"lab": "LabA"} )
Element to NWB Mappings
session.Session::KEY -> NWBFile.session_id
session.Session::session_datetime -> NWBFile.session_start_time
session.SessionNote::session_note -> NWBFile.session_description
session.SessionExperimenter::user -> NWBFile.experimenter
subject.Subject::subject -> NWBFile.subject.subject_id
subject.Subject::sex -> NWBFile.subject.sex
lab.Lab::institution -> NWBFile.institution
lab.Lab::lab_name -> NWBFile.lab
lab.Protocol::protocol -> NWBFile.protocol
lab.Protocol::protocol_description -> NWBFile.notes
lab.Project::project_description -> NWBFile.experiment_description
lab.ProjectKeywords.keyword -> NWBFile.keywords
lab.ProjectPublication.publication -> NWBFile.related_publications
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_key |
dict
|
Key for session.Session. Assumes session_datetime is in UTC time zone. |
required |
lab_key |
dict
|
Key for lab.Lab. Defaults to None. |
None
|
project_key |
dict
|
Key for lab.Project. Defaults to None. |
None
|
protocol_key |
dict
|
Key for Lab.Protocol. Defaults to None. |
None
|
additional_nwbfile_kwargs |
dict
|
Optionally overwrite or add fields to NWBFile. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
NWBFile
|
pynwb.NWBFile: NWB file object |
Source code in element_session/export/nwb.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|