Making Music with an MRI System
- Sharon McTaggart

- 4 days ago
- 5 min read

At the very beginning of my journey into the field of NMR/MRI, I was watching a series of video lectures on MR physics when I learnt about something exciting: MRI machines can be programmed to produce music. This idea entertained me to no end and I soon found myself watching video after video of MRI systems chirping and rumbling away to tunes from Scott Joplin's The Entertainer [1] to Bach's Cello Suite No.1. [2]. At the time, I barely understood what caused MRI machines to make sounds, let alone how to control that sound, so I didn't pursue the idea any further.
That was until last week when I realised that, with an MRI system sitting on my bench and a pulse sequence program open on my PC, there was actually nothing stopping me from turning my imaging system into a whimsical musical instrument.
Therefore, here are excerpts from Rondo alla Turca and All Star being played on a mini MRI system.
How to Create your own Music on the ilumr Benchtop MRI System
The sound that is emitted from an MRI system is caused by the system's gradient coils being switched on and off inside the permanent magnetic field. The rapid switching of electrical currents within a magnetic field causes a force (called the Lorentz Force) to be exerted on the coils. This causes vibrations in the coils that are emitted into the air as sound waves. By controlling the frequency of the gradient switching, we are able to control the pitch of the sound that is emitted - allowing us to play recognisable notes from the musical scale.
The simplest waveform we can generate using ilumr's gradients is a square wave. If we want to use the gradients to create a single square wave of a specific frequency, we need to string together the following pulse sequence library commands.

To create a longer note, we simply have to repeat these gradient switching commands for the desired duration. Now that we have created a single note, we can repeat these commands while varying the frequency and duration to produce an entire song.
I have created a simple pulse sequence program to generate these gradient waveforms. It's not a particularly elegant piece of code but it gives you a starting point for writing your own pulse sequence program and making your own music.
You can download the pulse sequence program (notes.py) and the notebook (music_notebook.ipynb) needed to run the pulse sequence here: Resonint GitHub
The pulse sequence file has an array of paired values (tuples) which specify the frequency and beats of each note you want to play. You can change these values to input your own song.
The "note" function then converts these values into gradient commands to create square waves.
When modifying the pulse sequence program to create your own songs, you can use the offline pulse sequence plotting tool to visualise the output waveforms. This is particularly useful if you plan to experiment with the shape of the gradient waveforms.

A Brief Side Quest: How to Manually Extract Data from Sheet Music
If you have a background in music, picking frequency and duration values to populate the array in the pulse sequence shouldn't be too difficult. If this is your first time playing music, you can use the following steps to convert simple sheet music into frequency and duration values.
This is by no means an exhaustive look at music theory but should be enough to help you turn a simple song into code. If you want to play some more complicated songs on your MRI system, you will have to venture out on your own deep into the wonderful world of musical notation.
Frequency
When reading music, the first step is to identify the notes in the melody. Each note is drawn at a different position on a set of five horizontal lines and is associated with a letter. The image below shows what each note in the 4th and 5th octave looks like in the Treble Clef (the swirly symbol on the left of the image). Sometimes you will see a ♯ symbol or ♭ beside a note in the sheet music. These symbols mean that, while the letter assigned to the note (and its position on the horizontal lines) has not changed, the frequency of the note has changed.

The following table can be used to convert each note into its corresponding frequency in Hertz.
Table 1: Frequencies of Musical Notes in the 4th and 5th Octaves [3]
Note | Octave 4 Frequency (Hz) | Octave 5 Frequency (Hz) |
C | 261 | 523 |
C♯ | 277 | 554 |
D | 293 | 587 |
D♯ / E♭ | 311 | 622 |
E | 329 | 659 |
F | 349 | 698 |
F♯ / G♭ | 369 | 739 |
G | 392 | 784 |
G♯ / A♭ | 415 | 830 |
A | 440 | 880 |
A♯ / B♭ | 466 | 932 |
B | 493 | 987 |
Example: if you wanted to play this short piece of music on your ilumr MRI System, you would need to input the following values into the notes array.

frequency = [261, 261, 392, 392, 440, 440, 392]
Duration
While the vertical position of a note indicates it's pitch/frequency, the way that the note is drawn indicates how long it should be played for. The table below shows how many beats each type of note should be played for.
Table 2: Notation for Note Duration
Musical Notation | Name | Number of Beats |
![]() | Semibreve | 4 |
![]() | Minum | 2 |
![]() | Crotchet | 1 |
![]() | Quaver | 1/2 |
![]() | Semiquaver | 1/4 |
Example: if you wanted to play this short piece of music on your ilumr MRI System, you would need to input the following values into the notes array.

beats = [1, 1, 1, 1, 1, 1, 2]
To translate beats into timing values for your gradient waveform you will also need to know your song's beats per minute (BPM). This blog post is not going to delve into tempo terms, so, the simplest way to obtain this value is to internet search the BPM for the song you want to play.
Future Work
Since ilumr has three gradients, there is the exciting possibility of creating three part harmonies. I have not attempted this yet, but I will report back if it is a success. There is also the possibility of creating more complex waveform shapes to alter the tone of each note. I also think it would be awesome to add a feature where you can upload MIDI files and automatically convert them into gradient control commands to make it easier to create and play more complex songs. Finally, it would be cool to create a pulse sequence that can both play music and acquire data. Perhaps in the future I will try to create some kind of musical EPI sequence. For now, I have to focus on developing pulse sequences for some slightly more serious applications but you can be sure that this will not be the last you see of my MRI music. Until then, I challenge you to go forth and make your own strange and wonderful music on an MRI system.
References
[1] Team T2 Star. "Scott Joplin's "The Entertainer," - MRI system playing music" YouTube, March 5, 2021 [Video file]. Available: https://www.youtube.com/watch?v=aQQ-Azi26N4
[2] Qinwei Zhang. "Music from MRI Gradient System," YouTube, April 25, 2018 [Video file]. Available: https://www.youtube.com/watch?v=VYAvxe9X3s0&list=RDVYAvxe9X3s0&start_radio=1
[3] The frequency values in Table 1 are sourced from the following paper:
Ortiz-Echeverri CJ, Rodríguez-Reséndiz J, Garduño-Aparicio M. "An approach to STFT and CWT learning through music hands-on labs," Comput Appl Eng Educ. 2018; 26: 2026–2035. https://doi.org/10.1002/cae.21967
Join the Discussion!
Our forum is a great place to discuss topics with the Resonint team and other ilumr users. If you have any questions about how to create your own music on ilumr or want to share a pulse sequence you've written to play your favourite song, send us a message in the "General" topic!

If you have questions about our product range, are interested in receiving a quotation, or would like to schedule a product demonstration, send us an email at info@resonint.com.










Comments