Skip to content

Commit

Permalink
Add plot of ROI contours w/o IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-friedrich committed Oct 2, 2024
1 parent b4e5b06 commit eaf2534
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ of the _registered_ (or, in the case of multi-plane imaging, _decrosstalked_) mo
## Output

The main output is the `extraction.h5` file.
For QC, the figure `detected_ROIs.png` displays contours of the detected ROIs over a selection of summary images.
For QC, the figures `detected_ROIs.png` and `detected_ROIs_withIDs.png` display contours of the detected ROIs over a selection of summary images.
If the capsule is run with the `--contour_video` argument, a 10x sped-up video is also created, showing ROI contours overlaid on the raw data, along with ROI activity and the remainder.
<br>
The `extraction.h5` file contains three groups: `traces`, `rois`, and `cellpose`, with the latter only present if Cellpose is used for detection (--anatomical_only ≠ 0).
Expand Down
13 changes: 7 additions & 6 deletions code/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,22 +843,23 @@ def contour_video(
corr_img = max_corr_image(f["data"])
# plot
x_size = 8.5 * max(dims[1] / dims[0], 0.4)
plt.figure(figsize=(x_size, 3))
fix, ax = plt.subplots(1, 3, figsize=(x_size, 3))
for i, img in enumerate((ops["meanImg"], ops["max_proj"], corr_img)):
plt.subplot(1, 3, 1 + i)
vmin, vmax = np.nanpercentile(img, (1, 99))
plt.imshow(img, interpolation=None, cmap="gray", vmin=vmin, vmax=vmax)
ax[i].imshow(img, interpolation=None, cmap="gray", vmin=vmin, vmax=vmax)
for c in coordinates:
plt.plot(*c["coordinates"].T, c="orange")
for k in range(rois.shape[0]):
plt.text(*cm[k], str(k), color="orange")
ax[i].plot(*c["coordinates"].T, c="orange")
plt.axis("off")
plt.title(
("mean image", "max image", "correlation image")[i],
fontsize=min(12, 2.4 + 2 * x_size),
)
plt.tight_layout(pad=0.1)
plt.savefig(output_dir / "detected_ROIs.png", bbox_inches="tight", pad_inches=0.02)
for i in (0, 1, 2):
for k in range(rois.shape[0]):
ax[i].text(*cm[k], str(k), color="orange")
plt.savefig(output_dir / "detected_ROIs_withIDs.png", bbox_inches="tight", pad_inches=0.02)

if args.contour_video:
with h5py.File(str(motion_corrected_fn), "r") as f:
Expand Down

0 comments on commit eaf2534

Please sign in to comment.