Acquiring and importing a tomographic tilt series using a Bruker EDS detector.

For any questions, e-mail Zack Gainsforth (zackg@berkeley.edu).

We start with a sequence of EDS acquisitions. We have one Bruker file (angle.bcf) for each stage tilt. angle = whatever the stage alpha is in degrees. These files are all in an input directory.

Let's go!


In [1]:
import sys, os, shutil
import numpy as np
import matplotlib.pyplot as plt
import os

# It annoys me that I have a large screen and these notebooks are a tiny -- narrow -- itsy bitsy column down the middle.
# The following two lines make jupyter notebook use the whole window!  Comment them out if you don't like it.
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))

# I also like images to be bigger than default.
import matplotlib.pylab as pylab
pylab.rcParams['figure.figsize'] = 10, 6  # that's default image size for this interactive session

# Uncomment this line to enable retina display on a Mac.
%config InlineBackend.figure_format = 'retina'



In [5]:
from ncempy.edstomo import preprocess, postprocess, bruker
# If you get a warning about traitsui, ignore it.  We're not using traitsui.

In [3]:
# These are the directories for the different stages of processing.
InputDirectory = os.path.join('Input')
OutputDirectory = os.path.join('Output')
EMDFileName = os.path.join(OutputDirectory, 'TomoData.emd')
if not os.path.isdir(OutputDirectory):
    os.mkdir(OutputDirectory)

# These are the signals we will extract today.
SignalNames = ['HAADF', 'Al_Ka', 'C_Ka', 'Ca_Ka', 'Cr_Ka', 'Fe_Ka', 'Ga_Ka', 'Mg_Ka', 'Na_Ka', 'Ni_Ka', 'O_Ka', 'P_Ka', 'Pt_La', 'S_Ka', 'Si_Ka']

1. Pull the raw signals out of bcf files.

You have to have all the bcf files in one directory and named like this:

-10.bcf
-5.bcf
0.bcf
5.bcf
10.bcf
etc.

The code will automatically construct a list of tilts from the names of the files and sort them according to tilts.


In [4]:
# First we extract the raw signals from the bcf files.  We infer the list of stage tilts from the names of the files.
# The EDS channels will be two binned (meaning each voxel is 2x2x2 voxels summed).  The HAADF channel is unchanged.
bruker.ExtractRawSignalsFromBrukerSequence(InputDirectory=InputDirectory, OutputEMD=EMDFileName)


Extracting Signals:
HAADF has dimensions (21, 256, 256)
EDS has dimensions (21, 256, 256, 2048)
Input/-50.bcf
Input/-45.bcf
Input/-40.bcf
Input/-35.bcf
Input/-30.bcf
Input/-25.bcf
Input/-20.bcf
Input/-15.bcf
Input/-10.bcf
Input/-5.bcf
Input/0.bcf
Input/5.bcf
Input/10.bcf
Input/15.bcf
Input/20.bcf
Input/25.bcf
Input/30.bcf
Input/35.bcf
Input/40.bcf
Input/45.bcf
Input/50.bcf
Writing HAADF tilt stack.
Writing EDS tilt stack.
Created file Output/TomoData.emd

Note that writing the file sometimes takes a while. Be sure to wait for the last cell to complete! It will say "Created file Output/TomoData.emd" when it is done.

After the emd file is written you can use the h5ls tool to examine the structure.

> h5ls -r Output/TomoData.emd

/                        Group
/comments                Group
/data                    Group
/data/EDS_TiltStack      Group
/data/EDS_TiltStack/data Dataset {21, 256, 256, 2048}
/data/EDS_TiltStack/dim1 Dataset {21}
/data/EDS_TiltStack/dim2 Dataset {256}
/data/EDS_TiltStack/dim3 Dataset {256}
/data/EDS_TiltStack/dim4 Dataset {2048}
/data/HAADF_TiltStack    Group
/data/HAADF_TiltStack/data Dataset {21, 256, 256}
/data/HAADF_TiltStack/dim1 Dataset {21}
/data/HAADF_TiltStack/dim2 Dataset {256}
/data/HAADF_TiltStack/dim3 Dataset {256}
/microscope              Group
/sample                  Group
/user                    Group

In [6]:
!jupyter-nbconvert --to html 'ConvertBrukerToEMD.ipynb'


[NbConvertApp] Converting notebook ConvertBrukerToEMD.ipynb to html
[NbConvertApp] Writing 285005 bytes to ConvertBrukerToEMD.html

In [ ]: