Code Monkey home page Code Monkey logo

Comments (6)

rii-mango avatar rii-mango commented on July 26, 2024

Let me know if I'm not understanding your question. You're asking if you can do this:
params.images = ["myImage.nii"];

... instead of this...
params["images"] = ["myImage.nii"];

Yes, you can do either. The only reason for the associative array is when you need to specify image parameters, since in that case the parameter would most likely contain a dot. For example, this wouldn't work:
params.myImage.nii = {alpha:0.5};

... instead you'd need...
params["myImage.nii"] = {alpha:0.5};

Most of the documentation uses the associative array approach, but either way will work.

from papaya.

rdevon avatar rdevon commented on July 26, 2024

Ah, not exactly, but I think I'm getting closer to understanding the question myself.
The papaya tutorial lays out constructing the papayaContainers via html and some variables defined within javascript. It's a little weird (to me) that the html can read the string that references the variable name ("params" in this case), but in the end the (simple) way to construct papaya objects is to do in html:

<div class="papaya" data-params=<some string referencing a javascript variable>></div> (1)

So to my understanding there is a lot going on under the hood with the above. The problem is if you want to construct many papayaContainer objects from an array of parameters:
[params1, params2, params3...]
such that each set of parameters is a function:
params1 = {images=[data_paths[i]], ...}
(for example), it's not straightforward in my limited experience how to reference these parameters with a string as in (1).
How would you go about this?

Another thing I've tried is just constructing all of the papaya objects with (1) with a global set of parameters, then using the loadNextImage method of papayaContainer. Alas, this failed (returned errors). Is there a correct way to do the following:

<script>my_file_paths.forEach(function (file_path, i) { <do awesome stuff here to papayaContrainers[i]>; })</script>

Thanks in advance.

from papaya.

rdevon avatar rdevon commented on July 26, 2024

To be a little more clear, <do awesome stuff here to papayaContrainers[i]> should load image (or images) from file_path.

from papaya.

rdevon avatar rdevon commented on July 26, 2024

Bonus if <do awesome stuff here to papayaContrainers[i]> also allows you to control the color, transparency, etc of loaded image.

from papaya.

rii-mango avatar rii-mango commented on July 26, 2024

Got it. I think this is what you need:
papaya.Container.resetViewer(index, params)

index = the index of the papaya container
params = the parameters object itself (not the string literal name of the object, as is used in the HTML declaration)

So in this case, just create your papaya containers without any parameters, then call papaya.Container.resetViewer() with the parameters you want. See here for documentation on how to control image parameters.

[One minor thing with this approach is if your parameters change the default UI (e.g., kioskMode), then you may see it flip from the default UI to the UI you specify. In that case, it may be a good idea to specify a global set of parameters just to set the UI state and which does not load images. Then when resetViewer() runs, it will load the images.]

More documentation on API methods here.

from papaya.

rdevon avatar rdevon commented on July 26, 2024

Beautiful, that appeared to get me close to what I want. I'll look more closely at those API options. Thanks!

from papaya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.