NeuroML / pyNeuroML

A single package in Python unifying scripts and modules for reading, writing, simulating and analysing NeuroML2/LEMS models.
https://docs.neuroml.org/Userdocs/Software/pyNeuroML.html
GNU Lesser General Public License v3.0
34 stars 30 forks source link

feat/Make 3d visualization compatibile with jupyter notebooks #399

Open lej0hn opened 5 days ago

lej0hn commented 5 days ago

Aims to solve #359

To run in jupyter you need to get the returned canvas object and call it. e.g. canvas = plot_interactive_3D(nml2_doc, plot_type='detailed', axes_pos=[0,0,0], upright=True) canvas

sanjayankur31 commented 5 days ago

Is it worth creating a plot_interactive_3D_jupyter function that wraps around the plot_interactive_3D function and calls canvas do you think? It'll pass the args to plot_interactive_3D but set the nogui etc. options as required.

Is the rbf package required for this at all? If yes, we'll also need to define a new jupyter extra in setup.cfg that could pull in the necessary deps?

lej0hn commented 5 days ago

While it is possible, then shouldn't we have wrapper functions for each visualization function (plot_3d_cell_morphology, plot_3d_schematic) as well? Also I believe the arguments are identical, so I guess it comes down to which method would be preferred by a user -- to call a different jupyter-specific function or to call canvas? I'm really not sure, although I think I tend a bit to calling canvas.

Yes, the rfb package is required and I believe is the only extra package required. I will add it to the setup.cfg

sanjayankur31 commented 5 days ago

We could have wrappers for all of them yes. I was simply thinking of this:

plot_interactive_3d_jupyter(*args, **kwargs):
    canvas = plot_interactive_3d(*args, **kwargs)
    canvas

(do check the usage of args and kwargs, I can't remember what the correct form is)

because I can't think of a way of informing users that canvas has to be called in jupyter notebooks---it'll have to be documented somewhere and users will have to find that documentation. With the wrapper, all they do is call a function and we take care of things for them "under the hood".

I guess another way is to simply add a new argument to all the functions: jupyter which will call canvas, similar to nogui and all that?

Is calling canvas all that is required? No other changes at all?

lej0hn commented 5 days ago

Yes I see your point. So both the wrappers and the argument are valid solutions, and perhaps with the argument we won't have to return the canvas as well, so it remains more the same.

Apparently yes, calling canvas, or using display(canvas) if in a function are all it needs

sanjayankur31 commented 4 days ago

Tasks:

Use neuroconstruct and play with its visualiser to get an idea of what features we can add to the pyneuroml visualiser