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

zarr file for testing #1

Open
stevejpurves opened this issue Jun 7, 2024 · 2 comments
Open

zarr file for testing #1

stevejpurves opened this issue Jun 7, 2024 · 2 comments

Comments

@stevejpurves
Copy link
Member

@PaulHax do you have a url to a public suitable zarr file for testing this?
https://github.com/curvenote/itk-plugins/blob/main/site/paper.md

@stevejpurves
Copy link
Member Author

stevejpurves commented Jun 7, 2024

I'm out of time for now but we just need to implement the react component, probably loading unsafe html etc... then I can test it in the scipy proceedings theme in local dev using one or more test images.

the target build is a remix/react site, we can handle ESM modules in the build or dynamically on a client side async import but looking at the example you pointed to I'm not sure how to approach that. is there a bundled version of the itk-viewer-2d module that could be loaded in the client?

@PaulHax
Copy link
Contributor

PaulHax commented Jun 7, 2024

@itk-viewer/element npm package has ESM modules, including itk-viewer-2d.js. Guessing there are a few rough edges to getting our viewer bundled and running in a Remix app. I'll work on an example with the viewer in a minimal CRA Remix app.

A CORS enabled Zarr image is here:
https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.3/idr0079A/9836998.zarr

And another Zarr image is checked in to the paper PR:
scipy-conference/scipy_proceedings#927

This is a naive React compnenet I have not tested

import { useEffect, useRef } from "react";
import { ItkViewer2d } from "@itk-viewer/element/itk-viewer-2d.js";
import "@itk-viewer/element/itk-viewer-2d.js";
import { ZarrMultiscaleSpatialImage } from "@itk-viewer/io/ZarrMultiscaleSpatialImage.js";

export function Viewer({ imagePath }: { imagePath: string }) {
  const viewer = useRef<ItkViewer2d>(null);

  useEffect(() => {
    const element = viewer.current;
    if (!element) {
      return;
    }
    const actor = element.getActor();
    const url = new URL(imagePath, document.location.origin);
    ZarrMultiscaleSpatialImage.fromUrl(url).then((image) => {
      actor!.send({ type: "setImage", image, name: "image" });
    });
  }, [imagePath, viewer]);

  return (
    <div>
      <itk-viewer-2d ref={viewer}></itk-viewer-2d>
    </div>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants