Difference between revisions of "Neighborhood analysis"
(24 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
= Concept = | = Concept = | ||
− | The neighborhood analysis is a tool available in Dynamo that is meant to help describe the local spatial relationships of particles, especially after STA. As such, it is implemented in Dynamo as a function that analyses particles through their [[table | alignment | + | The neighborhood analysis is a tool available in Dynamo that is meant to help describe the local spatial relationships of particles, especially after STA. As such, it is implemented in Dynamo as a function that analyses particles through their [[table | alignment table]]. |
− | Aligned particles are described [[Euler angles convention | by their euler angles]] and their aligned position. If two particles are close enough to be considered neighbors, they form a pair. The computation of the relative geometries of all pairs | + | Aligned particles are described [[Euler angles convention | by their euler angles]] and their aligned position. If two particles are close enough to be considered neighbors, they form a pair. The computation of the relative geometries of all pairs is the neighborhood analysis. |
− | A simplified 2D example with only three particles is presented with the following | + | A simplified 2D example with only three particles is presented with the following figures. The left part of the figures represents the real space in the tomogram, while the right graph present the neighborhood analysis space. |
− | [[File:neigh_fig1.png|centre|thumb|400px| Simplified example. We have three particles i,j,k with each their aligned position and orientation. While the tomogram has a global reference system, each particle | + | [[File:neigh_fig1.png|centre|thumb|400px| Simplified example. We have three particles i,j,k with each their aligned position and orientation. While the tomogram has a global reference system, each particle expresses its own [[Table convention#Convention interpretation | implicit reference system]] (red lines). Particles i, j and k are close to each other and so will be taken as neighbors of each other.]] |
− | [[File:neigh_fig2.png|centre|thumb|400px| Since particle defines its own reference system, that can be used to express the other particles. Here particle i "sees" its neighbors j and k. As such, the pair (i,j) and (i,k) are noted in the neighbohood analysis plot.]] | + | [[File:neigh_fig2.png|centre|thumb|400px| Since each particle defines its own reference system, that reference system can be used to express the other particles. Here particle i "sees" its neighbors j and k. As such, the pair (i,j) and (i,k) are noted in the neighbohood analysis plot.]] |
[[File:neigh_fig3.png|centre|thumb|400px| We can do the same with particle j. The new pairs will be (j,i) and (j,k).]] | [[File:neigh_fig3.png|centre|thumb|400px| We can do the same with particle j. The new pairs will be (j,i) and (j,k).]] | ||
[[File:neigh_fig4.png|centre|thumb|400px| And with particle k. The new pairs will be (k,i) and (k,j).]] | [[File:neigh_fig4.png|centre|thumb|400px| And with particle k. The new pairs will be (k,i) and (k,j).]] | ||
− | [[File:neigh_fig5.png|centre|thumb|400px| If there is a repeating geometric relationship between close particles, then this would be reflected by the presence concentrations points in the | + | [[File:neigh_fig5.png|centre|thumb|400px| If there is a repeating geometric relationship between close particles, then this would be reflected by the presence of concentrations points in the neighborhood plot.]] |
− | It is important to note that the pair (i,j) is not | + | It is important to note that the pair (i,j) is not necessarily a sign flip of the the pair (j,i), even through they express the same distance vector (with opposite sign) in the tomogram. This is because the reference systems of i and j have different independent orientations to each other! |
= Function call= | = Function call= | ||
Line 33: | Line 33: | ||
− | The output <code>analysisOfmyTable</code> is a structure. It contains three main fields: <code>.originalTable</code>, <code>.coupleTable</code> and <code>.couples</code>. <code>.originalTable</code> is merely a copy of the input table. <code>.coupleTable</code> is the table that records the geometric relationships between pairs of particles | + | The output <code>analysisOfmyTable</code> is a structure. It contains three main fields: <code>.originalTable</code>, <code>.coupleTable</code> and <code>.couples</code>. <code>.originalTable</code> is merely a copy of the input table. <code>.coupleTable</code> is the table that records the geometric relationships between pairs of particles and in particular the distance vector is recorded in columns 24, 25 and 26 (x,y,z following the Dynamo table conventions). <code>.couples</code> records for each pair the indexes of the corresponding particles in the original table. As such, <code>.coupleTable</code> will have the same number of rows as <code>.couples.tbl</code>. |
= Visualization= | = Visualization= | ||
− | The results of a neighborhood analysis can be inspected in different ways. A practical method is to use the <code>dtview</code> functionality of the | + | The results of a neighborhood analysis can be inspected in different ways. A practical method is to use the <code>dtview</code> functionality of the output <code>analysisOfmyTable.coupleTable</code>. |
[[File:dtview_GUI_1.png|centre|thumb|400px| The dtview GUI can be used to inspect any table. When inspecting neighborhood analysis tables the fields x, y and z indicate the relative distances of all pairs.]] | [[File:dtview_GUI_1.png|centre|thumb|400px| The dtview GUI can be used to inspect any table. When inspecting neighborhood analysis tables the fields x, y and z indicate the relative distances of all pairs.]] | ||
− | <code>dtview</code> | + | <code>dtview</code> allows for the creations of lassos in 2D scatterplots. This tool can be access by right-clicking the 2D scatter figure. A lasso can then by manually drawn. |
− | [[File:dtview_GUI_3.png|centre|thumb|400px| The lassos can be used to extract the indices of the | + | [[File:dtview_GUI_3.png|centre|thumb|400px| The lassos can be used to extract the indices of the pairs that accumulate in a certain area. This information can than me paired with the <code>.couples</code> information to recover the information of each particle involved from the original table.]] |
− | The pairs inside the lasso can be | + | The pairs inside the lasso can be saved by righ-clicking a lasso and selecting a "Subtable with points inside of lasso ->" option. If the "memory" option is selected, a variable called <code>mbtblSelection</code> will be created in the MATLAB workspace. |
+ | |||
+ | |||
+ | <code>dtview</code> has other drawing options, such as 2D and 3D histograms. However, it is sometimes more convenient to represent a neighborhood analysis has a 2D heatmap in order to to highlight accumulation areas. For an example on how to do so, the x-y heatmap of a neighborhood analysis can be generated by: | ||
+ | |||
+ | <pre> | ||
+ | nbins=[50 50]; | ||
+ | [N,C]=hist3([analysisOfmyTable.coupleTable(:,25), analysisOfmyTable.coupleTable(:,24)],nbins); | ||
+ | contourf(C{1},C{2},N); | ||
+ | xlabel('Relative pairwise X distance [px]'); | ||
+ | ylabel('Relative pairwise Y distance [px]'); | ||
+ | title(['Heatmap of Neighborhood analysis']); | ||
+ | axis equal; | ||
+ | </pre> | ||
+ | |||
+ | = Example= | ||
+ | |||
+ | An in-depth walkthough on the use of the neighborhood analysis is available at [[Walkthrough on hexagonal lattice coherence through neighborhood analysis | this page]]. |
Latest revision as of 11:51, 29 April 2024
Contents
Concept
The neighborhood analysis is a tool available in Dynamo that is meant to help describe the local spatial relationships of particles, especially after STA. As such, it is implemented in Dynamo as a function that analyses particles through their alignment table.
Aligned particles are described by their euler angles and their aligned position. If two particles are close enough to be considered neighbors, they form a pair. The computation of the relative geometries of all pairs is the neighborhood analysis.
A simplified 2D example with only three particles is presented with the following figures. The left part of the figures represents the real space in the tomogram, while the right graph present the neighborhood analysis space.
It is important to note that the pair (i,j) is not necessarily a sign flip of the the pair (j,i), even through they express the same distance vector (with opposite sign) in the tomogram. This is because the reference systems of i and j have different independent orientations to each other!
Function call
The most basic way to call the neighborhood analysis function is:
analysisOfmyTable = dpktbl.neighborhood.analize(myTable)
Where myTable
is the table describing the set of aligned particle in the usual Dynamo format.
dpktbl.neighborhood.analize
has a set of optional parameters:
- distance: this is the maximal allowed distance between particles to still be analysed. The distance is measured in pixels between the centers of the particles after alignment. The default value is 5 pixels. This value should be kept reasonably small, so as to highlight short-range repeating spatial relationships as well as to reduce computing time.
- modelColumn: this indicates which column of the table is used to separate the particles into groups. Particles in different groups cannot be considered as neighbors. The default column is 21 ("reg").
- secondTable: this options changes the behaviour of the function. If this option is active, the distribution of particles defined in the second table will be analysed as seen from the particles in the original table. This option is deactivated by default.
- indices: this options allows for the analysis of only a subset of the groups defined by modelColumn. By default all groups are analysed.
The output analysisOfmyTable
is a structure. It contains three main fields: .originalTable
, .coupleTable
and .couples
. .originalTable
is merely a copy of the input table. .coupleTable
is the table that records the geometric relationships between pairs of particles and in particular the distance vector is recorded in columns 24, 25 and 26 (x,y,z following the Dynamo table conventions). .couples
records for each pair the indexes of the corresponding particles in the original table. As such, .coupleTable
will have the same number of rows as .couples.tbl
.
Visualization
The results of a neighborhood analysis can be inspected in different ways. A practical method is to use the dtview
functionality of the output analysisOfmyTable.coupleTable
.
dtview
allows for the creations of lassos in 2D scatterplots. This tool can be access by right-clicking the 2D scatter figure. A lasso can then by manually drawn.
The pairs inside the lasso can be saved by righ-clicking a lasso and selecting a "Subtable with points inside of lasso ->" option. If the "memory" option is selected, a variable called mbtblSelection
will be created in the MATLAB workspace.
dtview
has other drawing options, such as 2D and 3D histograms. However, it is sometimes more convenient to represent a neighborhood analysis has a 2D heatmap in order to to highlight accumulation areas. For an example on how to do so, the x-y heatmap of a neighborhood analysis can be generated by:
nbins=[50 50]; [N,C]=hist3([analysisOfmyTable.coupleTable(:,25), analysisOfmyTable.coupleTable(:,24)],nbins); contourf(C{1},C{2},N); xlabel('Relative pairwise X distance [px]'); ylabel('Relative pairwise Y distance [px]'); title(['Heatmap of Neighborhood analysis']); axis equal;
Example
An in-depth walkthough on the use of the neighborhood analysis is available at this page.