Skip to content

Commit

Permalink
Merge pull request #177 from kushalbakshi/main
Browse files Browse the repository at this point in the history
Updates to package requirements + formatting with `black`
  • Loading branch information
Thinh Nguyen authored Jan 29, 2024
2 parents 63ef0c9 + 012124e commit b6b4b69
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 110 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
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
Expand Down Expand Up @@ -190,6 +196,7 @@ 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
Expand Down
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
58 changes: 34 additions & 24 deletions element_calcium_imaging/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,30 +1031,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
58 changes: 34 additions & 24 deletions element_calcium_imaging/imaging_no_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,30 +958,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
58 changes: 34 additions & 24 deletions element_calcium_imaging/imaging_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,30 +1244,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
74 changes: 45 additions & 29 deletions element_calcium_imaging/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,21 @@ def make(self, key):
px_width=scan.field_widths[field_id],
um_height=scan.field_heights_in_microns[field_id],
um_width=scan.field_widths_in_microns[field_id],
field_x=x_zero
+ scan._degrees_to_microns(scan.fields[field_id].x)
if x_zero
else None,
field_y=y_zero
+ scan._degrees_to_microns(scan.fields[field_id].y)
if y_zero
else None,
field_z=z_zero + scan.fields[field_id].depth
if z_zero
else None,
field_x=(
x_zero
+ scan._degrees_to_microns(scan.fields[field_id].x)
if x_zero
else None
),
field_y=(
y_zero
+ scan._degrees_to_microns(scan.fields[field_id].y)
if y_zero
else None
),
field_z=(
z_zero + scan.fields[field_id].depth if z_zero else None
),
delay_image=scan.field_offsets[field_id],
roi=scan.field_rois[field_id][0],
)
Expand All @@ -359,9 +363,11 @@ def make(self, key):
um_width=getattr(scan, "image_width_in_microns", None),
field_x=x_zero if x_zero else None,
field_y=y_zero if y_zero else None,
field_z=z_zero + scan.scanning_depths[plane_idx]
if z_zero
else None,
field_z=(
z_zero + scan.scanning_depths[plane_idx]
if z_zero
else None
),
delay_image=scan.field_offsets[plane_idx],
)
for plane_idx in range(scan.num_scanning_depths)
Expand All @@ -387,9 +393,11 @@ def make(self, key):
self.insert1(
dict(
key,
nfields=sbx_meta["num_fields"]
if is_multiROI
else sbx_meta["num_planes"],
nfields=(
sbx_meta["num_fields"]
if is_multiROI
else sbx_meta["num_planes"]
),
nchannels=sbx_meta["num_channels"],
nframes=sbx_meta["num_frames"],
ndepths=sbx_meta["num_planes"],
Expand All @@ -412,12 +420,16 @@ def make(self, key):
field_idx=plane_idx,
px_height=px_height,
px_width=px_width,
um_height=px_height * sbx_meta["um_per_pixel_y"]
if sbx_meta["um_per_pixel_y"]
else None,
um_width=px_width * sbx_meta["um_per_pixel_x"]
if sbx_meta["um_per_pixel_x"]
else None,
um_height=(
px_height * sbx_meta["um_per_pixel_y"]
if sbx_meta["um_per_pixel_y"]
else None
),
um_width=(
px_width * sbx_meta["um_per_pixel_x"]
if sbx_meta["um_per_pixel_x"]
else None
),
field_x=x_zero,
field_y=y_zero,
field_z=z_zero + sbx_meta["etl_pos"][plane_idx],
Expand Down Expand Up @@ -462,9 +474,11 @@ def estimate_nd2_scan_duration(nd2_scan_obj):
scan_datetime = nd2_file.text_info["date"]
scan_datetime = datetime.strptime(
scan_datetime,
"%m/%d/%Y %H:%M:%S %p"
if re.search(("AM|PM"), scan_datetime)
else "%m/%d/%Y %H:%M:%S",
(
"%m/%d/%Y %H:%M:%S %p"
if re.search(("AM|PM"), scan_datetime)
else "%m/%d/%Y %H:%M:%S"
),
)
scan_datetime = datetime.strftime(scan_datetime, "%Y-%m-%d %H:%M:%S")
except: # noqa: E722
Expand Down Expand Up @@ -551,9 +565,11 @@ def estimate_nd2_scan_duration(nd2_scan_obj):
um_width=PVScan_info["width_in_um"],
field_x=PVScan_info["fieldX"],
field_y=PVScan_info["fieldY"],
field_z=PVScan_info["fieldZ"]
if PVScan_info["num_planes"] == 1
else PVScan_info["fieldZ"][plane_idx],
field_z=(
PVScan_info["fieldZ"]
if PVScan_info["num_planes"] == 1
else PVScan_info["fieldZ"][plane_idx]
),
)
for plane_idx in range(PVScan_info["num_planes"])
)
Expand Down
3 changes: 2 additions & 1 deletion element_calcium_imaging/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Package metadata."""
__version__ = "0.9.2"

__version__ = "0.9.3"
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
"ipykernel>=6.0.1",
"ipywidgets",
"plotly",
"element-interface @ git+https://github.com/datajoint/element-interface.git",
],
extras_require={
"caiman_requirements": [caiman_requirements],
"caiman": ["caiman @ git+https://github.com/datajoint/CaImAn.git"],
"elements": [
"element-animal>=0.1.8",
"element-event>=0.2.3",
"element-interface>=0.6.0",
"element-lab>=0.3.0",
"element-session>=0.1.5",
"element-animal @ git+https://github.com/datajoint/element-animal.git",
"element-event @ git+https://github.com/datajoint/element-event.git",
"element-lab @ git+https://github.com/datajoint/element-lab.git",
"element-session @ git+https://github.com/datajoint/element-session.git",
],
"extract": ["matlabengine", "scipy"],
"nd2": ["nd2"],
Expand Down

0 comments on commit b6b4b69

Please sign in to comment.