From 036775e292a196eb3c3c3620b60dd41a39c17294 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Fri, 25 Oct 2024 12:40:27 +0200 Subject: [PATCH 1/3] add support for background components in FrameSliceSegmentationExtractor --- src/roiextractors/segmentationextractor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/roiextractors/segmentationextractor.py b/src/roiextractors/segmentationextractor.py index 3c2881c1..06c17993 100644 --- a/src/roiextractors/segmentationextractor.py +++ b/src/roiextractors/segmentationextractor.py @@ -476,6 +476,9 @@ def __init__( if hasattr(self._parent_segmentation, "_image_masks"): # otherwise, do not set attribute at all self._image_masks = self._parent_segmentation._image_masks + if hasattr(self._parent_segmentation, "_background_image_masks"): # otherwise, do not set attribute at all + self._background_image_masks = self._parent_segmentation._background_image_masks + parent_size = self._parent_segmentation.get_num_frames() if start_frame is None: start_frame = 0 @@ -530,6 +533,9 @@ def get_num_frames(self) -> int: def get_num_rois(self) -> int: return self._parent_segmentation.get_num_rois() + def get_num_background_components(self) -> int: + return self._parent_segmentation.get_num_background_components() + def get_images_dict(self) -> dict: return self._parent_segmentation.get_images_dict() @@ -550,3 +556,6 @@ def get_num_planes(self) -> int: def get_roi_pixel_masks(self, roi_ids: Optional[ArrayLike] = None) -> List[np.ndarray]: return self._parent_segmentation.get_roi_pixel_masks(roi_ids=roi_ids) + + def get_background_pixel_masks(self, background_ids: Optional[ArrayLike] = None) -> List[np.ndarray]: + return self._parent_segmentation.get_background_pixel_masks(background_ids=background_ids) \ No newline at end of file From e47970590eb668e66e8e77a89ad74cafccb3369b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:43:36 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/roiextractors/segmentationextractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/roiextractors/segmentationextractor.py b/src/roiextractors/segmentationextractor.py index 06c17993..7694f478 100644 --- a/src/roiextractors/segmentationextractor.py +++ b/src/roiextractors/segmentationextractor.py @@ -558,4 +558,4 @@ def get_roi_pixel_masks(self, roi_ids: Optional[ArrayLike] = None) -> List[np.nd return self._parent_segmentation.get_roi_pixel_masks(roi_ids=roi_ids) def get_background_pixel_masks(self, background_ids: Optional[ArrayLike] = None) -> List[np.ndarray]: - return self._parent_segmentation.get_background_pixel_masks(background_ids=background_ids) \ No newline at end of file + return self._parent_segmentation.get_background_pixel_masks(background_ids=background_ids) From a051bc9e2e0fa363997f9c937e8e8d8560a32898 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Fri, 25 Oct 2024 12:44:57 +0200 Subject: [PATCH 3/3] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53e78c5..8ed444e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Fixes * Added specific error message for single-frame scanimage data [PR #360](https://github.com/catalystneuro/roiextractors/pull/360) * Fixed bug with ScanImage's parse_metadata so that it works properly when hStackManager is disabled [PR #373](https://github.com/catalystneuro/roiextractors/pull/373) +* Add support for background components in FrameSliceSegmentationExtractor [PR #378](https://github.com/catalystneuro/roiextractors/pull/378) ### Improvements * Removed unnecessary import checks for scipy, h5py, and zarr [PR #364](https://github.com/catalystneuro/roiextractors/pull/364)