Published September 2025 as part of the proceedings of the first Alpaca conference on Algorithmic Patterns in the Creative Arts, according to the Creative Commons Attribution license. Copyright remains with the authors.

doi:10.5281/zenodo.17084378


Algorithmic Patterns in Magnetic Resonance Imaging

Magnus-Magdalene Cooper Tavener
Sir Peter Mansfield Imaging Centre, University of Nottingham, Nottingham, U.K. / Pastagang

Background and Introduction

I’m an undergraduate physicist working with magnetic resonance imaging (MRI) at the University of Nottingham. In my research I look at the ways imaging at ultra-high fields (7T+), itself primarily for further research, can be improved, focusing on techniques to reduce magnetic field inhomogeneity, so that images are accurate depictions of anatomy, or have good signal to noise ratios.

MRI is a technique founded on radar experiments that took place in the early half of the 20th century, when ex-military physicists found themselves with a glut of radar equipment on their hands, and pointed it into solid matter rather than aeroplanes. Improvements in digital computation (another product of the Second World War) enabled image reconstruction beyond the simplest cases, and MRI scanning became possible.

I like to remember that the actual nuclear magnetic resonance experiment that underlies every scan is analogue in nature, and grounded in algorithm patterns. MRI is a beautiful and vastly underappreciated physics experiment, and one that impacts all of our lives. The artistic application of medical imaging has been explored1 2 3, and there is some prior work looking at MRI as a method of artistic image making 4 5.

In this work, I focus on the physics beneath MRI images and explore approaches to thinking about and talking about MRI starting from algorithmic patterns and seeing where these take us.

Echoes

Every MRI experiment is concerned with a phenomenon called “echoes”. These are sudden increases in signal (an oscillating current your body induces in a coil placed around it whilst in the MRI scanner), as an incoherent signal is tricked into becoming coherent again – either because we yank it around with magnetic field gradients, or by pointing everything back the way it came and letting it rewind the loss. Along the way, we use additional magnetic fields to encode anatomical information and influence which magnetic properties of tissue contribute to the image.

The instructions of which magnetic fields to use and when exist in the MRI scanner as code, but are usually communicated within the community as pulse sequence diagrams, like this:

A spin-echo pulse sequence depicted as a block diagram. The first half is greyed out and labelled with various pre-sequence pulses like fat supression and spoilers, then there's the spin-echo sequence showing the excitation and refocusing pulses, gradients and FID produced.
Figure 1: An MRI pulse sequence which schematically shows the magnetic fields needed to create an echo for imaging. This figure is taken from a common textbook: From Picture to Proton1

  1. McRobbie, Donald W. MRI from Picture to Proton. 3rd ed. West Nyack: Cambridge University Press, 2017.↩︎

In this diagram, time goes from left to right. Some preparation pulses (greyed) for various methods are followed by a pulse sequence which excites (the red shape labelled 90 degrees), spatially encodes using gradient fields (the blue and striped trapezoids on the second, third and fourth lines from the top) and refocuses (the red shape labelled 180 degrees) a signal. Each of these is the application of a magnetic field whose timing must be precisely controlled (like turning an mp3 into speaker cone vibrations). This pulse sequence results in a single spin echo, shown as the red wriggly line on the last line.

We can do a similar experiment to some water in a test tube. The spectrometer cannot hear the radio frequency (GHz) signal a sample produces, so we instead measure its offset to a fixed reference signal. It just so happens that this offset is usually in the audio frequency range, so we can listen to the spin echo as the spectrometer will receive it6

A graph of a waveform, there's blue and orange lines and they oscillate up and down sinusoidal, increasing and decreasing in amplitude so it has an oval-shaped envelope.
Figure 2: A plot of a waveform. This shows the real (blue) and imaginary (orange) offset signals coming from an small vial of water. This waveform was produced by the author using a pulse sequence similar to the one described above and is the same as the one in the audio recording.

Phase graph analysis

Since each echo is a bit of useful information, we’d like to get as many of them as quickly as possible (subjects get fidgety!) but there are safety limits to how many pulses we can use in a time interval (they put heat into the subject), the rate at which we can drive gradients (they can induce currents in the body7) and there are intrinsic timing requirements in order to get certain sorts of images.

MRI pulse sequences are designed using a number of tools, but one of the most useful for understanding what it is a pulse sequence is doing, when these echoes will occur and what sort of information they will contain is called phase graph analysis (extended phase graph analysis, nowadays). This is a simple three step algorithm, but is quite tricky to write down:

  1. Start with a blank plane, with time in one direction, and ‘phase’ perpendicularly. Draw a straight line along the time direction,
  2. Every time you use an RF pulse, split all lines line into 3 at that point.
  3. The first of these should travel at some angle to zero depending on the gradient. The second should have no angle, and travel parallel to the zero line, and the third should have the negative of the first angle.
  4. Extend the lines in this manner until you use another RF pulse.

In these diagrams, an echo occurs whenever a line crosses the central (0-phase) line from the right8 Echo timings are to scale along the time axis, and multiple echoes coinciding give a stronger signal.

A photo of a piece of paper with a partially complete phase graph and the instructions for making one.
Figure 3. A photo of the one-page instruction sheet I made for creating phase graphs, or trifurcating trees. It explains the steps detailed above, taken out of the context of MRI.

These steps can be further simplified by taking them out of the context of MRI and using them as instructions for plotting a trifurcating tree. I have done this, and used the resulting pattern-making activity as a workshop to enjoy for its own sake, and use as a way to start talking about MRI. To do this, I wrote them into a “1-page RPG zine” style document and suggested participants use a paper template to help mark the angles.

A photo of 3 people sat at a green table. They hold pencils and look intently at their work, plotting lines on pieces of paper. The photo is taken from a high position, and you can see completed phase graphs, laptops and other bits and bobs on the table.
Figure 4. With thanks to Jon, Andrew and Gareth at Nottingham Hackspace.

Insights into MRI

A photo of a phase graph, drawn in pencil on white paper. It's a tree diagram splitting into 3 at a series of horizontal folded lines.
Figure 5. A phase graph drawn by a participant. This one wanted to do an extra pulse, and so had to draw three times as many lines as the others. Participants chose to use colour to mark echoes.
A phase graph drawn in thick black pen on green paper. The fold creases are clearly visible and there is writing saying "THIS IS A PHASE PLANE" and labeling the consequences of gradients and RF pulses.
Figure 6. Participants added colour and their own annotations to their phase graphs, and enjoyed using them as an ‘in’ to understanding a bit more about MRI.

My subjective impression, and the number of successfully completed graphs, is that people enjoyed this pattern-making activity. During the making of their phase graphs, participants would ask questions about the process that naturally came up, like “what happens if it goes off the page?”, “can I change the angle? What about between pulses?” and “what does it mean if multiple cross at the same time?”. These are all really good questions about pulse sequence design, and raise interesting problems or suggestions of techniques we could use. I found it challenging to answer these questions without explaining MRI more detail than we had time for, but I was usually able to by referring back to the phase graph and how the line they were asking about might contribute to a future echo.

At a Sheffield pattern club meetup, I was lucky enough to follow a talk about bobbin lace making. They explained how an error at some point in the lace has a history that is traced through the threads back to some mistake, sometimes a long way previous, but always traced along the thread. This is extremely similar to how the signal intensity of some echo depends on the history of the line that arrives at that echo, where it comes from, and what sort of gradients in traveled through and was an unexpected point in common.

The biggest challenge to this approach is that hand-plotted phase graphs don’t straightforwardly relate to the image you see. In the extended formalism, each line has a strength or opacity and it’s possible to get some sense of how different tissues might result in different strengths of echo. The phase graph also only applies to signal within a single voxel. It isn’t possible to relate it to how the entire image is acquired, and MRI image acquisition “spatial encoding” is hard to explain. I have begun developing tools (available on my website), which allow you to interact with MRI in a more conventional framing, but they are much more complex to understand and use, and not yet well integrated with the phase graphing approach.

Presenting phase graphing analysis starting from such a simple algorithm resulted in patterns that were appreciated in their own aesthetic sense, and also enabled participants, all nonspecialists, physicists, to explore the core of MRI, and ask really insightful questions about pulse sequence design and gain some understanding about a technique which will underlies so much of our healthcare.


  1. ‘Science Art Network’. Accessed 31 May 2025. https://scienceartnetwork.org/.↩︎

  2. ‘Artwork Inspired by MRI Brain Scans Installed at Stanford Imaging Center – Stanford Arts’. Accessed 31 May 2025. https://arts.stanford.edu/artwork-inspired-by-mri-brain-scans-installed-at-stanford-imaging-center/.↩︎

  3. Marinković, Slobodan, Tatjana Stošić-Opinćal, and Oliver Tomić. ‘Radiology and Fine Art’. American Journal of Roentgenology 199, no. 1 (July 2012): W24–26. https://doi.org/10.2214/AJR.11.7934.↩︎

  4. Casini, Silvia. ‘Magnetic Resonance Imaging (MRI) as Mirror and Portrait: MRI Configurations between Science and the Arts’. Configurations 19, no. 1 (2011): 73–99.↩︎

  5. Casini, Silvia. ‘Beyond the Neuro-Realism Fallacy. From John R. Mallard’s Hand-Painted MRI Image of a Mouse to BioArt Scenarios - PubMed’. Accessed 31 May 2025. https://pubmed.ncbi.nlm.nih.gov/30358376/.↩︎

  6. here I’ve slowed it down by 100 times so that the recording isn’t over in 0.01 seconds, I promise the original recording is audible!↩︎

  7. If you, like me, sometimes get (completely safe!) involuntary muscle twitches in MRI scans, that’s what’s going on. The term of art is “peripheral nervous stimulation” (PNS) and sometimes the radiographer has the option to scan slower to possible reduce the amount this happens, so you can let them know.↩︎

  8. We could, and in practice do, simplify the plotting of these by only drawing the leftwards traveling line, but this makes tracking lines after RF pulses more challenging. It’s easier simply to instruct participants to split every line into 3.↩︎