|
73 | 73 | "experiment_description", "session_id", "institution", "keywords", "notes", |
74 | 74 | "pharmacology", "protocol", "related_publications", "slices", "source_script", |
75 | 75 | "source_script_file_name", "data_collection", "surgery", "virus", "stimulus_notes", |
76 | | - "lab", "session_description" |
| 76 | + "lab", "session_description", |
| 77 | + "rec_datetime", |
77 | 78 | ) |
78 | 79 |
|
79 | 80 | POSSIBLE_JSON_FIELDS = ( |
@@ -273,7 +274,7 @@ def read_all_blocks(self, lazy=False, **kwargs): |
273 | 274 | "session_start_time"] |
274 | 275 | if "file_create_date" in self.global_block_metadata: |
275 | 276 | self.global_block_metadata["file_datetime"] = self.global_block_metadata[ |
276 | | - "file_create_date"] |
| 277 | + "rec_datetime"] |
277 | 278 |
|
278 | 279 | self._blocks = {} |
279 | 280 | self._read_acquisition_group(lazy=lazy) |
@@ -435,11 +436,13 @@ def write_all_blocks(self, blocks, **kwargs): |
435 | 436 | annotations["session_description"] = blocks[0].description or self.filename |
436 | 437 | # todo: concatenate descriptions of multiple blocks if different |
437 | 438 | 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 |
439 | 444 | # todo: handle subject |
440 | | - # todo: store additional Neo annotations somewhere in NWB file |
441 | 445 | nwbfile = NWBFile(**annotations) |
442 | | - |
443 | 446 | assert self.nwb_file_mode in ('w',) # possibly expand to 'a'ppend later |
444 | 447 | if self.nwb_file_mode == "w" and os.path.exists(self.filename): |
445 | 448 | os.remove(self.filename) |
@@ -518,7 +521,7 @@ def _write_segment(self, nwbfile, segment, electrodes): |
518 | 521 | signal.name = "%s %s %i" % (signal.name, segment.name, i) |
519 | 522 | logging.warning("Warning signal name exists. New name: %s" % (signal.name)) |
520 | 523 | if not signal.name: |
521 | | - signal.name = "%s : analogsignal%d" % (segment.name, i) |
| 524 | + signal.name = "%s : analogsignal%d %i" % (segment.name, i, i) |
522 | 525 | self._write_signal(nwbfile, signal, electrodes) |
523 | 526 |
|
524 | 527 | for i, train in enumerate(segment.spiketrains): |
@@ -632,7 +635,8 @@ class AnalogSignalProxy(BaseAnalogSignalProxy): |
632 | 635 | common_metadata_fields = ( |
633 | 636 | # fields that are the same for all TimeSeries subclasses |
634 | 637 | "comments", "description", "unit", "starting_time", "timestamps", "rate", |
635 | | - "data", "starting_time_unit", "timestamps_unit", "electrode" |
| 638 | + "data", "starting_time_unit", "timestamps_unit", "electrode", |
| 639 | + "stream_id", |
636 | 640 | ) |
637 | 641 |
|
638 | 642 | def __init__(self, timeseries, nwb_group): |
|
0 commit comments