Skip to content

Commit

Permalink
Add support for background components in FrameSliceSegmentationExtrac…
Browse files Browse the repository at this point in the history
…tor (#378)

* add support for background components in FrameSliceSegmentationExtractor

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update CHANGELOG.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
alessandratrapani and pre-commit-ci[bot] authored Oct 25, 2024
1 parent 5d8284b commit e8eb2cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/roiextractors/segmentationextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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)

0 comments on commit e8eb2cf

Please sign in to comment.