Skip to content

Commit

Permalink
Merge branch 'bugfix-metadata_export' into experiment-202411
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sasatani committed Nov 27, 2024
2 parents 62ed296 + 9b26971 commit 8cf6426
Show file tree
Hide file tree
Showing 6 changed files with 3,231 additions and 15 deletions.
5 changes: 4 additions & 1 deletion miniscope_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def append(self, data: List[Any]) -> None:
data : List[Any]
The data to be appended.
"""
data = [int(value) if isinstance(value, np.generic) else value for value in data]
data = [
float(value) if isinstance(value, (np.integer, np.floating)) else value
for value in data
]
self.buffer.append(data)
if len(self.buffer) >= self.buffer_size:
self.flush_buffer()
Expand Down
15 changes: 7 additions & 8 deletions miniscope_io/stream_daq.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,14 +710,6 @@ def capture(
update_ms=self.config.runtime.plot.update_ms,
)

if metadata:
self._buffered_writer = BufferedCSVWriter(
metadata, buffer_size=self.config.runtime.csvwriter.buffer
)
self._buffered_writer.append(
list(StreamBufferHeader.model_fields.keys()) + ["unix_time"]
)

try:
for image, header_list in exact_iter(imagearray.get, None):
self._handle_frame(
Expand Down Expand Up @@ -797,6 +789,13 @@ def _handle_frame(
except Exception as e:
self.logger.exception(f"Exception plotting headers: \n{e}")
if metadata:
if self._buffered_writer is None:
self._buffered_writer = BufferedCSVWriter(
metadata, buffer_size=self.config.runtime.csvwriter.buffer
)
self._buffered_writer.append(
list(header.model_dump(warnings=False).keys()) + ["unix_time"]
)
self.logger.debug("Saving header metadata")
try:
self._buffered_writer.append(
Expand Down
Binary file modified tests/data/stream_daq_test_fpga_raw_input_200px.bin
Binary file not shown.
Binary file modified tests/data/stream_daq_test_output_200px.avi
Binary file not shown.
Loading

0 comments on commit 8cf6426

Please sign in to comment.