# **Structure Tensor (ST) by OrientationJ** OrientationJ is a powerful tool for analyzing and characterizing fiber properties such as orientation and anisotropy. This guide will walk you through how to use the OrientationJ plugin in FIJI, how to adjust the settings based on your analysis goals, and how to interpret the resulting data. For more detailed information, refer to the official documentation on their website: [OrientationJ Documentation](http://bigwww.epfl.ch/demo/orientation/). ## Getting Started ### 1) Download and install the plugin. First, download the `OrientationJ_.jar` plugin from the documentation website. Once downloaded, drag and drop the file into the "plugins" folder within your FIJI installation directory. Restart FIJI to activate the plugin. ### 2) Accessing OrientationJ After restarting FIJI, you’ll find OrientationJ under the plugins menu. The plugin offers several analysis options, each tailored to different aspects of histology exploration. ### 3) Key parameters for analysis Before diving into the different options, it’s essential to understand two main parameters that you'll need to configure: * **Local Window**: The local window size determines the neighborhood of pixels over which the analysis is performed, essentially acting as a Gaussian kernel. The appropriate window size depends on the anatomical structure you’re analyzing. It's crucial to experiment with different window sizes to find the best fit for your analysis goals. Once you've chosen a local window size, ensure consistency across all analyses for comparability. * **Gradient**: You’ll need to choose a gradient method for the analysis. The Cubic Spline gradient is recommended by the developers for its speed and accuracy, but you can explore other options if needed. ![Captura de pantalla 2024-08-13 a la(s) 4.25.32 p.m.](https://hackmd.io/_uploads/B1ep6LF5C.png) --- Now let's check the analysis options: ## OrientationJ Analysis This is the **qualitative** option of the structure tensor. This analysis will compute a series of images based on the texture of the histology. For this exercise I used a MBP immunofluoresce staining with a close up of the internal capsule in the brain: ![Captura de pantalla 2024-08-13 a la(s) 5.37.16 p.m.](https://hackmd.io/_uploads/r1iZJOYc0.png) In this case, I thick all the boxes to display all the options. What do they mean? * **Gradient-X and Gradient-Y**: These gradients are the first derivatives of the image intensity values in the horizontal (X) and vertical (Y) directions. They provide information about how the image intensity changes along these axes, which is crucial for detecting edges and orientation of structures within the image. * **Energy**: This measure the total amount of intensity variation within the local window. It’s calculated from the eigenvalues of the ST and it reflects the overall strength of the directional signal. For example, high energy can indicate a strong consistent orientation patterns, while low energy could mean a more isotropic or random distribution of orientations. * **Orientation**: It refers to the dominant direction of the structures within the local window. This is calculated from the main eigenvector of the ST, basically representing the angle the structures are aligned. * **Coherence**: This quantifies the degree of anisotropy, or directional uniformity, of the structure. High coherence (1) indicates that the structures are well-aligned in a single direction, while low coherence (0) suggests a more random or isotropic structure. Mathematically, it is derived from the eigenvalues of the structure tensor, where a high coherence value means the difference between the eigenvalues is large. * **Color-Survey**: This is a visual representation of the orientations, where different orientations are mapped to specific colors (dependieng on their direction). Each color corresponds to a specific orientation, enabling quick identification of patterns and anisotropies in the image. Here below are the examples of how they looks like: ![Captura de pantalla 2024-08-13 a la(s) 5.37.36 p.m.](https://hackmd.io/_uploads/SktlfuY5A.png) ## OrientationJ Distribution This option allows you to analyze the distribution of orientations within the image. The parameters in the *Structure Tensor* section are similar to those in the `OrientationJ Analysis` option, so they won’t provide different information. However, **for this analysis, the key settings to focus on are the `Histogram` and `Table` options**: ![Captura de pantalla 2024-08-13 a la(s) 6.16.31 p.m.](https://hackmd.io/_uploads/SyG3v_Y9R.png) When selected, these options will generate a histogram that displays the distribution of orientations across the image. The histogram plots the frequency of each orientation on the Y-axis against the corresponding degrees on the X-axis. This visual representation helps to understand the overall alignment of structures. In addition to the histogram, and most important, the same information of orientation distribution is also provided in a table format and can be saved as a CSV file for further statistical analysis. This feature is especially useful for more detailed or custom data analysis outside of FIJI. ![Captura de pantalla 2024-08-13 a la(s) 6.16.40 p.m.](https://hackmd.io/_uploads/S1MhDOKqC.png) ## OrientationJ Measure This option allows you to calculate the ST within specific Regions of Interest (ROIs). To select the area you want to measure, use the rectangle or circle tool from the FIJI toolbar. Once you've defined the ROI, click the `Measure` button in the `OrientationJ Measure` window. This will overlay two circles on your histology image: a purple circle representing the ROI and an orange ellipse representing the calculated ST. The orange ellipse visually represents the anisotropy and main orientation (first eigenvalue) of the underlying structure. For example, if the ellipse is elongated and aligned with the fibers, it indicates a high degree of anisotropy and a clear orientation. In the example, tensor number one shows a well-aligned and thinner shape, meaning that the anisotropy is higher compared to others, like ellipse number two. On the right-hand side of the window, you'll find a summary of the results, which can be copied for further analysis. You can measure as many ROIs as needed, and each one will be identified by a unique number in both the image and the results table. You can also customize the color and line thickness of the ellipse and ROI by clicking the `Options` section. ![Captura de pantalla 2024-08-15 a la(s) 11.44.01 p.m.-2-2-2](https://hackmd.io/_uploads/SkZ8tw29A.png) Another useful feature is the ability to create a binary mask from the selected ROIs. This mask can be used for additional processing in FIJI that requires segmented areas. ![Captura de pantalla 2024-08-15 a la(s) 11.55.40 p.m.-2](https://hackmd.io/_uploads/r1rkjv390.png) ## OrientationJ Vector Field Finally, this option allows you to compute and visualize a vector field across the entire histology image. This vector representation is derived from the dominant orientation and anisotropy within each local window, providing a visual guide to patterns and alignments in the image. You can modify the grid size of the vector field, which controls the spacing between the vectors. As you adjust the grid size, the vector lines will span more or fewer pixels, effectively changing the resolution of the local window used to compute the vectors. Smaller grid sizes result in a denser vector field, while larger grid sizes produce a more sparse representation. In the example below, the grid size has been adjusted from 80 to 10. It's recommended to choose a grid size that best matches the underlying structure of your image for the most accurate representation. ![Captura de pantalla 2024-08-16 a la(s) 12.18.24 a.m.](https://hackmd.io/_uploads/H1rlWMpqC.png) While the vector overlay provides a valuable visual assessment, the most juicy information is found in the `Table` option. This table contains essential data such as: * **X and Y**: The coordinates of each vector. * **Orientation**: The main orientation of each vector. * **Anisotropy (Coherence)**: The degree of anisotropy associated with each vector. You can save and export this table for further analysis in your preferred software, such as deeper exploration of the orientation patterns and anisotropy within your image. ![Captura de pantalla 2024-08-16 a la(s) 12.19.59 a.m.](https://hackmd.io/_uploads/B1WZWzTq0.png) --- I hope this tutorial is useful for anyone who is doing some Structure Tensor Analysis. Please share your comments or any suggestions to improve this document is very welcome! :)