In this section we discuss specific operations that are available for EBSD data which are measured on a square or hexagonal grid.

By default MTEX ignores any gridding in the data. The reason for this is that when restricting to some subset, e.g. to a certain phase, the data will not form a regular grid anyway. For that reason, almost all functions in MTEX are implemented to work for arbitrarily aligned data.

On the other hand, there are certain functions that are only available or much faster for gridded data. Those functions include plotting, gradient computation and denoising. The key command to make MTEX aware of EBSD data on a hexagonal or square grid is gridify.

In order to explain the corresponding concept in more detail lets import some sample data.

As we can see already from the phase plot above the data have been measured at an rectangular grid. A quick look at the unit cell verifies this

If we apply the command gridify to the data set

we data get aligned in a 137 x 167 matrix. In particular we may now apply standard matrix indexing to our EBSD data, e.g., to access the EBSD data at position 50,100 we can simply do

It is important to understand that the property of beeing shaped as a matrix is lost as soon as we select a subset of data

However, we may always force it into matrix form by reapplying the command gridify

The difference between both matrix shapes EBSD variables **ebsd** and **ebsdMg** is that not indexed pixels in **ebsd** are stored as the seperate phase **notIndexed** while in **ebsdMg** all pixels have phase Magnesium but the Euler angles of the not indexed pixels are set to nan. This allows to select and plot subregions of the EBSD in a very intuitive way by

## The Gradient

## Hexagonal Grids

Next lets import some data on a hexagonal grid

Indexing works here similarly as for square grids

## Switching from Hexagonal to Square Grid

Sometimes it is required to resample EBSD data on a hex grid on a square grid. This can be accomplished by passing to the command gridify a square unit cell by the option `unitCell`

.

In the above example we have chosen the square unit cell to have approximately the same size as the hexgonal unit cell. This leads to quite some distortions as squares can not reproduces all the shapes of the hexagones. We can reduce this issue by chosing the quare unit cell significantly smaller then the hexagonal unit cell.

It is important to understand that the command gridify does not increase the number of data points. As a consquence, we end up with many white spots in the map which corresponds to orientations that have been set to NaN. In order to fill these white spots, we may either use the command fill which performs nearest neighbour interpolation or the command smooth which allows for more suffisticated interpolation methods.

## Gridify on Rotated Maps

A similar situation occurs if gridify is applied to rotated data.

Again we may observe white spots within the map which we can easily fill with the fill command.