Skip to content

Accessing original data from SciView #607

@odinsbane

Description

@odinsbane

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;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions