7373 "experiment_description" , "session_id" , "institution" , "keywords" , "notes" ,
7474 "pharmacology" , "protocol" , "related_publications" , "slices" , "source_script" ,
7575 "source_script_file_name" , "data_collection" , "surgery" , "virus" , "stimulus_notes" ,
76- "lab" , "session_description"
76+ "lab" , "session_description" ,
77+ "rec_datetime" ,
7778)
7879
7980POSSIBLE_JSON_FIELDS = (
@@ -273,7 +274,7 @@ def read_all_blocks(self, lazy=False, **kwargs):
273274 "session_start_time" ]
274275 if "file_create_date" in self .global_block_metadata :
275276 self .global_block_metadata ["file_datetime" ] = self .global_block_metadata [
276- "file_create_date " ]
277+ "rec_datetime " ]
277278
278279 self ._blocks = {}
279280 self ._read_acquisition_group (lazy = lazy )
@@ -435,11 +436,13 @@ def write_all_blocks(self, blocks, **kwargs):
435436 annotations ["session_description" ] = blocks [0 ].description or self .filename
436437 # todo: concatenate descriptions of multiple blocks if different
437438 if "session_start_time" not in annotations :
438- raise Exception ("Writing to NWB requires an annotation 'session_start_time'" )
439+ annotations ["session_start_time" ] = blocks [0 ].rec_datetime
440+ if annotations ["session_start_time" ] is None :
441+ raise Exception ("Writing to NWB requires an annotation 'session_start_time'" )
442+ self .annotations = {"rec_datetime" : "rec_datetime" }
443+ self .annotations ["rec_datetime" ] = blocks [0 ].rec_datetime
439444 # todo: handle subject
440- # todo: store additional Neo annotations somewhere in NWB file
441445 nwbfile = NWBFile (** annotations )
442-
443446 assert self .nwb_file_mode in ('w' ,) # possibly expand to 'a'ppend later
444447 if self .nwb_file_mode == "w" and os .path .exists (self .filename ):
445448 os .remove (self .filename )
@@ -514,8 +517,9 @@ def _write_segment(self, nwbfile, segment, electrodes):
514517 for i , signal in enumerate (
515518 chain (segment .analogsignals , segment .irregularlysampledsignals )):
516519 assert signal .segment is segment
520+ signal .name = "%s %s %i" % (signal .name , segment .name , i )
517521 if not signal .name :
518- signal .name = "%s : analogsignal%d" % (segment .name , i )
522+ signal .name = "%s : analogsignal%d %i " % (segment .name , i , i )
519523 self ._write_signal (nwbfile , signal , electrodes )
520524
521525 for i , train in enumerate (segment .spiketrains ):
@@ -526,6 +530,7 @@ def _write_segment(self, nwbfile, segment, electrodes):
526530
527531 for i , event in enumerate (segment .events ):
528532 assert event .segment is segment
533+ event .name = "%s %s %i" % (event .name , segment .name , i )
529534 if not event .name :
530535 event .name = "%s : event%d" % (segment .name , i )
531536 self ._write_event (nwbfile , event )
@@ -626,7 +631,8 @@ class AnalogSignalProxy(BaseAnalogSignalProxy):
626631 common_metadata_fields = (
627632 # fields that are the same for all TimeSeries subclasses
628633 "comments" , "description" , "unit" , "starting_time" , "timestamps" , "rate" ,
629- "data" , "starting_time_unit" , "timestamps_unit" , "electrode"
634+ "data" , "starting_time_unit" , "timestamps_unit" , "electrode" ,
635+ "stream_id" ,
630636 )
631637
632638 def __init__ (self , timeseries , nwb_group ):
0 commit comments