4.2. core.py

Module for the ‘Project’ class that handles a project instance.

class core.Project(filename_full, debug_obj=None, species_dict=None)

The main API through which to build and access the data extracted from HAADF-STEM images.

Parameters
  • filename_full (str) – The full path and/or relative path and filename of the .dm3 image to import. A project can be instantiated with filename_full=’empty’, but this is only meant to be used as a placeholder. Use Project.import(filename, file_type) to instantiate projects from other files than dm3.

  • debug_obj (GUI.MainUI()) – (Optional, default=None) An reference to an AutomAl 6000 GUI.MainUI() instance.

  • species_dict (dict) – (Optional, default=None) A species dictionary for the project. If none is provided, core.Project.default_species_dict is used.

calc_area_gamma()

Calculate the area averaged pixel intensity

calc_avg_gamma()

Calculate average intensity for every vertex based on image information.

calc_avg_pixel_value()

Calculate the average pixel intensity of the image.

column_characterization(starting_index, search_type=0, ui_obj=None)

Column characterization algorithm.

Assumes a starting_index, that is taken to be an Al column in the matrix. The search_type enables access to the different sub-proccesses of the algorithm. These are:

search_type

Process

0

The full column characterization

1

The most important parts of the algorithm

2

Finalize the parameter state

3

Spatial mapping

4

Identify edge columns

5

Not in use

6

Zeta analysis

7

Active model predictions from alpha angles

8

Particle detection

9

Calculate normalized gamma attributes

10

Evaluate advanced species

11

Active model predictions from all attributes

12

Reset all probability vectors

13

Reset user-set columns

14

Look for intersections

15

Not in use

16

Build the vertex maps of the graph (including out-neighbourhoods)

17

Build the vertex maps of the graph (excluding out-neighbourhoods)

18

Run untangling (including strong)

19

Run untangling (excluding strong)

20

Experimental zeta analysis

21

Calculate area gamma

22

Not in use

23

Not in use

Columns that have been set by the user will not be have their species changed by the algorithm. Apply search_type=13 to reset columns if needed.

Parameters
  • starting_index (int) – Index of a vertex that is a part of the matrix.

  • search_type (int) – (optional, default=0) Which sub-process to access.

column_characterization_2(starting_index, sub_method=0, ui_obj=None, indent='', supress_logging=False)

The full algorithm consist of many pieces, which through the interface of this method, can be accsessed as a full sequence, or induvitiualliy if needed.

Calling this method will do one of the following things:

————— ————————— —————————————————————– sub_method Method title descripiton ————— ————————— —————————————————————– o (default) Full algorithm Applies the full algorithm as intended 1 Initialization Applies the nessercary initialization of the image 2 recurring section Graphs and statistics will battle for convergence 3 Finalization section Make summaries and checks the integrity of the data 4 Spatial mapping Calculate projected separation matrix 5 Edge detection Label vertices close to the edge of the graph 6 Graph mapping Assign out-neighbourhoods 7 Apply alpha model Predict adv. species from alpha angles (zeta selected) 8 Apply full model Predict adv. species from all attributes 9 Precipitate detection Find precipitate 10 Calculate gamma Calculate normalized gamma 11 Zeta-analysis Determine zeta values (plane association) 12 Weak untangling Run weak untangling 13 Strong untangling Run strong untangling 14 Evaluate adv. species Determine adv. species from at. species 15 Reset probability vectors Reset probability vectors 16 Reset user-set columns Unset all user species determinations 17 Find intersections Find and terminate arc intersections 18 Graph mapping Map in-neighbourhoods only 19 Calculate area gamma Calculate alternative intensity measure 20 Refresh graph Refresh graph parameters 21 test version Experimental version 22 Zeta untangling Zeta untangling 23 Alpha (district) Alpha model from district angles 24 Alpha (partners) Alpha model from partner angles 25 Alpha (Out) Alpha model from out-neighbour angles ————— ————————— —————————————————————–

column_detection(search_type='s', plot=False)

Column detection algorithm.

The search type indicates the termination condition of the column detection (see table).

———————————– —————————————————— search_type explanation ———————————– —————————————————— s Search until self.search_size columns are found. t Search until self.search_mat.max() < self.threshold. ———————————– ——————————————————

This algorithm will check the column state and continue appropriately if there are already columns present. It will also “roll back” columns if the threshold value is higher than the peak gamma of the already existing columns. This means that if the initial threshold is guessed too low, then it will remove columns.

Parameters
  • search_type (str) – (Optional, default=’s’) The algorithm termination condition.

  • plot (bool) – (Optional, default=False) Plotting on/off.

find_edge_columns()

Locate vertices that are close to the edge of the image.

These vertices get special treatment throughout the program because information about their surroundings will be incomplete. This method will find all vertices that are within a distance 6 * self.r from the edge, and set the field self.graph.vertices[i].is_edge_column = True.

get_alloy_string()

Generate a string representation of the alloy based on the alloys present in the species dictionary.

:returns A species string on the form Al-Mg-Si. :rtype str:

get_im_length_from_spatial(spatial_length)

Returns the a spatial length in image pixel length.

Parameters

spatial_length (float) – A spatial length in pm

Returns An image length in px

Rtype float

get_spatial_length_from_im(im_length)

Returns the an image length in spatial length.

Parameters

spatial_length (float) – An image length in px

Returns A spatial length in pm

Rtype float

static load(filename_full, supress_logging=False)

Load an instance from a pickle-file.

Parameters

filename_full (str) – Path-name of the file to be loaded.

Returns

project instance.

Return type

core.Project

make_heat_map(attribute, kernel_size=1, kernel_step_size=1, measure_type='variance', kernel_type='square', title='heat map')
Parameters
  • attribute (str) –

  • kernel_size

  • kernel_step_size

  • kernel_shape

Returns A heat map of the image

Rtype numpy.array

normalize_gamma()

Find the mean of the intensity of the Al-matrix, and scale all intensities.

Scale all intensities such that the mean of the Al-matrix is a fixed point. Store the result in each vertex i self.graph.vertices[i].normalized_peak_gamma and self.graph.vertices[i].normalized_avg_gamma fields.

redraw_search_mat()

Redraw the search matrix.

report(supress_log=True)

Build a string representation of the current instance.

Returns A project summary

Rtype str

reset_graph()

Reset the graph (delete all vertices)

reset_graph_information()

Reset graph (except all vertices and their 2D position)

save(filename_full, supress_logging=False)

Save the current project as a pickle file.

Parameters

filename_full (str) – Path and name of save-file. The project will be pickled as filename_full without any file-extension identifier.

vertex_report(i, supress_log=False)

Build a string representation of vertex i.

Returns A vertex summary

Rtype str