This is the first of two posts - the second on reconstructing holograms using Python can be found here.

When learning about magnets and magnetic fields, you have probably seen visualizations similar to these1 which represent how the magnetic field extends outside a rectangular magnet

Magnetic field lines

The left represents how iron filings agglomerate when sprinkled around a magnet as they roughly align to the magnetic field, a common method to directly “see” the magnetic field around larger magnets. In the middle the magnetic field is represented with a series of magnetic field lines which are drawn along lines of constant field strength, while the rightmost image shows how an array of freely rotating magnets (e.g. compasses) would align themselves in the same magnetic field.

This is usually presented for magnets large enough hold in your hand, but it is actually possible to directly measure the magnetic field all the way down at the nano scale in a Transmission Electron Microscope or TEM, just like this:

magnetic field lines around magnetite nanoparticle

The above image shows a magnetite nanoparticle around 90 nm wide where the contour lines represent the magnetic field around the particle as measured directly in the microscope. Iron filings and tiny compasses work great for magnets large enough to handle, but what do we do when working on the nanoscale?

Below i will explain a method known as Off-Axis Electron Holography and how it can be used to measure and visualize the magnetic field around magnetic nanoparticles in the TEM to make images like the above. Much of what follows is based on this book chapter2 on electron holography of magnetic materials which I recommend reading if you are interested in the subject.

The data shown was acquired as part of my bachelors thesis3 at DTU Nanolab (previously Center for Electron Nanoscopy) several years back. I recently went back to revisit the subject and redo (and improve) in Python out of curiousity and decided do this writeup to share with anyone why might be interested.

This post is part one of two and covers some TEM fundamentals and relevant mathematics. For numerical calculations, take a look at part two where we reconstruct holograms using Python.

Very brief intro to the TEM

A Transmission Electron Microscope in conventional operation is very similar to a typical optical microscope, but instead of using light waves we use a beam of electrons. Since electron waves generated at high voltages have a much shorter wavelength than visible light, we can use it to see much smaller things. As an example, blue light has a wavelength around , while an electron will have a wavelength around at acceleration voltage – for reference a hydrogen atom has a diameter of around 4.

The diagram below shows a simplified schematic of a TEM in bright field (BF) mode, where an electron gun at the top provides a beam of coherent electrons which are condensed to a uniform plane wavefront before passing through a sample. After this the beam is focused, various apertures can be inserted, and the image is formed in the image plane on the bottom, where we place 2D detector to save the image.

Simplified TEM diagram

Unlike in the optical microscope, the lenses are not made from glass or any physical material. Instead, we use magnetic lenses to focus the electron beam – Essentially a symmetric bunch of coils with adjustable current going through them to create a magnetic field. The reason we can manipulate the electrons with magnetic fields is due to the Lorentz force.

With a strong field of a certain shape we can use this to focus our electron beam. This is also the reason we are able to visualise the magnetic field of a sample when using electrons, as the field around a magnetic particle deflects the electrons slightly and change their phase.

I am barely scratching the surface of the subject for the sake of brevity - have a look at the very detailed and pedagogical DoITPoMS from the University of Cambridge on the TEM if you want more details.

Electron beam as a wavefunction

Mathematically we can describe the electron beam at any point in the image plane as a plane wave with amplitude and phase in a complex exponential phase term

In typical operating conditions, when recording the image on a detector the phase information is lost as the intensity distribution is the absolute square of the wavefunction, where the conjugated exponential terms cancel out

In other words we’re only recording the square of the amplitude of the wave, which simply tells us how many electrons reached each pixel on the sensor, regardless of their phase. This is plenty for most uses, but in our case we actually need to know the phase of the electrons.

When an electron wave passes through a sample the phase of the wave will experience a phase shift. For thin magnetic samples we can express the phase shift at a given point after passing through a sample as the sum of an electric and magnetic contribution

arises from the electron beam intereacting with the electrons in the sample, while depends on the in-plane component of the magnetic field from the sample due to the Lorentz force. We note that since the force is proportional to the cross product , the moving charges are only affected by the components of the B-field orthogonal to the movement direction. Since the electrons are moving from the top and down into the sample they will thus only be affected by the in-plane component of the B-field. If we imagine a magnetic field pointing directly upwards from the sample, parallel to the movement of electrons there would be no phase shift, while a field perfectly orthogonal, along the sample plane, would show up fully in the phase shift.

The phase shift is thus our key to imaging the magnetic field of our particles, and we need to figure out how to record it. As luck would have it there are workarounds for this problem.

Holography in the electron microscope

In case you are wondering, holo graphy comes from Greek and can be translated as whole drawing - in microscopy and this often refers to the fact that holographic methods preserve the phase. The “whole” in cool shiny 3D holograms on old CD’s, toys, credit cards etc. refers to the fact that they capture the “whole” three dimensional scene.

The challenge for us is to find a way to make sure the phase information of our electron wave is not lost as we record it on the detector. Below is a very simplified diagram of a TEM in a setup used for a method called Off-Axis Electron Holography.

Holography schematic

The green part of the beam which passed trough the sample we’ll call , and the other half which goes unhindered through the vacuum is our reference wave, .

Like before we generate a coherent plane wave of electrons, but now we only send part of it through the sample (green part). Further down, after the objective lens5, is the key part of the setup: the biprism. It is simply a wire going all the way through the middle of the electron beam with a plate on each side along the length of the wire outside the beam. When applying a positive charge to the beam and negative charge to the plates the electrons are repelled by the plates and attracted to the wire.

So we have essentially split the whole wavefront in two parts which we can bend towards each other causing them to overlap, and this is where the magic happens. When two coherent (in-phase) plane waves meet each other at an angle a sinusoidal interference pattern will appear as illustrated in the bottom of the diagram and can be recorded with out image sensor. The pattern is highly sensitive to small differences in phase between the two waves and will thus have information relating to and embedded in it.

So how do we extract the phase?

Mathematics of the phase retrieval

Let’s formalise a bit on what was described above.

Contributions to the phase shift

For a sample with no external charge distributions or external electric fields, the electrostatic contribution to the phase shift can be expressed in terms of a mean inner potential which is assumed constant throughout the sample.

where is a constant dependent on the microscope acceleration voltage6 and the thickness profile of the sample projected in the beam direction.

The magnetic phase shift can be expressed as

where is the magnetic vector potential, specifically the component parallel to the electron beam direction. The gradient of the magnetic phase then gives us a direct relationship to the B-field form the phase shift

where is the total projection of the B-field components perpendicular to electron beam direction through the sample area

As such, the phase shift of the electron beam after passing through a sample can be described as

Our goal now is to extract just the magnetic phase shift of the electron beam and we need to get rid of in some way.

If we can exactly reverse the magnetic field of our particle, the magnetic phase shift will also be reversed from to while is unchanged. In the TEM this can be done by applying a strong magnetic field in one direction, record an image, then apply a strong field in the opposite direction to reverse the magnetisation of the particle, and record another image.

We can then record two images where the magnetisation of the particle is exactly reversed between them and then subtract the phase shifts. Then cancels out and leaves just the magnetic information

Now we just remember to divide by 2 and we have our magnetic phase shift!7

Preserving the phase information

Remembering that the electron beam at a given point in the image plane can be described as a wavefunction , we now introduce a plane reference wave that only passes unhindered through vacuum

with being a two-dimenstional reciprocal space vector determining the tilt of the reference wave. This is what we do with the biprism in the off-axis holography setup, when we split the beam into two parts and make them overlap. In the overlap the wavefunction is simply a superposition of the two wavefunctions leading to the following intensity distribution

This can be evaluated as

The phase information is now preserved directly in the intensity distribution on our image sensor! We have the amplitude of the wave passing through the sample (as before), the amplitude of the reference wave , and finally an oscillating term8 which contains the phase of the sample beam .

Let’s see how it looks in practice. Below is a holographic image of a magnetite nanoparticle which is about 90 nm wide. It is actually shaped like an octahedron but as it is lying down the projection through the particle appears as a hexagon. The large round shape in the top left half of the image is a hole in a thin carbon substrate9, and our particle is just barely holding on to the edge of this hole.

Magnetite particle with interference pattern

The thin lines all across the image is a direct result of the interference of the two beams. In areas with even background it closely matches a cosine function as expected. Note that the much larger parallel lines (top left) are an artifact from diffraction fringes at the edges of the biprism wire and not directly related to the phase. Let’s look at a closeup of the particle

Closeup of interference pattern

Notice how the lines are not straight everywhere. If we follow one from top to bottom, we see it bends at the top end of the particle, continues in a mostly straight line and then bends back close to its original position. This bending is directly due to the phase shift of the electron beam due to the particle - at the edges the thickness varies causing the bend, while the center of the particle is fairly even, giving straight lines. The phase shift is primarily from the electric interaction as it tends to be stronger than .

Recovering just the phase

To separate the phase term, we turn to the trusty Fourier transform, which I wrote a bit about here. Now, as the Fourier transform is a linear operator, the transform of a sum of terms is equivalent to the sum of individually transformed terms:

With a bit of mathematical gymnastics the last term in the expression can expressed as a convolution with a delta function

where denotes the convolution operator. The proof of the above is left as an exercise to the reader.

It is slightly complex, but here’s what you need to take away from the above: When convolving a delta function with a fourier transform, it essentially becomes “centered” at the point where the argument of the delta function is zero; . Thus if convolving with the center will be at .

So now we have two amplitude terms with no phase information, and centered around in the middle of the reciprocal space in the fourier transformed image. They are more or less the regular bright field image you would get without the special technique. But now we also have two phase terms, which are the complex conjugates of each other, centered at and respectively. These will show up at opposite sides, away from the center of the fourier transformed image.

Visually it looks like this. Below is shown the 2D Fast Fourier Transform of the hologram image

FFT with sidebands

A large peak in the center with two distinct peaks away from center at opposite sides. These are the sidebands mentioned before, and the vector is the vector pointing from the center and out to these sidebands. The visible line from the center all the way to the sideband comes from the diffraction fringes from the biprism as mentioned earlier.

Note that the Fourier transform of a real valued image results in complex values, i.e. each pixel has a real part and imaginary part . When showing the image here, we are seeing the absolute value, or amplitude, of this complex image.

We can now select a sideband from the full image, i.e. we pick out just the term

Sideband in the FFT

The horizontal and vertical streaks are artifacts from the edges of the image and will not affect our analysis. The center of this new image is now at and the convolution with the delta function becomes leaving us with

By performing an inverse Fourier transform the image is now simply

We are now liberated of the other terms and we are one important step closer to isolating itself. Exciting!

Amplitude and phase of a complex number

Our sideband is now a complex function on the exponential or polar form where is the amplitude and the phase. Mathematically we can directly read off the amplitude as and the phase of our image as but numerically our data is stored in another form.

The (Inverse) Fast Fourier Transform used to numerically perform fourier transforms gives us an image where complex numbers are in the cartesian form , and thus each pixel has a real value and imaginary value . Luckily the conversion comes from basic trigonometry. The amplitude is simply the pythagorean length of the complex number

and the phase is the angle

That’s it, we now have everything we need to recover the phase! The reconstructed phase of our particle looks like this

Phase from sideband

The above image (besides artifacts) is a direct image of the phase of the electron beam where it reached the detector in the microscope, reconstructed from the shown hologram. We would expect the magnetic field somewhere outside the particle, so where is it? The electric contribution is much larger than the magnetic so it gets a bit lost in the signal. To see it properly we still need to subtract an image of the same particle with reversed magnetic field, meaning we still have some work to do.

Summary

We’ve gone briefly through the workings of a transmission electron microscope and seen how the electron beam can be described as a wave. With a special setup in the microscope which introduces a reference wave, the interference pattern in the overlap of these waves enables us to record the phase information of the beam passing through the sample. Using some Fourier transform magic we walked through the mathematics of extracting the phase from this pattern and demonstrated it for a single particle.

The remaining work to isolate only the magnetic contribution to the phase shift is mainly computational. I continue this in the post on reconstructing holograms using Python where I walk through the code used to go from raw holograms to finished magnetic phase images.


  1. Diagrams of the magnetic field around a bar magnet from Wikimedia Commons 

  2. Takeshi Kasama, Rafal E. Dunin-Borkowski and Marco Beleggia (2011). Electron Holography of Magnetic Materials, Holography - Different Fields of Application, F. A. Ramirez (Ed.), IntechOpen, DOI: 10.5772/22366 

  3. Supervisors: Takeshi Kasama, Marco Beleggia, Cathrine Frandsen. On a personal note: Takeshi Kasama passed away a few years back at a much too young age. He did an amazing job as supervisor on my bachelor’s project. He had a knack for teaching and for making me “learn how to learn”, and I am grateful to have been under his guidance. He has definitely shaped my approach to science and physics and how I explain things to others, so if you like what you read send him a friendly thought! 

  4. Strictly speaking an atom has a fuzzy undefined size, but the diameter from the Bohr model gives a useful sense of how far from the center of a hydrogen atom you are likely to find its accompanying electron. 

  5. Since we are trying to image the weak magnetic field of our nanoparticles, the objective lens is now a Lorentz lens, as this does not generate a magnetic field at the sample. 

  6. With acceleration voltage as we have where is the relativistic electron wavelength and the rest mass energy of the electron. 

  7. There are also other ways of removing the electric phaseshift , such as directly simulating from detailed sample information and subtracting that. It can also be useful on its own, e.g. for accurate measurements of particle thickness, but we will not consider this for now. 

  8. Using some identities of complex exponentials we can also write the phase term as a cosine term . These sinusoidal interference fringes are what we directly measure in the raw hologram. 

  9. Take a look at Agar scientific for some example images.