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']
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)
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'
In [ ]: