niivue / ipyniivue

A WebGL-powered Jupyter Widget for Niivue based on anywidget
BSD 2-Clause "Simplified" License
25 stars 8 forks source link

Documentation and class introspection #5

Closed AnthonyAndroulakis closed 6 months ago

AnthonyAndroulakis commented 1 year ago

from https://github.com/AnthonyAndroulakis/ipyniivue_ts/issues/2 by @christian-oreilly

Thanks for putting this notebook integration together. It looks great and promising! I tried this tool using the use cases of visualizing 1) a NIfTI file I have and 2) EEG sources computed from MNE-Python. The widget displays as expected using

from ipyniivue import Niivue
w = Niivue()
w

However, I am afraid that is where my use cases hit a dead end. The first python-programmer reflex, I think, would be to check the docstring for the Niivue class. Checking it through the IPython ? operator:

Init signature: Niivue(*args, **kwargs)
Docstring:      Widget that can be inserted into the DOM
Init docstring: Public constructor
File:           ~/Library/CloudStorage/GoogleDrive-christian.oreilly@gmail.com/My Drive/Code/ipyniivue_ts/ipyniivue/widget.py
Type:           MetaHasTraits
Subclasses:     

This does not help me as there are no named arguments. I cannot introspect the bells and whistles available on this widget. The second reflex: going through the code on GitHub. Looking at it, it appears there is about no Python coding in the wrapper on this widget. It is an extremely thin wrapper, exposing no public methods and attributes. This means that I would need to dig into javascript or ts which, as a Python programmer (I suppose, the intended target), is a no-go.

Third reflex, running dir(Niivue) which lists the attributes and methods of the class. That is a bit more useful as it at least give me some methods to explore, but these do not seem to be methods specific to the functionalities of that specific widget... I could search my way in the dark and teach myself what is traitlets and how to use this framework, but the bottom line is that to attract a significant Python user base, I think this project will need to :

1 - Have a deeper richer wrapper, exposing useful methods and attributes for programmatic interaction in Python. 2 - Provide additional documentation to illustrate how most common operations (loading a file, panning, rotating, zooming, changing color map, etc.) can be performed.