By Noah Schnitzer, Suk Hyun Sung @ Hovden Lab
Code accompanying our paper: Schnitzer, N., Sung, S. H., & Hovden, R. (2020). Optimal STEM Convergence Angle Selection Using a Convolutional Neural Network and the Strehl Ratio. Microscopy and Microanalysis, 26(5), 921-928.
A MATLAB library for quick simulation of the STEM probe and electron Ronchigram, and training of a CNN to assess probe quality from the Ronchigram.
See also: http://ronchigram.com/ (source) for a similar JS/Wasm project.
MATLAB scripts and functions are organized into folders but are mutually dependent -- all subfolders must be added to the path to work properly. assessment
and simulation
functions are well tested for reasonable inputs, dataset_building
scripts are not and should be used cautiously/as examples.
To get started, check out misc/example.m
assessment
: functions to calculate heuristics for aberration functionsindiv_p4_calculator.m
: Calculate the individual aberration phase shift convergence angle for a single aberrationpar_strehl_calculator.m
: Calculate the Strehl ratio converence angle (parallel) for aberrationspi4_calculator.m
: Calculate the total aberration phase shift convergence angle for a single aberrationprobe_sizer.m
: Wrapsresolution_test.m
to calculate 50% probe current diameter for given aberration functions and convergence anglesresolution_test.m
: Poorly named probe size assessment, should be used witheffprobe
optionstrehl_calculator.m
: Calculate the Strehl ratio converence angle for aberrations
CNN
: scripts to train and test CNN on simulated Ronchigramslim_net.m
: Train CNN used in papertransfer_learning.m
: Transfer learn on Alexnet
dataset_building
: scripts and functions to build data sets. Note many parameters are embedded in scripts, have only been tested for limitied inputs.aberration_series.m
: Calculates heuristics as specific aberrations are varied. Used to e.g. find defocus to balance other aberrations.dataset_generator.m
: Generates a dataset with a ~ uniform distibution of convergence angles.defocus_distribution.m
: More slowly generates a dataset with ~ uniform distribution of convergence angles and defocus set to compensate other aberrations.distribution_generator.m
: Subroutine to generate aberrations and dynamically scale to try to get uniform CA distribtion.
misc
: miscellaneous scripts and functions, e.g. utilities and examplesab_set.mat
: Test set of in-focus randomly generated aberrations with a broad range of optimal convergence angles. Read byronchi_game.m
, used for testing network and human performance in paper.colordef.m
: Colors from paperexample.m
: Brief walkthrough for Ronchigram simulation and heuristic calculationget_aberration.m
: Calculates the phase shift for a specific aberrationnormalize_data.m
: Normalizes data to min 0 max 1px_to_ang.m
: Calculates the scale factor Å/px for a given accelerating voltage and simulation dimensionradial_average.m
: Calculates a radial averageronchi_game_labeling.m
: Minimal version of ronchi_game GUI Application for human aperture selection. This version has no feedback and minimal UI for quick labeling of testing data. Requires a fileab_set.mat
in the working directory with a variable abs with containing any number of aberrations. User selections will be saved ingame_res_1.mat
file in the working directory.
ronchi_game
: GUI Application for human aperture selection, with optional feedback.simulation
: functions for STEM probe and Ronchigram simulationaberration_generator.m
: Generates aberrations with random magnitude and angle out to 5th order. Relative scale of magnitudes is based off observations from AC-STEM, Kirkland 2011 Ultramicrosc.aperture_mask.m
: Generates a binary disc of given radiuscalculate_aberration_function.m
: Calculates phase shift for an aberration functioncalculate_probe.m
: Calculates STEM probe given ab phase shift, convergence angleshifted_ronchigram.m
: Calculates a Ronchigram for an aberration function, shift in Ronch center relative to obj aperture, and convergence angleshifted_ronchigram_o.m
: Legacy shifted_ronchigram to match parameters (e.g. grating resize factor) of trained networks.