Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull from main #181

Merged
merged 12 commits into from
Feb 1, 2024
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"editor.rulers": [
88
],
"python.formatting.provider": "black",
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": null
"editor.defaultFormatter": "ms-python.black-formatter"
},
"[markdown]": {
"editor.defaultFormatter": "disable"
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.9.3] - 2024-01-29

+ Update - DataJoint Elements to install from GitHub instead of PyPI
+ Fix - `element-interface` required during package installation
+ Fix - apply formatting with `black` across the repository

## [0.9.2] - 2024-01-10

+ Fix - Imports and attribute values in notebooks to resolve DataJoint errors

## [0.9.1] - 2023-12-19

+ Update - Tutorial notebook
+ Fix - minor fixes in `setup.py` and `README`

## [0.9.0] - 2023-10-13

+ Add - Export to NWB and upload to DANDI
Expand Down Expand Up @@ -181,6 +196,10 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
+ Add - `scan` and `imaging` modules
+ Add - Readers for `ScanImage`, `ScanBox`, `Suite2p`, `CaImAn`

[0.9.3]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.9.3
[0.9.2]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.9.2
[0.9.1]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.9.1
[0.9.0]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.9.0
[0.8.1]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.8.1
[0.8.0]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.8.0
[0.7.9]: https://github.com/datajoint/element-calcium-imaging/releases/tag/0.7.9
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ documentation page.
+ Clone the repository to your computer

```bash
git clone https://github.com/<enter_github_username>/element-calcium-imaging
git clone https://github.com/<enter_github_username>/element-calcium-imaging.git
```

+ Install with `pip`
Expand Down
3 changes: 1 addition & 2 deletions docs/src/.overrides/assets/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ html a[title="YouTube"].md-social__link svg {
/* --md-footer-fg-color: var(--dj-white); */
}

[data-md-color-scheme="slate"] td,
th {
[data-md-color-scheme="slate"] .jupyter-wrapper .Table Td {
color: var(--dj-black)
}
8 changes: 5 additions & 3 deletions element_calcium_imaging/export/nwb/nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ def _add_scan_to_nwb(session_key, nwbfile):
name="ImagingPlane",
optical_channel=optical_channel,
imaging_rate=frame_rate,
description=scan_notes
if scan_notes != ""
else f"Imaging plane for field {field_no+1}, channel {channel+1}",
description=(
scan_notes
if scan_notes != ""
else f"Imaging plane for field {field_no+1}, channel {channel+1}"
),
device=device,
excitation_lambda=nan,
indicator="unknown",
Expand Down
64 changes: 35 additions & 29 deletions element_calcium_imaging/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,9 @@ def infer_output_dir(cls, key, relative=False, mkdir=False):
e.g.: sub4/sess1/scan0/suite2p_0
"""
acq_software = (scan.Scan & key).fetch1("acq_software")
filetypes = dict(
ScanImage="*.tif", Scanbox="*.sbx", NIS="*.nd2", PrairieView="*.tif"
)

scan_dir = find_full_path(
get_imaging_root_data_dir(),
get_calcium_imaging_files(key, filetypes[acq_software])[0],
get_calcium_imaging_files(key, acq_software)[0],
).parent
root_dir = find_root_directory(get_imaging_root_data_dir(), scan_dir)

Expand Down Expand Up @@ -1031,30 +1027,40 @@ def make(self, key):
}
for fkey, ref_image, ave_img, corr_img, max_img in zip(
field_keys,
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["average_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
],
(
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["average_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
]
),
)
]
self.Summary.insert(summary_images)
Expand Down
69 changes: 38 additions & 31 deletions element_calcium_imaging/imaging_no_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,9 @@ def infer_output_dir(cls, key, relative=False, mkdir=False):
e.g.: sub4/sess1/scan0/suite2p_0
"""
acq_software = (scan.Scan & key).fetch1("acq_software")
filetypes = dict(
ScanImage="*.tif", Scanbox="*.sbx", NIS="*.nd2", PrairieView="*.tif"
)

scan_dir = find_full_path(
get_imaging_root_data_dir(),
get_calcium_imaging_files(key, filetypes[acq_software])[0],
get_calcium_imaging_files(key, acq_software)[0],
).parent
root_dir = find_root_directory(get_imaging_root_data_dir(), scan_dir)

Expand Down Expand Up @@ -369,6 +365,7 @@ def make(self, key):
task_mode, output_dir = (ProcessingTask & key).fetch1(
"task_mode", "processing_output_dir"
)
acq_software = (scan.Scan & key).fetch1("acq_software")

if not output_dir:
output_dir = ProcessingTask.infer_output_dir(key, relative=True, mkdir=True)
Expand Down Expand Up @@ -452,8 +449,8 @@ def make(self, key):
"Caiman pipeline is not yet capable of analyzing 3D scans."
)

# handle multi-channel tiff image before running CaImAn
if nchannels > 1:
if acq_software == "ScanImage" and nchannels > 1:
# handle multi-channel tiff image before running CaImAn
channel_idx = caiman_params.get("channel_to_process", 0)
tmp_dir = pathlib.Path(output_dir) / "channel_separated_tif"
tmp_dir.mkdir(exist_ok=True)
Expand Down Expand Up @@ -958,30 +955,40 @@ def make(self, key):
}
for fkey, ref_image, ave_img, corr_img, max_img in zip(
field_keys,
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["average_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
],
(
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["average_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
]
),
)
]
self.Summary.insert(summary_images)
Expand Down
64 changes: 35 additions & 29 deletions element_calcium_imaging/imaging_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,9 @@ def infer_output_dir(cls, key, relative=False, mkdir=False):
e.g.: sub4/sess1/scan0/suite2p_0
"""
acq_software = (scan.Scan & key).fetch1("acq_software")
filetypes = dict(
ScanImage="*.tif", Scanbox="*.sbx", NIS="*.nd2", PrairieView="*.tif"
)

scan_dir = find_full_path(
get_imaging_root_data_dir(),
get_calcium_imaging_files(key, filetypes[acq_software])[0],
get_calcium_imaging_files(key, acq_software)[0],
).parent
root_dir = find_root_directory(get_imaging_root_data_dir(), scan_dir)

Expand Down Expand Up @@ -1244,30 +1240,40 @@ def make(self, key):
}
for fkey, ref_image, ave_img, corr_img, max_img in zip(
field_keys,
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["average_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
],
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
],
(
caiman_dataset.motion_correction["reference_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["reference_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["average_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["average_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["correlation_image"].transpose(
2, 0, 1
)
if is3D
else caiman_dataset.motion_correction["correlation_image"][...][
np.newaxis, ...
]
),
(
caiman_dataset.motion_correction["max_image"].transpose(2, 0, 1)
if is3D
else caiman_dataset.motion_correction["max_image"][...][
np.newaxis, ...
]
),
)
]
self.Summary.insert(summary_images)
Expand Down
Loading
Loading