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

wishlist: Is there a way to open a new image via Javascript API? #28

Closed
cjmielke opened this issue Jul 28, 2015 · 1 comment
Closed

Comments

@cjmielke
Copy link

I love Papaya - its by far the best MRI viewer my lab has experimented with. Out of curiositiy, is it possible to close the current image and load a new one entirely through Javascript, or must a new page be navigated to with the neccessary params block defined?

Ive managed to reverse engineer a number of features into Mango, namely moving the cursor around, but this last issue still troubles me as it seems as if the constructor methods are no longer present once the viewer loads.

Thanks!

@rii-mango
Copy link
Owner

See the below snippet. Edit tests/debug_server.html with the below to run the example. It loads an image, then after 5 seconds closes it and load a new image (I use the atlas image just as an example since it's already part of the project).

I think there's lots to do to make a cleaner API for Papaya. Eventually I'll get around to that along with more documentation...

<script type="text/javascript">
    /* DO NOT EDIT (start) -- papayaLoadableImages is generated by papaya-builder and is here for debugging purposes only */
    var papayaLoadableImages = [
        {nicename: "Sample Image", name: "sample_image", url: "../data/sample_image.nii.gz"},
        {nicename: "Atlas", name:"Talairach_labels_1mm", url: "../data/Talairach_labels_1mm.nii.gz", hide:true}
    ];
    /* DO NOT EDIT (end) */

    var params = [];
    params["images"] = ["../data/sample_image.nii.gz"];
    params["atlas"] = ["Talairach_labels_1mm"];

    setTimeout(function() {
        papayaContainers[0].viewer.resetViewer();
        papayaContainers[0].toolbar.updateImageButtons();
        papayaContainers[0].viewer.loadImage(["../data/Talairach_labels_1mm.nii.gz"], true)
    }, 5000);
</script>

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