Skip to content

Commit

Permalink
add extraction of timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandratrapani committed Oct 8, 2024
1 parent a7d5a2e commit a96f063
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/roiextractors/extractors/minian/miniansegmentationextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit a96f063

Please sign in to comment.