top of page
  • Writer's pictureSharon McTaggart

Getting Started with Jupyter Notebooks


ilumr desktop MRI, matipo spectrometer and Jupyter Notebooks


All Resonint products share a common platform called matipo. Our mission is to make MRI more accessible and, because of this, we have developed this software platform in the open-source Jupyter Lab environment.


Why we use Jupyter Lab:

  • Easy setup: Since Jupyter Lab can be run from a web browser, you can start using the spectrometer immediately without downloading software.

  • Flexible: Jupyter Lab can be run from any PC, laptop, or tablet and, because it is web based, the spectrometer can be made accessible from anywhere in the world.

  • Extendable: Jupyter Lab has an active community of users creating amazing open-source projects that extend the functionality of the Jupyter Lab environment. Click the link to check out some of the cool extensions you can add to your projects: https://github.com/ml-tooling/best-of-jupyter


Dashboards vs. Notebooks

When you load the software webpage for one of our spectrometers, you will see dashboards used for running experiments interactively, and a series of example Jupyter Notebooks.


interactive 2D RARE imaging dashboard
2D RARE Dashboard

Dashboards are a simple and accessible way to run standard MRI experiments. They allow you to alter parameters, run standard pulse sequences, and view the results with a few button clicks. This makes them a great tool for calibration, routine imaging, and outreach demonstrations.



notebook showing a lab task, code snippet, and rf pulse plot
Excerpt from MRI Fundamentals Lab 3 Notebook


Notebooks are a more flexible method of running MRI experiments. They provide a combination of rich text elements, executable code, and inline plot displays. This makes them perfect for creating multi-step experiments, running interactive lab scripts, and developing pulse sequences.






Resources for Getting Started with Jupyter Notebooks

Creating a Python Notebook to run your next MRI experiment is super easy and, to make things even easier, we have compiled a list of resources to help you get started.


1. Setting up a Notebook

The Jupyter Notebook Read the Docs provides a good introduction to setting up notebooks, running cells, and keyboard shortcuts:  https://jupyter-notebook.readthedocs.io/en/stable/notebook.html


2. Python and Python Libraries

Our spectrometers are fully programmable using Python 3, which can be run in a Python Notebook.


Pulse sequences are constructed and run using the matipo library, which is documented here: https://resonint-matipo-python.readthedocs-hosted.com/en/latest/usage.html


Other python libraries can be used for data processing, plotting, interactive widgets and more. Some useful libraries, which come preinstalled, are:


3. Rich Text Elements

These sections of the Notebook are great for writing educational content, creating lab tasks, noting down your MRI experiment setup, and documenting your code.


Text

This handy markdown guide is great for getting started with text styling: https://www.markdownguide.org/cheat-sheet/


Mathematics

Mathematical notation and equations can be added directly into the markdown cells using LaTeX notation with a single "$...$" for inline notation and a double "$$...$$" for displayed equations.


Example:

In order to efficiently generate the $\vec B_1$ field and pickup the signal from the net magnetization $\vec M$, the coil is combined with a capacitor to form a resonant circuit shown in the figure on the right. The resonant frequency of an LC circuit is:

$$f = \frac{1}{2\pi\sqrt{LC}} \tag{2}$$

Output:

output of code snippet one showing rendered equation

Images and gifs

Although images and gifs can be added using markdown syntax, the styling options are rather limited. Using HTML styling provides greater control over image placement, sizing, and figure captions.


Example:

<figure style="float: right;">
<img src="Images/CapCircuit.png" width="300" style="display: block;">
<center><figcaption style="width: 300px;">Figure 4: Resonant Circuit</figcaption></center>
</figure>

In order to efficiently generate the $\vec B_1$ field and pickup the signal from the net magnetization $\vec M$, the coil is combined with a capacitor to form a resonant circuit shown in the figure on the right. The resonant frequency of an LC circuit is:

$$f = \frac{1}{2\pi\sqrt{LC}} \tag{2}$$

Output:

output of code snippet two showing rendered image

To learn more about image styling in HTML check out this useful tutorial: https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Images_in_HTML










43 views
bottom of page