From 7aa2a63c1700075df45f377cc281f573aa1c30f8 Mon Sep 17 00:00:00 2001 From: Richard Hakim Date: Mon, 4 Mar 2024 13:49:39 -0500 Subject: [PATCH] allow for incomplete data ingestion, fix ypix bug, add mean image to caiman seg class (#227) * added new args to allow for incomplete data import and fixed potential bug with ypix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make method: caiman seg class retrieve mean image * Update src/roiextractors/extractors/suite2p/suite2psegmentationextractor.py naming of _load_npy Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update src/roiextractors/extractors/suite2p/suite2psegmentationextractor.py remove search_plane_subdirectory Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> * update changelog * fix bug and remove remaining references to search_plane_subdirectory * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * bug fix on function name passing tests now * Revert suite2p to main version * add docstrings --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Co-authored-by: Paul Adkisson --- CHANGELOG.md | 5 +++++ .../caiman/caimansegmentationextractor.py | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c894813b..a29c46c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,11 @@ * Added support for Miniscope AVI files with the `MiniscopeImagingExtractor`. [PR #225](https://github.com/catalystneuro/roiextractors/pull/225) +* Added support for incomplete file ingestion for the `Suite2pSegmentationExtractor`. [PR #227](https://github.com/catalystneuro/roiextractors/pull/227) + +* Bug fix for the `CaimanSegmentationExtractor`: Change reshaping from 'C' to 'F' (Fortran). [PR #227](https://github.com/catalystneuro/roiextractors/pull/227) + +* Bug fix for the `CaimanSegmentationExtractor`: Added importing of `self._image_correlation` and changed how `self._image_mean` to import the background component image. [PR #227](https://github.com/catalystneuro/roiextractors/pull/227) # v0.5.2 diff --git a/src/roiextractors/extractors/caiman/caimansegmentationextractor.py b/src/roiextractors/extractors/caiman/caimansegmentationextractor.py index 77eefb29..613b8bbd 100644 --- a/src/roiextractors/extractors/caiman/caimansegmentationextractor.py +++ b/src/roiextractors/extractors/caiman/caimansegmentationextractor.py @@ -58,7 +58,8 @@ def __init__(self, file_path: PathType): self._roi_response_dff = self._trace_extractor_read("F_dff") self._roi_response_neuropil = self._trace_extractor_read("C") self._roi_response_deconvolved = self._trace_extractor_read("S") - self._image_correlation = self._summary_image_read() + self._image_correlation = self._correlation_image_read() + self._image_mean = self._summary_image_read() self._sampling_frequency = self._dataset_file["params"]["data"]["fr"][()] self._image_masks = self._image_mask_sparse_read() @@ -112,11 +113,18 @@ def _trace_extractor_read(self, field): if field in self._dataset_file["estimates"]: return lazy_ops.DatasetView(self._dataset_file["estimates"][field]).lazy_transpose() - def _summary_image_read(self): - """Read the summary image (Cn) from the estimates dataset of the h5py file.""" + def _correlation_image_read(self): + """Read correlation image Cn.""" if self._dataset_file["estimates"].get("Cn"): return np.array(self._dataset_file["estimates"]["Cn"]) + def _summary_image_read(self): + """Read summary image mean.""" + if self._dataset_file["estimates"].get("b"): + FOV_shape = self._dataset_file["params"]["data"]["dims"][()] + b_sum = self._dataset_file["estimates"]["b"][:].sum(axis=1) + return np.array(b_sum).reshape(FOV_shape, order="F") + def get_accepted_list(self): accepted = self._dataset_file["estimates"]["idx_components"] if len(accepted.shape) == 0: