r/IPython • • Sep 13 '15

IPython notebooks as electronic lab notebooks (ELNs)

Hello!

I'm a Python newbie and was wondering if there is a scientist here that actually uses IPython notebooks as lab notebooks (ELN software).

My goals are:

  1. To keep notes in Latex, as well as code in my Ipython notebook

  2. To reuse my Latex code, as well as some of my graphs for my thesis.

  3. To create publication quality graphs for my papers using iPython notebooks.

  4. To use citations with Bibtex within iPython, much like in Latex. The .bib file will be the same .bib file I'll have for my thesis.

  5. To integrate version control with Git possibly in the future.

I saw some Youtube videos that sparked my interest. But is there actually anyone here who has done it? If so, what is your workflow? What problems did you face?

9 Upvotes

9 comments sorted by

2

u/gash789 Sep 14 '15

I am a final year PhD candidate in astrophysics. I started off trying to get an electronic lab book in my first year, but I quickly gave up. Here are my thoughts:

The reason that (I found) it doesn't work is that: the whole purpose of a log-book is to be able to quickly and easily recall what you did at some distant point in the past. For me, the electronic format works as well as your naming convention. Unfortunately in science we often don't know what we're doing until it is done, so it is hard to name things in a way that will make you remember them in future before you have done it!

So to counter this I fell into using paper: I buy cheap empty lines books then number them. They progress in a linear fashion: with dates and titles of what I was trying to do. Usually this is accompanied by a notebook or some python scripts. At a preliminary stage results are printed off and stuck in to the book. Once I am convinced it is correct and worth spending time on, I will write it up as either a latex document or possibly a notebook.

The end result is I have two log books: a rough version (the paper) and a more refined copy (the notebooks/latex). The refined version can be transformed into other things if needs be, but the paper copy remains as a permanent memory so if someone asks: what happens if I do this, I can remember "ah that was in a book from sometime last year" and usually find it.

TL;DR Saving all your work on a computer requires you to remember what you called the file. I find paper copies easier to remember where something will be.

1

u/run_from_your_wife Sep 14 '15

But what about after 20 years? How will you search your paper books efficiently?

I don't understand why you don't keep the rough version in electronic format and just index it later on, when you know what the project led to eventually.

1

u/[deleted] Sep 15 '15

If you think your research is going to interesting or fundable in 20 years you should probably be in science a bit longer than you have been.

1

u/HilariousBookbinder Sep 14 '15

I had a similar experience, I found the iPython notebooks good for writing tutorials for other lab members and reports on my results for my supervisor

1

u/[deleted] Sep 14 '15 edited Sep 14 '15

This isn't implausible but I find that it can get a little unwieldy since there is no clear away to organize the notebooks you create other than your computer's folder structure.

Edit: also, as far as I know ipython notebooks don't support LaTeX at all (and I personally hope they never do). They do support mathjax so you can put latex like equations in a markdown cell. If you really want to use latex instead of markdownthink latex I suppose you could write it in a raw format and copy and paste it into something else later.

Edit2: bibtex in jupyter https://youtu.be/m3o1KXA1Rjk

Also ipython notebooks aren't word processors and they aren't even that great of an ide. They can be used to great effect to produce webpages describing science, producing publication worthy figures, etc. But you are going to find them lacking if you try to write your whole thesis in one. Especially if you insist on writing them in latex.

I recommend just using them to produce figures and figure captions and notes. Write papers in msword/latex. Write software in a real ide. Make figures in a jupyter notebook.

1

u/run_from_your_wife Sep 14 '15

I don't want to write my whole thesis in one. But I suppose it's true that an IPython ELN would quickly get very large and unwieldy.

3

u/bheklilr Sep 13 '15

You can certainly do all of that in notebooks, but the hardest part will be the version control, notebooks don't diff very well. You could pretty easily write a commit hook or a script that converts all your notebooks into multiple formats before committing, that way you can diff python files, latex files, or whatever format you find useful.

1

u/NomadNella Sep 14 '15

I remembered seeing NBDiff a while back, but since my work flow is more suited to using git, I never tried it.

1

u/bdforbes Sep 14 '15

I've used all those technologies separately throughout my research, and it sounds too difficult to try and integrate them like that.