pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
79 stars 30 forks source link

Reader of EBSD signal from a directory of EBSD pattern images #571

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

Add reader of an EBSD signal from a directory EBSD pattern images, assuming they all have the same shape and data type, closing #459. This adds a dependency on imageio (which HyperSpy already has).

The navigation/map shape is attempted read from the filenames, possibly specified in a regular expression passed to xy_pattern, like r"-x(\d+)y(\d+).tif", and if this does not work, the returned signal will have one navigation dimension.

You might find this reader useful, @IMBalENce.

Note that no metadata is read from the image files.

Progress of the PR

Minimal example of the bug fix or new feature

>>> dir_data = "/home/hakon/directory_with_patterns/"
>>> import os
>>> os.listdir(dir_data)
['pattern_x0y1.bmp',
 'pattern_x0y2.bmp',
 'pattern_x1y1.bmp',
 'pattern_x1y0.bmp',
 'pattern_x1y2.bmp',
 'pattern_x0y0.bmp',
 'pattern_x2y0.bmp',
 'pattern_x2y1.bmp',
 'pattern_x2y2.bmp']
>>> import kikuchipy as kp
>>> s = kp.load(os.path.join(dir_data, "*.bmp"))
>>> s
<EBSD, title: patterns , dimensions: (3, 3|60, 60)>

For reviewers