Skip to content

Commit e00ceca

Browse files
brunoboivinNosheen Adil
and
Nosheen Adil
authored
IT-1137: enforce movie data type (#52)
* IT-1137 generalize author/email info * IT-1137 ignore IDE config files * IT-1137 fix movie data type inconsistency * IT-1137 add missing maintainers info * fixes for testing --------- Co-authored-by: Nosheen Adil <[email protected]>
1 parent a6c7580 commit e00ceca

File tree

8 files changed

+24
-22
lines changed

8 files changed

+24
-22
lines changed

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# data
2-
31
# secrets
42
.ideas-github-token
53

6-
74
# IDE
85
*.sublime-workspace
96
*.sublime-project
107
.vscode/
11-
8+
.idea/
129

1310
poetry.lock
1411

Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ jupyter:
1111
install-poetry:
1212
@bash install-poetry.sh
1313

14-
test:
14+
install: install-poetry
15+
@echo "Installing py_isx..."
16+
poetry check --lock || poetry lock
17+
poetry install --verbose
18+
19+
install-test: install-poetry
20+
@echo "Installing py_isx & dependencies for testing..."
21+
poetry check --lock || poetry lock
22+
poetry install --extras "test" --verbose
23+
24+
test: install-test
1525
poetry run pytest -sx --failed-first
1626

1727
test-pip:

install-poetry.sh

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ then
33
echo "poetry could not be found, installing..."
44
curl -sSL https://install.python-poetry.org | python3 -
55
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bash_profile
6-
# tell git to use SSH to get code
7-
git config --global url.ssh://[email protected]/.insteadOf https://github.com/
86
exit
97
fi

isx/__init__.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,10 @@ def get_frame_data(self, index: int):
180180

181181
if self.footer["dataType"] == 0:
182182
bytes_per_pixel = 2
183-
format_string = "H"
184183
elif self.footer["dataType"] == 1:
185184
bytes_per_pixel = 4
186-
format_string = "f"
187185
elif self.footer["dataType"] == 2:
188186
bytes_per_pixel = 1
189-
format_string = "b"
190187
else:
191188
raise NotImplementedError(
192189
"Unknown number of bytes per pixel. Cannot decode this frame."
@@ -213,10 +210,8 @@ def get_frame_data(self, index: int):
213210

214211
with open(self.file_path, mode="rb") as file:
215212
file.seek(index * n_bytes_per_frame)
216-
217213
data = file.read(bytes_per_pixel * n_pixels)
218-
219-
frame = struct.unpack(format_string * n_pixels, data)
214+
frame = np.frombuffer(data, dtype=self.data_type)
220215
frame = np.reshape(frame, self.spacing.num_pixels)
221216

222217
return frame
@@ -374,11 +369,11 @@ def isxd_type(file_path: str) -> str:
374369
isx_datatype_mapping = {
375370
0: "miniscope_movie",
376371
1: "cell_set",
377-
2: "isxd_behavioral_movie", # not currently supported on IDEAS
372+
2: "isxd_behavioral_movie",
378373
3: "gpio_data",
379374
4: "miniscope_image",
380375
5: "neural_events",
381-
6: "isxd_metrics", # not currently supported on IDEAS
376+
6: "isxd_metrics",
382377
7: "imu_data",
383378
8: "vessel_set",
384379
}

mkdocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
site_name: Python API for Inscopix Data
2-
site_author: Srinivas Gorur-Shandilya, Zachary Ip
2+
site_author: Inscopix, Inc.
33
repo_url: https://github.com/inscopix/py_isx
44
repo_name: inscopix/py_isx
55
site_url: https://inscopix.github.io/py_isx/

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
name = "isx"
55
version = "0.0.0.dev"
66
description = "Python-based ISXD file reader"
7-
authors = ["Srinivas Gorur-Shandilya <[email protected]>", "Zachary Ip <Zachary.Ip@bruker.com>"]
8-
maintainers = ["Zachary Ip <Zachary.Ip@bruker.com>"]
7+
authors = ["Inscopix, Inc. <support@inscopix.com>"]
8+
maintainers = ["Inscopix, Inc. <support@inscopix.com>"]
99
readme = "README.md"
1010
license = "CC-BY-NC-4.0"
1111
homepage = "https://github.com/inscopix/py_isx"

setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
'version': '0.0.0.dev0',
3232
'description': 'Python-based ISXD file reader',
3333
'long_description': '# isx: pure-python API to read Inscopix data\n\n![](https://github.com/inscopix/py_isx/actions/workflows/main.yml/badge.svg) \n![](https://img.shields.io/pypi/v/isx)\n\nThis is a pure-python API to read Inscopix ISXD files. \n\n\n## Documentation\n\n[Read the documentation](https://inscopix.github.io/py_isx/)\n\n## Support\n\n| File type | Support |\n| --------- | ------- |\n| ISXD CellSet | ✅ |\n| ISXD Movie | ✅ |\n| ISXD Movie (multi-plane) | ❌ |\n| ISXD Movie (dual-color) | ❌ |\n| GPIO data | ❌ |\n| ISXD Events | ❌ |\n| ISXD VesselSet | ❌ |\n\n\n## Install\n\n### Poetry\n\n```bash\npoetry add isx\n```\n\n### pip\n\n\n```bash\npip install isx\n```\n\n## Caution\n\nThis is a work in progress, and all reading functions in the IDPS Python API are not supported yet. \n\n\n## Testing\n\nThis code is tested using GitHub Actions on the following python\nversions:\n\n- 3.9\n- 3.10\n- 3.11\n- 3.12\n',
34-
'author': 'Srinivas Gorur-Shandilya',
35-
'author_email': 's.gorur_shandilya@bruker.com',
36-
'maintainer': 'Zachary Ip',
37-
'maintainer_email': 'Zachary.Ip@bruker.com',
34+
'author': 'Inscopix, Inc.',
35+
'author_email': 'support@inscopix.com',
36+
'maintainer': 'Inscopix, Inc.',
37+
'maintainer_email': 'support@inscopix.com',
3838
'url': 'https://github.com/inscopix/py_isx',
3939
'packages': packages,
4040
'package_data': package_data,

tests/test_isx.py

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ def test_movie_data_type(item):
174174
movie.data_type == item["dtype"]
175175
), f"Could not correctly read data type of movie {movie_name}"
176176

177+
assert movie.data_type == movie.get_frame_data(0).dtype
178+
177179

178180
@pytest.mark.parametrize("item", movie_info)
179181
def test_movie_num_pixels(item):

0 commit comments

Comments
 (0)