MTEX has no graphical user interface. You work with MTEX by writing MATLAB scripts: text files that keep the commands for an analysis in a reproducible order.
A typical script follows five steps.
- Import data.
- Inspect the imported data.
- Correct the data when necessary.
- Analyze the data.
- Plot and export the results.
During these steps, MATLAB stores data under names called variables. Each variable has a type, called its class, which determines the operations that can be applied to it. MTEX provides classes for objects such as vectors, rotations, EBSD data, grains, and orientation distribution functions (ODFs). The Function Reference lists all MTEX classes and functions.
Import and inspect data
Import functions create variables automatically. Here, fileName stores the path to an example CTF file. The second command imports that file and stores the result in the variable ebsd.
fileName = [mtexEBSDPath filesep 'Forsterite.ctf'];
ebsd = EBSD.load(fileName,'EulerCorrection', ...
rotation.byAxisAngle(xvector,180*degree))ebsd = EBSDsquare (y↓→x, row↓→col)
Phase Orientations Mineral Color Symmetry Crystal reference frame
0 58485 (24%) notIndexed none
1 152345 (62%) Forsterite LightSkyBlue mmm
2 26058 (11%) Enstatite DarkSeaGreen mmm
3 9064 (3.7%) Diopside Goldenrod 12/m1 X||a*, Y||b, Z||c
Properties: bands, bc, bs, error, mad, oldId
Scan unit : um
X × Y × Z : [0 → 36550] × [0 → 16750] × [0 → 0]
Normal vector: (0,0,1)
Square grid :336 × 732Leaving off the semicolon displays a summary of ebsd in the Command Window. This is a quick inspection step: the summary reports the phases, numbers of orientations, properties, map extent, and grid size. The 'EulerCorrection' option also corrects the imported orientations by the specified rotation.
Plot the phase map
Pass a variable to an MTEX function to operate on its data. The command below passes ebsd to plot and colors every indexed measurement by its phase.
plot(ebsd)
Notice the large blue forsterite regions, the smaller green enstatite and yellow diopside regions, and the white notIndexed areas. A notIndexed measurement is one whose diffraction pattern could not be indexed.
Reconstruct and inspect grains
The next command segments the measurements into grains. A grain is a phase-homogeneous, spatially connected region of EBSD measurements produced by segmentation. The 'minPixel' option excludes indexed grains with fewer than three measurements.
grains = calcGrains(ebsd,'minPixel',3)grains = grain2d (y↓→x)
Phase Grains Pixels Mineral Symmetry Color
0 8 811 notIndexed none
1 490 151675 Forsterite mmm LightSkyBlue
2 223 25747 Enstatite mmm DarkSeaGreen
3 229 7674 Diopside 12/m1 Goldenrod
boundary segments: 35830 (1.7e+06 µm)
inner boundary segments: 285 (13165 µm)
triple points: 1567
Properties: meanRotation, GOSThe returned grain2d object is stored in grains. Its Command Window summary reports the number of grains in each phase and information about their boundaries.
Add the grain boundaries
Plotting on the same axes connects the result of the analysis to the phase map. hold on preserves the existing map while the boundary is added, and hold off ends that plotting state.
hold on
plot(grains.boundary,'lineWidth',2)
hold off
Notice that the dark lines trace changes between neighboring grains. Some lines lie within one color because grains of the same phase can still have different orientations.
Organize a script
An MTEX script is a sequence of MATLAB and MTEX commands. Add comments on lines beginning with % to record why each command is present. These explanations make the analysis understandable when the script is reopened.
Divide a longer script into sections with lines beginning with %%. In the MATLAB Editor, Ctrl+Enter runs the current section, while Ctrl+Shift+Enter runs it and advances to the next section. Running one section at a time lets you inspect each intermediate variable before continuing.
References
- MathWorks, Create Scripts, MATLAB documentation. It explains script files, comments, sections, and the Editor commands used on this page.
Next
Continue with Lists and Indexing to select parts of an MTEX variable and apply one operation to many stored objects.
Citing this page.
This page is part of the documentation of
MTEX, a free and open
source MATLAB toolbox for analyzing and modeling crystallographic textures.
It was written by The MTEX Developers and is published at
https://mtex-toolbox.github.io/MTEXScripts.html.
If you use MTEX, or reuse text or figures from this page, in your research,
please cite
F. Bachmann, R. Hielscher, H. Schaeben: Texture Analysis with MTEX - Free and Open Source Software Toolbox, Solid State Phenomena 160 (2010), 63-68. 10.4028/www.scientific.net/SSP.160.63
BibTeX
@article{bachmann2010mtex,
author = {F. Bachmann and R. Hielscher and H. Schaeben},
title = {Texture Analysis with MTEX - Free and Open Source Software Toolbox},
journal = {Solid State Phenomena},
volume = {160},
pages = {63-68},
year = {2010},
doi = {10.4028/www.scientific.net/SSP.160.63},
url = {https://doi.org/10.4028/www.scientific.net/SSP.160.63}
}
Other papers describing specific MTEX methods are listed under Publications — please cite the one that best fits your application. The MTEX source code is licensed under the GNU General Public License v2.0; the text and figures of this documentation are licensed under CC BY 4.0, which permits reuse — including by automated systems — provided The MTEX Developers and this page are credited.