Skip to content

Commit d7e8004

Browse files
author
Thinh Nguyen
authored
Merge pull request #158 from kabilar/main
Update `get_calcium_imaging_files` and installation instructions
2 parents 953019b + 797e8ad commit d7e8004

File tree

10 files changed

+64
-34
lines changed

10 files changed

+64
-34
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN \
2222
apt-get install sudo git bash-completion graphviz default-mysql-client s3fs procps -y && \
2323
usermod -aG sudo vscode && \
2424
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
25-
pip install --no-cache-dir --upgrade black pip && \
25+
pip install --no-cache-dir --upgrade black pip nbconvert && \
2626
echo '. /etc/bash_completion' >> /home/vscode/.bashrc && \
2727
echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /home/vscode/.bashrc && \
2828
apt-get clean
@@ -32,8 +32,9 @@ COPY ./ /tmp/element-calcium-imaging/
3232
RUN \
3333
# pipeline dependencies
3434
apt-get install gcc g++ ffmpeg libsm6 libxext6 -y && \
35-
pip install --no-cache-dir -e /tmp/element-calcium-imaging[caiman_requirements] && \
36-
pip install --no-cache-dir -e /tmp/element-calcium-imaging[caiman,elements,nd2,sbxreader,scanreader,suite2p,tests] && \
35+
# pip install --no-cache-dir -e /tmp/element-calcium-imaging[caiman_requirements] && \
36+
# pip install --no-cache-dir -e /tmp/element-calcium-imaging[caiman] && \
37+
pip install --no-cache-dir -e /tmp/element-calcium-imaging[elements,nd2,sbxreader,scanreader,suite2p,tests] && \
3738
# clean up
3839
rm -rf /tmp/element-calcium-imaging && \
3940
apt-get clean

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
44
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
55

6+
## [0.8.0] - 2023-08-08
7+
8+
+ Update - Rename `get_image_files` to `get_calcium_imaging_files`, and update arguments
9+
+ Update - Remove CaImAn installation from the Dev Container due to memory limits of a free GitHub Codespace account
10+
+ Update - Installation instructions
11+
612
## [0.7.9] - 2023-07-27
713

814
+ Update - GitHub Actions to run every Monday at 8am
@@ -167,6 +173,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
167173
+ Add - `scan` and `imaging` modules
168174
+ Add - Readers for `ScanImage`, `ScanBox`, `Suite2p`, `CaImAn`
169175

176+
[0.8.0]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.8.0
170177
[0.7.9]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.7.9
171178
[0.7.8]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.7.8
172179
[0.7.7]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.7.7

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![PyPI version](https://badge.fury.io/py/element-calcium-imaging.svg)](http://badge.fury.io/py/element-calcium-imaging)
2-
31
# DataJoint Element for Functional Calcium Imaging
42

53
DataJoint Element for functional calcium imaging with
@@ -32,11 +30,19 @@ documentation page.
3230

3331
## Getting Started
3432

35-
+ Install from PyPI
33+
+ Please fork this repository
34+
35+
+ Clone the repository to your computer
36+
37+
```bash
38+
git clone https://github.com/<enter_github_username>/element-calcium-imaging
39+
```
40+
41+
+ Install with `pip`
3642

37-
```bash
38-
pip install element-calcium-imaging
39-
```
43+
```bash
44+
pip install -e .
45+
```
4046

4147
+ [Interactive tutorial on GitHub Codespaces](#interactive-tutorial)
4248

docs/src/index.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ schemas can be found in the [Data Pipeline](./pipeline.md) documentation page.
2727

2828
## Getting Started
2929

30-
+ Install from PyPI
30+
+ Please fork the [repository](https://github.com/datajoint/element-calcium-imaging){:target="_blank"}
3131

32-
```bash
33-
pip install element-calcium-imaging
34-
```
32+
+ Clone the repository to your computer
33+
34+
```bash
35+
git clone https://github.com/<enter_github_username>/element-calcium-imaging
36+
```
37+
38+
+ Install with `pip`
39+
40+
```bash
41+
pip install -e .
42+
```
3543

3644
+ [Data Pipeline](./pipeline.md) - Pipeline and table descriptions
3745

element_calcium_imaging/imaging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from . import imaging_report, scan
1111
from .scan import (
12-
get_image_files,
12+
get_calcium_imaging_files,
1313
get_imaging_root_data_dir,
1414
get_processed_root_data_dir,
1515
)

element_calcium_imaging/imaging_no_curation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from . import imaging_report, scan
1111
from .scan import (
12-
get_image_files,
12+
get_calcium_imaging_files,
1313
get_imaging_root_data_dir,
1414
get_processed_root_data_dir,
1515
)

element_calcium_imaging/imaging_preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from . import imaging_report, scan
1111
from .scan import (
12-
get_image_files,
12+
get_calcium_imaging_files,
1313
get_imaging_root_data_dir,
1414
get_processed_root_data_dir,
1515
)

element_calcium_imaging/scan.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,17 @@ def get_processed_root_data_dir() -> Union[str, pathlib.Path]:
104104
return get_imaging_root_data_dir()[0]
105105

106106

107-
def get_image_files(scan_key: dict, file_type: str) -> list:
108-
"""Retrieve the list of image files associated with a given Scan.
107+
def get_calcium_imaging_files(scan_key: dict, acq_software: str) -> list:
108+
"""Retrieve the list of absolute paths of the calcium imaging files associated with a given Scan and a given acquisition software (e.g. .tif, .sbx, etc.).
109109
110110
Args:
111111
scan_key: Primary key of a Scan entry.
112+
acq_software: name of the acquisition software, matching AcquisitionSoftware entry (i.e. "ScanImage" "Scanbox", "NIS", or "PrairieView")
112113
113114
Returns:
114115
A list of full file paths.
115116
"""
116-
return _linking_module.get_image_files(scan_key, file_type)
117+
return _linking_module.get_calcium_imaging_files(scan_key, acq_software)
117118

118119

119120
# ----------------------------- Table declarations ----------------------
@@ -289,12 +290,12 @@ def make(self, key):
289290
"""Populate the ScanInfo with the information parsed from image files."""
290291

291292
acq_software = (Scan & key).fetch1("acq_software")
293+
scan_filepaths = get_calcium_imaging_files(key, acq_software)
292294

293295
if acq_software == "ScanImage":
294296
import scanreader
295297

296298
# Read the scan
297-
scan_filepaths = get_image_files(key, "*.tif")
298299
scan = scanreader.read_scan(scan_filepaths)
299300

300301
# Insert in ScanInfo
@@ -370,7 +371,6 @@ def make(self, key):
370371
import sbxreader
371372

372373
# Read the scan
373-
scan_filepaths = get_image_files(key, "*.sbx")
374374
sbx_meta = sbxreader.sbx_get_metadata(scan_filepaths[0])
375375
sbx_matinfo = sbxreader.sbx_get_info(scan_filepaths[0])
376376
is_multiROI = bool(
@@ -429,7 +429,6 @@ def make(self, key):
429429
import nd2
430430

431431
# Read the scan
432-
scan_filepaths = get_image_files(key, "*.nd2")
433432
nd2_file = nd2.ND2File(scan_filepaths[0])
434433
is_multiROI = False # MultiROI to be implemented later
435434

@@ -519,7 +518,6 @@ def estimate_nd2_scan_duration(nd2_scan_obj):
519518
elif acq_software == "PrairieView":
520519
from element_interface import prairie_view_loader
521520

522-
scan_filepaths = get_image_files(key, "*.tif")
523521
PVScan_info = prairie_view_loader.get_prairieview_metadata(
524522
scan_filepaths[0]
525523
)
@@ -612,30 +610,31 @@ def make(self, key):
612610
acq_software, nchannels = (Scan * ScanInfo & key).fetch1(
613611
"acq_software", "nchannels"
614612
)
613+
scan_filepaths = get_calcium_imaging_files(key, acq_software)
615614

616615
if acq_software == "ScanImage":
617616
import scanreader
618617

619618
# Switch from FYXCT to TCYX
620-
data = scanreader.read_scan(get_image_files(key, "*.tif"))[
621-
key["field_idx"]
622-
].transpose(3, 2, 0, 1)
619+
data = scanreader.read_scan(scan_filepaths)[key["field_idx"]].transpose(
620+
3, 2, 0, 1
621+
)
623622
elif acq_software == "Scanbox":
624623
from sbxreader import sbx_memmap
625624

626625
# Switch from TFCYX to TCYX
627-
data = sbx_memmap(get_image_files(key, "*.sbx"))[:, key["field_idx"]]
626+
data = sbx_memmap(scan_filepaths)[:, key["field_idx"]]
628627
elif acq_software == "NIS":
629628
import nd2
630629

631-
nd2_file = nd2.ND2File(get_image_files(key, "*.nd2")[0])
630+
nd2_file = nd2.ND2File(scan_filepaths[0])
632631

633632
nd2_dims = {k: i for i, k in enumerate(nd2_file.sizes)}
634633

635634
valid_dimensions = "TZCYX"
636635
assert set(nd2_dims) <= set(
637636
valid_dimensions
638-
), f"Unknown dimensions {set(nd2_dims)-set(valid_dimensions)} in file {get_image_files(key, '*.nd2')[0]}."
637+
), f"Unknown dimensions {set(nd2_dims)-set(valid_dimensions)} in file {scan_filepaths[0]}."
639638

640639
# Sort the dimensions in the order of TZCYX, skipping the missing ones.
641640
data = nd2_file.asarray().transpose(

element_calcium_imaging/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package metadata."""
2-
__version__ = "0.7.9"
2+
__version__ = "0.8.0"

notebooks/tutorial_pipeline.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,27 @@ def get_imaging_root_data_dir():
2626
raise TypeError("`imaging_root_data_dir` must be a string, pathlib, or list")
2727

2828

29-
def get_image_files(scan_key, file_type: str):
30-
"""Retrieve the list of absolute paths associated with a given Scan."""
29+
def get_calcium_imaging_files(scan_key, acq_software: str):
30+
"""Retrieve the list of absolute paths of the calcium imaging files associated with a given Scan and a given acquisition software (e.g. "ScanImage", "PrairieView", etc.)."""
3131
# Folder structure: root / subject / session / .tif or .sbx or .nd2
3232
session_dir = element_interface.utils.find_full_path(
3333
get_imaging_root_data_dir(),
3434
(session.SessionDirectory & scan_key).fetch1("session_dir"),
3535
)
3636

37-
filepaths = [fp.as_posix() for fp in session_dir.glob(file_type)]
37+
if acq_software == "ScanImage":
38+
filepaths = [fp.as_posix() for fp in session_dir.glob("*.tif")]
39+
elif acq_software == "Scanbox":
40+
filepaths = [fp.as_posix() for fp in session_dir.glob("*.sbx")]
41+
elif acq_software == "NIS":
42+
filepaths = [fp.as_posix() for fp in session_dir.glob("*.nd2")]
43+
elif acq_software == "PrairieView":
44+
filepaths = [fp.as_posix() for fp in session_dir.glob("*.tif")]
45+
else:
46+
raise NotImplementedError(f"{acq_software} is not implemented")
3847

3948
if not filepaths:
40-
raise FileNotFoundError(f"No {file_type} file found in {session_dir}")
49+
raise FileNotFoundError(f"No {acq_software} file found in {session_dir}")
4150
return filepaths
4251

4352

0 commit comments

Comments
 (0)