Skip to content

Commit

Permalink
BaseSegmentation class improvements (#327)
Browse files Browse the repository at this point in the history
* prepopulate private attribute for image mask; rearrange abstract method

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

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

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Paul Adkisson <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent c184754 commit b8bc0db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

### Fixes

* Remove unecessary scipy import error handling: [#315](https://github.com/catalystneuro/roiextractors/pull/315)
* Remove unnecessary `scipy` import error handling: [#315](https://github.com/catalystneuro/roiextractors/pull/315)
* Fixed the typing returned by the `InscopixImagingExtractor.get_dtype` method: [#326](https://github.com/catalystneuro/roiextractors/pull/326)

### Improvements

* The `Suite2PSegmentationExtractor` now produces an error when a required sub-file is missin: [#330](https://github.com/catalystneuro/roiextractors/pull/330)
* Added `_image_mask` initialization in `BaseSegmentationExtractor`; combined `abstractmethod`s into top of file: [#327](https://github.com/catalystneuro/roiextractors/pull/327)

### Testing

Expand Down
25 changes: 13 additions & 12 deletions src/roiextractors/segmentationextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SegmentationExtractor(ABC):
"""

def __init__(self):
"""Create a new SegmentationExtractor from specified data type (unique to each child SegmentationExtractor)."""
"""Create a new SegmentationExtractor for a specific data format (unique to each child SegmentationExtractor)."""
self._sampling_frequency = None
self._times = None
self._channel_names = ["OpticalChannel"]
Expand All @@ -44,6 +44,7 @@ def __init__(self):
self._roi_response_deconvolved = None
self._image_correlation = None
self._image_mean = None
self._image_mask = None

@abstractmethod
def get_accepted_list(self) -> list:
Expand All @@ -67,6 +68,17 @@ def get_rejected_list(self) -> list:
"""
pass

@abstractmethod
def get_image_size(self) -> ArrayType:
"""Get frame size of movie (height, width).
Returns
-------
no_rois: array_like
2-D array: image height x image width
"""
pass

def get_num_frames(self) -> int:
"""Get the number of frames in the recording (duration of recording).
Expand Down Expand Up @@ -204,17 +216,6 @@ def get_background_pixel_masks(self, background_ids=None) -> np.array:

return _pixel_mask_extractor(self.get_background_image_masks(background_ids=background_ids), background_ids)

@abstractmethod
def get_image_size(self) -> ArrayType:
"""Get frame size of movie (height, width).
Returns
-------
no_rois: array_like
2-D array: image height x image width
"""
pass

def frame_slice(self, start_frame: Optional[int] = None, end_frame: Optional[int] = None):
"""Return a new SegmentationExtractor ranging from the start_frame to the end_frame.
Expand Down

0 comments on commit b8bc0db

Please sign in to comment.