Skip to content

Commit

Permalink
Merge pull request #263 from catalystneuro/fix_suite2p_channel_name
Browse files Browse the repository at this point in the history
Fix override of `channel_name` in `Suite2pSegmentationExtractor`
  • Loading branch information
CodyCBakerPhD authored Nov 22, 2023
2 parents 5ffb0a5 + 3ca299f commit 138a8e3
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
### Fixes

* Fixed `MicroManagerTiffImagingExtractor` private extractor's dtype to not override the parent's dtype. [PR #257](https://github.com/catalystneuro/roiextractors/pull/257)

* Fixed override of `channel_name` in `Suite2pSegmentationExtractor`. [PR #263](https://github.com/catalystneuro/roiextractors/pull/263)


# v0.5.4
Original file line number Diff line number Diff line change
@@ -168,8 +168,9 @@ def __init__(

self.iscell = self._load_npy("iscell.npy", mmap_mode="r")

channel_name = "OpticalChannel" if len(channel_names) == 1 else channel_name.capitalize()
self._channel_names = [channel_name]
# The name of the OpticalChannel object is "OpticalChannel" if there is only one channel, otherwise it is
# "Chan1" or "Chan2".
self._channel_names = ["OpticalChannel" if len(channel_names) == 1 else channel_name.capitalize()]

self._image_correlation = self._correlation_image_read()
image_mean_name = "meanImg" if channel_name == "chan1" else f"meanImg_chan2"
19 changes: 17 additions & 2 deletions tests/test_suite2psegmentationextractor.py
Original file line number Diff line number Diff line change
@@ -28,6 +28,10 @@ def setUpClass(cls):
cls.first_channel_raw_traces = np.load(cls.folder_path / "plane0" / "F.npy").T
cls.second_channel_raw_traces = np.load(cls.folder_path / "plane0" / "F_chan2.npy").T

options = np.load(cls.folder_path / "plane0" / "ops.npy", allow_pickle=True).item()
cls.first_channel_mean_image = options["meanImg"]
cls.second_channel_mean_image = options["meanImg_chan2"]

cls.image_size = (128, 128)
cls.num_rois = 15

@@ -43,7 +47,7 @@ def tearDownClass(cls):
# remove the temporary directory and its contents
shutil.rmtree(cls.test_dir)

def test_channel_names(self):
def test_available_channel_names(self):
self.assertEqual(
Suite2pSegmentationExtractor.get_available_channels(folder_path=self.folder_path), self.channel_names
)
@@ -98,7 +102,7 @@ def test_num_frames(self):
def test_sampling_frequency(self):
self.assertEqual(self.extractor.get_sampling_frequency(), 10.0)

def test_channel_names(self):
def test_optical_channel_names(self):
self.assertEqual(self.extractor.get_channel_names(), ["Chan1"])

def test_num_channels(self):
@@ -125,3 +129,14 @@ def test_extractor_image_masks_selected_rois(self):
"""Test that the image masks are correctly extracted for a subset of ROIs."""
roi_indices = list(range(5))
assert_array_equal(self.extractor.get_roi_image_masks(roi_ids=roi_indices), self.image_masks[..., roi_indices])

def test_first_channel_mean_image(self):
"""Test that the mean image is correctly loaded from the extractor."""
images_dict = self.extractor.get_images_dict()
assert_array_equal(images_dict["mean"], self.first_channel_mean_image)

def test_second_channel_mean_image(self):
"""Test that the mean image for the second channel is correctly loaded from the extractor."""
extractor = Suite2pSegmentationExtractor(folder_path=self.folder_path, channel_name="chan2")
images_dict = extractor.get_images_dict()
assert_array_equal(images_dict["mean"], self.second_channel_mean_image)

0 comments on commit 138a8e3

Please sign in to comment.