SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
59 stars 29 forks source link

spyder or jupyter notebooks for interactive demos #170

Open KrisThielemans opened 6 years ago

KrisThielemans commented 6 years ago

for the course, we've decided on jupyter notebooks (assuming it all works!). That will lead to duplication of demos and therefore bugs.

One solution might be to swap to jupyter notebooks and tell people about the spyder plug-in to use jupyter notebooks in spyder. I haven't tried this yet.

By the way, there seems to be a nice feature of jupyter notebooks to be able to generate a new notebook with all output, and then convert it to HTML (or Latex or ...), see here. This would be good for generating documentation.

paskino commented 6 years ago

And I've made a script to convert spyder scripts to jupyter notebooks! We can close the circle.

KrisThielemans commented 6 years ago

:-) I knew you were not a copy-paste guy.

will be interesting to see the output... Note that there are some fixes on the demos already.

paskino commented 6 years ago

After the first file I painstakingly translated I went for the more interesting way. Which enabled me to update the notebook you've updated!

I've got a question: it seems that you need to run the PET interactive samples in a single thread, as one is needed for the other step. Shall I put it all in one notebook?

MR notebooks work like charm.

BTW, you can already try it on any machine with SIRF installed (and jupyter)

KrisThielemans commented 6 years ago

great.

RE the PET interactive ones question, does each notebook run with its own kernel? If not, I'd rather avoid it. It otherwise would become a very large notebook. Maybe we could put some stuff in then to avoid the dependency. To discuss tomorrow?

BTW: try, yes. great. but where are they? :-;

paskino commented 6 years ago

they are here https://github.com/CCPPETMR/SIRF-Exercises/tree/notebook

Yes, each notebook runs on a different kernel, and to make a notebook connect to another kernel is quite a hack.

KrisThielemans commented 6 years ago

notebook convert can output spyder, and/or check the spyder notebook plug-in.

casperdcl commented 6 years ago

https://ipython.org/ipython-doc/2/notebook/nbconvert.html

casperdcl commented 6 years ago

from the link above, we could do ipython nbconvert --config mycfg.py which should hopefully allow us to replace # <codecell> with #%% automatically. If it doesn't we can always run our own script to do the replacement.

casperdcl commented 6 years ago

update: jupyter nbconvert --to python now does # In [*] instead. This seems to be supportend by spyder (spyder-ide/spyder#1783). I've tested this with latest jupyter and spyder via conda (and nbstripout via pip). I'd recommend:

nbstripout file.ipynb && jupyter nbconvert --to python file.ipynb
KrisThielemans commented 5 years ago

would need to be done at install time (see #181) I think