From ed16fc3f2b02e8a7a3f65022fa3417a5c12d2197 Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 14:35:54 -0500 Subject: [PATCH 01/23] add inscopix imaging extractor --- requirements-full.txt | 1 + src/roiextractors/extractorlist.py | 2 + .../extractors/inscopixextractors/__init__.py | 1 + .../inscopiximagingextractor.py | 43 ++++++++++++++++ tests/test_inscopiximagingextractor.py | 49 +++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 src/roiextractors/extractors/inscopixextractors/__init__.py create mode 100644 src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py create mode 100644 tests/test_inscopiximagingextractor.py diff --git a/requirements-full.txt b/requirements-full.txt index bd515c3e..1b05e432 100644 --- a/requirements-full.txt +++ b/requirements-full.txt @@ -2,3 +2,4 @@ tifffile>=2018.10.18 scanimage-tiff-reader==1.4.1 neuroconv[video]>=0.4.6 # Uses the VideoCaptureContext class natsort>=8.3.1 +isx \ No newline at end of file diff --git a/src/roiextractors/extractorlist.py b/src/roiextractors/extractorlist.py index 73d0bf6e..959f9e97 100644 --- a/src/roiextractors/extractorlist.py +++ b/src/roiextractors/extractorlist.py @@ -22,6 +22,7 @@ MicroManagerTiffImagingExtractor, ) from .extractors.sbximagingextractor import SbxImagingExtractor +from .extractors.inscopixextractors import InscopixImagingExtractor from .extractors.memmapextractors import NumpyMemmapImagingExtractor from .extractors.memmapextractors import MemmapImagingExtractor from .extractors.miniscopeimagingextractor import MiniscopeImagingExtractor @@ -45,6 +46,7 @@ NumpyMemmapImagingExtractor, MemmapImagingExtractor, VolumetricImagingExtractor, + InscopixImagingExtractor, ] segmentation_extractor_full_list = [ diff --git a/src/roiextractors/extractors/inscopixextractors/__init__.py b/src/roiextractors/extractors/inscopixextractors/__init__.py new file mode 100644 index 00000000..35c9ab3a --- /dev/null +++ b/src/roiextractors/extractors/inscopixextractors/__init__.py @@ -0,0 +1 @@ +from .inscopiximagingextractor import InscopixImagingExtractor \ No newline at end of file diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py new file mode 100644 index 00000000..5c71aad6 --- /dev/null +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -0,0 +1,43 @@ +import warnings +from typing import Optional, Tuple + +import numpy as np + +from ...imagingextractor import ImagingExtractor +from ...extraction_tools import PathType + + +class InscopixImagingExtractor(ImagingExtractor): + + extractor_name = "InscopixImaging" + + def __init__(self, file_path: PathType): + + import isx + + super().__init__(file_path=file_path) + self.movie = isx.Movie.read(file_path) + + def get_image_size(self) -> Tuple[int, int]: + num_pixels = self.movie.spacing.num_pixels + return num_pixels + + def get_num_frames(self) -> int: + return self.movie.timing.num_samples + + def get_sampling_frequency(self) -> float: + return 1 / self.movie.timing.period.secs_float + + def get_channel_names(self) -> list: + warnings.warn("isx only supports single channel videos.") + return ["channel_0"] + + def get_num_channels(self) -> int: + warnings.warn("isx only supports single channel videos.") + return 1 + + def get_video(self, start_frame: Optional[int] = None, end_frame: Optional[int] = None, + channel: int = 0) -> np.ndarray: + start_frame = start_frame or 0 + end_frame = end_frame or self.get_num_frames() + return np.array([self.movie.get_frame_data(i) for i in range(start_frame, end_frame)]) \ No newline at end of file diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py new file mode 100644 index 00000000..628bc297 --- /dev/null +++ b/tests/test_inscopiximagingextractor.py @@ -0,0 +1,49 @@ +import numpy as np +from numpy import dtype +from numpy.testing import assert_array_equal + +from roiextractors import InscopixImagingExtractor + +from .setup_paths import OPHYS_DATA_PATH + + +def test_inscopiximagingextractor_movie_128x128x100_part1(): + + file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_128x128x100_part1.isxd" + extractor = InscopixImagingExtractor(file_path=file_path) + + assert extractor.get_num_frames() == 100 + assert extractor.get_image_size() == (128, 128) + assert extractor.get_dtype() == dtype("float64") + assert extractor.get_sampling_frequency() == 10.0 + assert extractor.get_channel_names() == ["channel_0"] + assert extractor.get_num_channels() == 1 + assert extractor.get_video().shape == (100, 128, 128) + + +def test_inscopiximagingextractor_movie_longer_than_3_min(): + + file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_longer_than_3_min.isxd" + extractor = InscopixImagingExtractor(file_path=file_path) + + assert extractor.get_num_frames() == 1248 + assert extractor.get_image_size() == (33, 29) + assert extractor.get_dtype() == dtype("int64") + np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 5.5563890139076415) + assert extractor.get_channel_names() == ["channel_0"] + assert extractor.get_num_channels() == 1 + assert extractor.get_video().shape == (1248, 33, 29) + + +def test_inscopiximagingextractor_movie_u8(): + + file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_u8.isxd" + extractor = InscopixImagingExtractor(file_path=file_path) + + assert extractor.get_num_frames() == 5 + assert extractor.get_image_size() == (3, 4) + assert extractor.get_dtype() == dtype("int64") + np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 20.0) + assert extractor.get_channel_names() == ["channel_0"] + assert extractor.get_num_channels() == 1 + assert extractor.get_video().shape == (5, 3, 4) From 920547d33319d78d4356cc518bd5ca178f47223a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 19:36:23 +0000 Subject: [PATCH 02/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- requirements-full.txt | 2 +- .../extractors/inscopixextractors/__init__.py | 2 +- .../inscopixextractors/inscopiximagingextractor.py | 9 ++++----- tests/test_inscopiximagingextractor.py | 3 --- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/requirements-full.txt b/requirements-full.txt index 1b05e432..efb448f6 100644 --- a/requirements-full.txt +++ b/requirements-full.txt @@ -2,4 +2,4 @@ tifffile>=2018.10.18 scanimage-tiff-reader==1.4.1 neuroconv[video]>=0.4.6 # Uses the VideoCaptureContext class natsort>=8.3.1 -isx \ No newline at end of file +isx diff --git a/src/roiextractors/extractors/inscopixextractors/__init__.py b/src/roiextractors/extractors/inscopixextractors/__init__.py index 35c9ab3a..c7850bbb 100644 --- a/src/roiextractors/extractors/inscopixextractors/__init__.py +++ b/src/roiextractors/extractors/inscopixextractors/__init__.py @@ -1 +1 @@ -from .inscopiximagingextractor import InscopixImagingExtractor \ No newline at end of file +from .inscopiximagingextractor import InscopixImagingExtractor diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 5c71aad6..8434491f 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -8,11 +8,9 @@ class InscopixImagingExtractor(ImagingExtractor): - extractor_name = "InscopixImaging" def __init__(self, file_path: PathType): - import isx super().__init__(file_path=file_path) @@ -36,8 +34,9 @@ def get_num_channels(self) -> int: warnings.warn("isx only supports single channel videos.") return 1 - def get_video(self, start_frame: Optional[int] = None, end_frame: Optional[int] = None, - channel: int = 0) -> np.ndarray: + def get_video( + self, start_frame: Optional[int] = None, end_frame: Optional[int] = None, channel: int = 0 + ) -> np.ndarray: start_frame = start_frame or 0 end_frame = end_frame or self.get_num_frames() - return np.array([self.movie.get_frame_data(i) for i in range(start_frame, end_frame)]) \ No newline at end of file + return np.array([self.movie.get_frame_data(i) for i in range(start_frame, end_frame)]) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 628bc297..63dd07b8 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -8,7 +8,6 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_128x128x100_part1.isxd" extractor = InscopixImagingExtractor(file_path=file_path) @@ -22,7 +21,6 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): def test_inscopiximagingextractor_movie_longer_than_3_min(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_longer_than_3_min.isxd" extractor = InscopixImagingExtractor(file_path=file_path) @@ -36,7 +34,6 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): def test_inscopiximagingextractor_movie_u8(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_u8.isxd" extractor = InscopixImagingExtractor(file_path=file_path) From b6e8e3cd5301b8635edcd59a5c1992ae3b41cf86 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Tue, 23 Jan 2024 14:48:00 -0500 Subject: [PATCH 03/23] Update run-tests.yml rmv py3.8 --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1723bbd9..c82c9dd6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, "3.10", 3.11] + python-version: ["3.9", "3.10", "3.11"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: s-weigand/setup-conda@v1 From b34f1b79562af48979f4b316f505c23e4001dffc Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 14:49:35 -0500 Subject: [PATCH 04/23] give in to strong typing --- tests/test_inscopiximagingextractor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 628bc297..4180c9eb 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -10,7 +10,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_128x128x100_part1.isxd" - extractor = InscopixImagingExtractor(file_path=file_path) + extractor = InscopixImagingExtractor(file_path=str(file_path)) assert extractor.get_num_frames() == 100 assert extractor.get_image_size() == (128, 128) @@ -24,7 +24,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): def test_inscopiximagingextractor_movie_longer_than_3_min(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_longer_than_3_min.isxd" - extractor = InscopixImagingExtractor(file_path=file_path) + extractor = InscopixImagingExtractor(file_path=str(file_path)) assert extractor.get_num_frames() == 1248 assert extractor.get_image_size() == (33, 29) @@ -38,7 +38,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): def test_inscopiximagingextractor_movie_u8(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_u8.isxd" - extractor = InscopixImagingExtractor(file_path=file_path) + extractor = InscopixImagingExtractor(file_path=str(file_path)) assert extractor.get_num_frames() == 5 assert extractor.get_image_size() == (3, 4) From 63c4613f71fb44237f68c4844ca276b1774329cf Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 14:59:55 -0500 Subject: [PATCH 05/23] give in to strong typing --- .../inscopixextractors/inscopiximagingextractor.py | 2 +- tests/test_inscopiximagingextractor.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 8434491f..da6ecb95 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -14,7 +14,7 @@ def __init__(self, file_path: PathType): import isx super().__init__(file_path=file_path) - self.movie = isx.Movie.read(file_path) + self.movie = isx.Movie.read(str(file_path)) def get_image_size(self) -> Tuple[int, int]: num_pixels = self.movie.spacing.num_pixels diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index ace3f4df..63dd07b8 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -9,7 +9,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_128x128x100_part1.isxd" - extractor = InscopixImagingExtractor(file_path=str(file_path)) + extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 100 assert extractor.get_image_size() == (128, 128) @@ -22,7 +22,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): def test_inscopiximagingextractor_movie_longer_than_3_min(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_longer_than_3_min.isxd" - extractor = InscopixImagingExtractor(file_path=str(file_path)) + extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 1248 assert extractor.get_image_size() == (33, 29) @@ -35,7 +35,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): def test_inscopiximagingextractor_movie_u8(): file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_u8.isxd" - extractor = InscopixImagingExtractor(file_path=str(file_path)) + extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 5 assert extractor.get_image_size() == (3, 4) From 55a9d4abc3d97b3c1aba46c595407691da5b28db Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 15:04:00 -0500 Subject: [PATCH 06/23] fix data paths --- tests/test_inscopiximagingextractor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 63dd07b8..77d6b07b 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -8,7 +8,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_128x128x100_part1.isxd" + file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_128x128x100_part1.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 100 @@ -21,7 +21,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): def test_inscopiximagingextractor_movie_longer_than_3_min(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_longer_than_3_min.isxd" + file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_longer_than_3_min.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 1248 @@ -34,7 +34,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): def test_inscopiximagingextractor_movie_u8(): - file_path = OPHYS_DATA_PATH / "imaging_data" / "inscopix" / "movie_u8.isxd" + file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_u8.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 5 From eadd98be1eb5264dc81e26f29a09d1b8a5a81478 Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 15:06:30 -0500 Subject: [PATCH 07/23] docstrings --- .../inscopixextractors/inscopiximagingextractor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index da6ecb95..0da600f0 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -8,9 +8,16 @@ class InscopixImagingExtractor(ImagingExtractor): + """Extracts imaging data from Inscopix recordings.""" extractor_name = "InscopixImaging" def __init__(self, file_path: PathType): + """ + Parameters + ---------- + file_path : PathType + Path to the Inscopix file. + """ import isx super().__init__(file_path=file_path) From 5820843b5b71095d9e6bd6d5db18509c3d9c3a7e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:06:40 +0000 Subject: [PATCH 08/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../extractors/inscopixextractors/inscopiximagingextractor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 0da600f0..84d65bee 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -9,6 +9,7 @@ class InscopixImagingExtractor(ImagingExtractor): """Extracts imaging data from Inscopix recordings.""" + extractor_name = "InscopixImaging" def __init__(self, file_path: PathType): From e11b7c61a701cc12d9e69b1cb3409fd9f27eed4b Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 15:08:21 -0500 Subject: [PATCH 09/23] rmv py3.8 --- .github/ISSUE_TEMPLATE/bug_report.yml | 5 +++-- .github/workflows/auto-publish.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index fa063e56..728ebd4f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -60,9 +60,10 @@ body: attributes: label: Python Version options: - - 3.7 - - 3.8 - 3.9 + - 3.10 + - 3.11 + - 3.12 validations: required: true - type: textarea diff --git a/.github/workflows/auto-publish.yml b/.github/workflows/auto-publish.yml index dd44b7fb..74860b92 100644 --- a/.github/workflows/auto-publish.yml +++ b/.github/workflows/auto-publish.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.8" + python-version: "3.9" - name: Install dependencies run: | python -m pip install --upgrade pip From 889b981deab8d05e9333a95fed700449c8022eab Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 15:18:21 -0500 Subject: [PATCH 10/23] add docstring to inscopix imaging extrator module --- .../extractors/inscopixextractors/inscopiximagingextractor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 84d65bee..1d527e23 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -1,3 +1,7 @@ +""" +Inscopix Imaging Extractor +""" + import warnings from typing import Optional, Tuple From 9271c144f4efcca461b8cd46d7a8b2c24b5effa5 Mon Sep 17 00:00:00 2001 From: bendichter Date: Tue, 23 Jan 2024 15:20:15 -0500 Subject: [PATCH 11/23] add docstring to inscopix imaging extrator module --- src/roiextractors/extractors/inscopixextractors/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/roiextractors/extractors/inscopixextractors/__init__.py b/src/roiextractors/extractors/inscopixextractors/__init__.py index c7850bbb..f2baff5c 100644 --- a/src/roiextractors/extractors/inscopixextractors/__init__.py +++ b/src/roiextractors/extractors/inscopixextractors/__init__.py @@ -1 +1,5 @@ +""" +Defines extactors for Inscopix data. +""" + from .inscopiximagingextractor import InscopixImagingExtractor From 5893bda62481be9971c6ef3fc56dd9c6aee786a6 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:34:25 -0400 Subject: [PATCH 12/23] Update requirements-full.txt --- requirements-full.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-full.txt b/requirements-full.txt index efb448f6..0ae2e497 100644 --- a/requirements-full.txt +++ b/requirements-full.txt @@ -2,4 +2,4 @@ tifffile>=2018.10.18 scanimage-tiff-reader==1.4.1 neuroconv[video]>=0.4.6 # Uses the VideoCaptureContext class natsort>=8.3.1 -isx +isx>=1.0.4 From f88bf0285cb8bf4739e37361709c73766aa27d37 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:37:55 -0400 Subject: [PATCH 13/23] Apply suggestions from code review --- src/roiextractors/extractors/inscopixextractors/__init__.py | 4 +--- .../extractors/inscopixextractors/inscopiximagingextractor.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/roiextractors/extractors/inscopixextractors/__init__.py b/src/roiextractors/extractors/inscopixextractors/__init__.py index f2baff5c..60c67ef7 100644 --- a/src/roiextractors/extractors/inscopixextractors/__init__.py +++ b/src/roiextractors/extractors/inscopixextractors/__init__.py @@ -1,5 +1,3 @@ -""" -Defines extactors for Inscopix data. -""" +"""Defines extactors for Inscopix data.""" from .inscopiximagingextractor import InscopixImagingExtractor diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 1d527e23..7022b84a 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -1,6 +1,4 @@ -""" -Inscopix Imaging Extractor -""" +"""Inscopix Imaging Extractor.""" import warnings from typing import Optional, Tuple From 947bffe80278194157095dce24915f1e0f6728e2 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:46:28 -0400 Subject: [PATCH 14/23] Update src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py --- .../extractors/inscopixextractors/inscopiximagingextractor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 7022b84a..18cd0550 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -16,6 +16,8 @@ class InscopixImagingExtractor(ImagingExtractor): def __init__(self, file_path: PathType): """ + Create an InscopixImagingExtractor instance from a single .isx file. + Parameters ---------- file_path : PathType From 8d135fe1607596e39dc0084832257eda2a91941e Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Wed, 1 May 2024 16:27:51 -0400 Subject: [PATCH 15/23] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fe901c..dc4aabe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ### Features +* Add InscopixSegmentationExtractor [#276](https://github.com/catalystneuro/roiextractors/pull/276) + ### Fixes -* Remove unecessary scipy import error handling [#315]((https://github.com/catalystneuro/roiextractors/pull/315) +* Remove unecessary scipy import error handling [#315](https://github.com/catalystneuro/roiextractors/pull/315) # v0.5.8 From 71eb4e0ea47e0377fbc43f9bb5f8954efc92b7d5 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 1 May 2024 22:35:41 -0400 Subject: [PATCH 16/23] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e012f71e..f62a0cd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Features -* Add InscopixSegmentationExtractor [#276](https://github.com/catalystneuro/roiextractors/pull/276) +* Add InscopixImagingExtractor [#276](https://github.com/catalystneuro/roiextractors/pull/276) ### Fixes From 5b4942ea7966887fcea8930f06b0a31dfed76e30 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 4 May 2024 18:14:29 -0500 Subject: [PATCH 17/23] fix tests --- tests/test_inscopiximagingextractor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 77d6b07b..009acb26 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -1,4 +1,7 @@ +import sys + import numpy as np +import pytest from numpy import dtype from numpy.testing import assert_array_equal @@ -7,39 +10,42 @@ from .setup_paths import OPHYS_DATA_PATH +@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_128x128x100_part1(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_128x128x100_part1.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 100 assert extractor.get_image_size() == (128, 128) - assert extractor.get_dtype() == dtype("float64") + assert extractor.get_dtype() == dtype("float32") assert extractor.get_sampling_frequency() == 10.0 assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 assert extractor.get_video().shape == (100, 128, 128) +@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_longer_than_3_min(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_longer_than_3_min.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 1248 assert extractor.get_image_size() == (33, 29) - assert extractor.get_dtype() == dtype("int64") + assert extractor.get_dtype() == dtype("uint64") np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 5.5563890139076415) assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 assert extractor.get_video().shape == (1248, 33, 29) +@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_u8(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_u8.isxd" extractor = InscopixImagingExtractor(file_path=file_path) assert extractor.get_num_frames() == 5 assert extractor.get_image_size() == (3, 4) - assert extractor.get_dtype() == dtype("int64") + assert extractor.get_dtype() == dtype("uint64") np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 20.0) assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 From 3ea5a6045e05b4322e106972680da9df99169ffa Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sat, 4 May 2024 18:21:31 -0500 Subject: [PATCH 18/23] fix types again --- tests/test_inscopiximagingextractor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 009acb26..0b08c5e3 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -31,7 +31,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): assert extractor.get_num_frames() == 1248 assert extractor.get_image_size() == (33, 29) - assert extractor.get_dtype() == dtype("uint64") + assert extractor.get_dtype() == dtype("int16") np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 5.5563890139076415) assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 @@ -45,7 +45,7 @@ def test_inscopiximagingextractor_movie_u8(): assert extractor.get_num_frames() == 5 assert extractor.get_image_size() == (3, 4) - assert extractor.get_dtype() == dtype("uint64") + assert extractor.get_dtype() == dtype("uint8") np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 20.0) assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 From b6bb9e0bffdaeb9a87a8517063ea9ccc89b525d1 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 6 May 2024 09:04:50 -0500 Subject: [PATCH 19/23] fix types again --- tests/test_inscopiximagingextractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 0b08c5e3..78a2c10e 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -31,7 +31,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): assert extractor.get_num_frames() == 1248 assert extractor.get_image_size() == (33, 29) - assert extractor.get_dtype() == dtype("int16") + assert extractor.get_dtype() == dtype("uint16") np.testing.assert_almost_equal(extractor.get_sampling_frequency(), 5.5563890139076415) assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 From 65375c8ce90a871ea1a0b3e7ff5237adfb730a13 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 12 May 2024 22:09:40 -0400 Subject: [PATCH 20/23] Update src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py Co-authored-by: Heberto Mayorquin --- .../extractors/inscopixextractors/inscopiximagingextractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 18cd0550..56011b2b 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -38,7 +38,7 @@ def get_num_frames(self) -> int: def get_sampling_frequency(self) -> float: return 1 / self.movie.timing.period.secs_float - def get_channel_names(self) -> list: + def get_channel_names(self) -> list[str]: warnings.warn("isx only supports single channel videos.") return ["channel_0"] From 2c9da327abfe8e04978f09c99b978590a9a03753 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 12 May 2024 21:23:11 -0500 Subject: [PATCH 21/23] add method for getting data type efficiently. Also add tests for each example that this fetched data type is the same as the data type of actual data --- .../inscopixextractors/inscopiximagingextractor.py | 3 +++ tests/test_inscopiximagingextractor.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py index 18cd0550..e2809bb6 100644 --- a/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py +++ b/src/roiextractors/extractors/inscopixextractors/inscopiximagingextractor.py @@ -52,3 +52,6 @@ def get_video( start_frame = start_frame or 0 end_frame = end_frame or self.get_num_frames() return np.array([self.movie.get_frame_data(i) for i in range(start_frame, end_frame)]) + + def get_dtype(self): + return self.movie.data_type diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 78a2c10e..0633eaff 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -7,7 +7,7 @@ from roiextractors import InscopixImagingExtractor -from .setup_paths import OPHYS_DATA_PATH +from tests.setup_paths import OPHYS_DATA_PATH @pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") @@ -22,6 +22,7 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 assert extractor.get_video().shape == (100, 128, 128) + assert extractor.get_frames(frame_idxs=[0], channel=0).dtype == extractor.get_dtype() @pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") @@ -36,6 +37,7 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 assert extractor.get_video().shape == (1248, 33, 29) + assert extractor.get_frames(frame_idxs=[0], channel=0).dtype == extractor.get_dtype() @pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") @@ -50,3 +52,4 @@ def test_inscopiximagingextractor_movie_u8(): assert extractor.get_channel_names() == ["channel_0"] assert extractor.get_num_channels() == 1 assert extractor.get_video().shape == (5, 3, 4) + assert extractor.get_frames(frame_idxs=[0], channel=0).dtype == extractor.get_dtype() From 40e9869e1a79fb55bffdf98da0a1a68234a07af7 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 12 May 2024 22:36:36 -0400 Subject: [PATCH 22/23] Update tests/test_inscopiximagingextractor.py Co-authored-by: Heberto Mayorquin --- tests/test_inscopiximagingextractor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 0633eaff..26c8b3a3 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -40,7 +40,6 @@ def test_inscopiximagingextractor_movie_longer_than_3_min(): assert extractor.get_frames(frame_idxs=[0], channel=0).dtype == extractor.get_dtype() -@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_u8(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_u8.isxd" extractor = InscopixImagingExtractor(file_path=file_path) From a41d30c48e6e4058eaf5a1530a2f26006580e731 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Sun, 12 May 2024 21:37:09 -0500 Subject: [PATCH 23/23] remove tests for Python 3.8 --- tests/test_inscopiximagingextractor.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_inscopiximagingextractor.py b/tests/test_inscopiximagingextractor.py index 26c8b3a3..fd2064b5 100644 --- a/tests/test_inscopiximagingextractor.py +++ b/tests/test_inscopiximagingextractor.py @@ -1,7 +1,4 @@ -import sys - import numpy as np -import pytest from numpy import dtype from numpy.testing import assert_array_equal @@ -10,7 +7,6 @@ from tests.setup_paths import OPHYS_DATA_PATH -@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_128x128x100_part1(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_128x128x100_part1.isxd" extractor = InscopixImagingExtractor(file_path=file_path) @@ -25,7 +21,6 @@ def test_inscopiximagingextractor_movie_128x128x100_part1(): assert extractor.get_frames(frame_idxs=[0], channel=0).dtype == extractor.get_dtype() -@pytest.mark.skipif(sys.version_info <= (3, 8), reason="Requires Python 3.9 or higher") def test_inscopiximagingextractor_movie_longer_than_3_min(): file_path = OPHYS_DATA_PATH / "imaging_datasets" / "inscopix" / "movie_longer_than_3_min.isxd" extractor = InscopixImagingExtractor(file_path=file_path)