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

Accessing original data from SciView #607

Open
odinsbane opened this issue Sep 24, 2024 · 0 comments
Open

Accessing original data from SciView #607

odinsbane opened this issue Sep 24, 2024 · 0 comments

Comments

@odinsbane
Copy link

odinsbane commented Sep 24, 2024

My example is using marching cubes, I have a volume-time series shown in sciview and I want to perform the marching cubes algorithm on it.

Right now it is using the Volume#getMetaData() to get the original RandomAccessibleInterval it would be good if there was a way that doesn't involve using a magic key.

The next problem is the marching cubes algorithm will use the first time point. So my idea was to use Volume#getCurrentTimepoint() then create a shifted view.

I think there are two issues here.

  • How to access the original data source as an RandomAccessibleInterval/Img

    public RandomAccessibleInterval<?> getOriginalRandomAccessibleInterval()

  • How to access the data used for the currently rendered volume.

    public InternalInterval<?> getCurrentView();

@Override
    public void run() {
        Node active = sciView.getActiveNode();
        Volume v;
        if(active instanceof Volume) {
            v = (Volume)active;
            Img<UnsignedByteType> img = (Img<UnsignedByteType>)v.getMetadata().get("RandomAccessibleInterval");
            int tp = v.getCurrentTimepoint();

            IntervalView<UnsignedByteType> view = Views.hyperSlice(img, 3, tp);
            Mesh meshes = MarchingCubesRealType.calculate(view, 1);
            meshes = RemoveDuplicateVertices.calculate(meshes, 0);
            Group g = new Group(  );
            g.setName("meshes-at:" + tp);
            for(Map.Entry<String, Object> entry : v.getMetadata().entrySet()){
                System.out.println(entry.getKey() + ", " + entry.getValue());
            }
            for(Mesh m : MeshConnectedComponents.iterable(meshes)){
                graphics.scenery.Mesh ready = MarchingCubesCheck.convert(m);
                ready.material().setWireframe(true);
                ready.material().setDiffuse(new Vector3f(1f, 0.7f, 0.5f));
                g.addChild(ready);
            }
            sciView.addNode(g, v);
        } else{
            ui.showDialog("The active node needs to be a volume.", DialogPrompt.MessageType.ERROR_MESSAGE);
            return;
        }
    }
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

1 participant