Skip to content

Commit

Permalink
fail early
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jul 23, 2024
1 parent 0650b1f commit 041ccd0
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
@app.default
def render_umap_png(input_hdf5: Path, output_png: Path) -> None:
image = MultiChannelImage.read_hdf5(path=input_hdf5)
values_cluster = image.data_flat.sel(c="cluster").values.ravel()
values_image_id = image.data_flat.sel(c="image_index").values.ravel()

# TODO use UMAP(random_state=...) but this will prevent parallelization
umap = UMAP().fit_transform(image.data_flat.drop_sel(c="cluster").values.T)

fig, axs = plt.subplots(1, 2, figsize=(10, 5))

axs[0].scatter(umap[:, 0], umap[:, 1], c=image.data_flat.sel(c="cluster").values.ravel(), s=1, cmap="tab10")
axs[0].scatter(umap[:, 0], umap[:, 1], c=values_cluster, s=1, cmap="tab10")
axs[0].axis("off")
axs[0].set_title("Clusters")

axs[1].scatter(umap[:, 0], umap[:, 1], c=image.data_flat.sel(c="image_index").values.ravel(), s=1, cmap="tab10")
axs[1].scatter(umap[:, 0], umap[:, 1], c=values_image_id, s=1, cmap="tab10")
axs[1].axis("off")
axs[1].set_title("Image IDs")

Expand Down

0 comments on commit 041ccd0

Please sign in to comment.