Introductionยถ

From acoustic dissonance to magnetic resonance

This interactive book will teach you NumPy and SciPy in the context of signal processing. The main exercise is to make some magnetic music by harmoniously mixing MRI acoustic noise with guitar melodies and vocal tracks. I have a special introduction to motivate you:

ISMRM Innovation in MRI Education

๐Ÿฅˆ This course is the silver award winner!

Listen, interact and re-run

All the interactive content (audio and interactive figures) has been embedded in this Jupyter Book, so you can use interactive features without running a single line of code.

Why?ยถ

This would have been a sunrise session if it were a physical meeting.

โ€”Dan and Miki

I prepared this NumPy and SciPy course for a software engineering educational session at ISMRM 2021 Annual Virtual meeting. There are thousands of great resources to learn about these fundamental Python modules online, but this course is special because:

  • ๐Ÿ‘จโ€๐ŸŽค It is artfully tailored for MRI scientists. You make music using MRI sounds as you learn Python.

  • ๐ŸŒ… Despite that the conference is virtual, it is still about sunrise no matter where you are

  • ๐Ÿงฒ It comes with a publicly available pulse sequence

  • ๐Ÿ’ฝ It teaches scientific computing with Python using community data standards: ISMRM-RD and BIDS

  • ๐ŸŽš It includes interactive visualizations

  • It is equipped to ensure reproducibility

Scientific computing with a cooking analogyยถ

All the notebooks are presented in the context of a typical image processing workflow, with an analogy to cooking!

An overarching theme

Use the tabs below to find out about the culinary skills you will obtain in this course to cook a scientifically nutritious Pythonic dinner!

Know your file formats and data standards

Most high-level programming languages have a native way for packing and unpacking their own objects, such as MATLAB (*.mat), Python (*.pkl), Julia (*.jld) and such.

But when we go to community markets for data shopping to cook a nutritious meal, we usually donโ€™t find ingredients available in such formats.

Imagine that we'd like to bake a `Pythonic pizza ๐Ÿ•`, and we need tomatoes `๐Ÿ…`

_images/tomato.png
See what a world-class master chef has to say about that

_images/gordon.png

Fresh MRI ingredients

ISMRM-RD for k-space data and BIDS for reconstructed images. For dealing with audio processing, we will be working with 16-bit .wav files, which is frequently used by professional music studios.

Put everything in place with NumPy

Depending on our research question or application, we often need to dice and slice our data in different ways. `NumPy` is the brand of our chef's knife and all the utensils to put everything in place. _images/numpy_step2.png

Let professionals cook for you!

You can imagine SciPy (or any other Python package) as a culinary academy of Michelin Star Chefs, who are willing to cook your meal for free, if you did the preparation.

_images/scipy_chefs.png

Everything tastes better when you share.

IMHO, sharing our MRI processing recipe with others is a requirement rather than a choice.

It is always good to know what you eat!

https://i.pinimg.com/originals/f9/f0/1b/f9f01bc7b3436efece0c29cca44cc1e1.gif


To that end, I equipped this repository with some tools to foster transparency & reproducibility.

What youโ€™ll learnยถ

_images/summary.png

1D Data ๐ŸŽผยถ

Samples from different MRI sequences (including NORAH JONES) and some guitar melodies to compose magnetic melodies in Python. Files are in *.wav format, storing audio sampled at 44.1kHz sampling frequency (or framerate) ๐Ÿ’ฟ. Respecting Nyquist sampling theorem, this framerate allows us to digitize analog sound at the highest frequency audiable to human ear (20kHz).

There are so many Python modules that can load a *.wav in a single line, such as scipy, librosa, soundfile, scikits etc.

For demonstration, we will use Pythonโ€™s standard wave library and convert data from byte array to numpy array.

2D Data ๐ŸŒ…ยถ

Images acquired using the NORAH JONES sequence at 4 TRs. Each image is 100x100, organized in Brain Imaging Data Structure (BIDS). We will use pyBIDS to query and load this data.

3D Data ๐ŸŽ†ยถ

K-space data acquired using the NORAH JONES sequence at 4 TRs. Each file contains 100x100x1x16 data (16 receive channels), organized in ISMRM Raw Data - ISMRM-RD format. We will use ismrmd-python to load this data.