From a96f0638ce564fe6c93c41151c8dc2b7524caca4 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Tue, 8 Oct 2024 10:51:32 +0200 Subject: [PATCH] add extraction of timestamps --- .../minian/miniansegmentationextractor.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/roiextractors/extractors/minian/miniansegmentationextractor.py b/src/roiextractors/extractors/minian/miniansegmentationextractor.py index 229473e4..b7d2931a 100644 --- a/src/roiextractors/extractors/minian/miniansegmentationextractor.py +++ b/src/roiextractors/extractors/minian/miniansegmentationextractor.py @@ -11,6 +11,7 @@ import zarr import warnings import numpy as np +import pandas as pd from ...extraction_tools import PathType from ...segmentationextractor import SegmentationExtractor @@ -43,8 +44,10 @@ def __init__(self, folder_path: PathType): self._roi_response_neuropil = self._trace_extractor_read(field="f") self._roi_response_deconvolved = self._trace_extractor_read(field="S") self._image_maximum_projection = self._file_extractor_read("/max_proj.zarr/max_proj") + # TODO add extraction of motion correction self._image_masks = self._roi_image_mask_read() self._background_image_masks = self._background_image_mask_read() + self._times = self._timestamps_extractor_read() def _file_extractor_read(self, zarr_group=""): """Read the zarr. @@ -111,6 +114,22 @@ def _trace_extractor_read(self, field): elif dataset[field].ndim == 1: return np.expand_dims(dataset[field], axis=1) + def _timestamps_extractor_read(self): + """ Extract timestamps corresponding to frame numbers of the stored denoised trace + + Returns + ------- + list + The timestamps of the denoised trace. + """ + + csv_file = self.folder_path + "timeStamps.csv" + df = pd.read_csv(csv_file) + frame_numbers = self._file_extractor_read("/C.zarr/frame") + filtered_df = df[df['Frame Number'].isin(frame_numbers)] + + return filtered_df['Time Stamp (ms)'].tolist() + def get_image_size(self): dataset = self._file_extractor_read("/A.zarr") height = dataset["height"].shape[0]