This package encompasses both the ImageJ plugin RFT, and the scripts used to further process the data.
This plugin has a ImageJ (Java) and Python part. The ImageJ plugin is easily configured to run the full stack, but either part can be used seperately.
To automatically use the latest version, you can subscribe to the Hohlbein update site in ImageJ. Otherwise, download the latest version jar from here and place it in the plugins folder in your FIJI installation folder and restart the application.
Download the python script from here and place this in a folder. More folders and files will be written here, so recommended is that the folder is empty (besides the script).
In the ImageJ plugin, you can put the path to the folder containing the gaussian_order.py
script in the script path box, and your preferred python version in the py box. This will link them together.
This python install must include the following packages: matplotlib, numpy, scipy, tqdm, openpyxl, astropy
.
You can install them using the following python command: python.exe -m pip install matplotlib numpy scipy tqdm openpyxl astropy
- This does assume your python installation is
python.exe
. Replace if you are using a differeny path
Analysis of Textured Vegetable Protein:
Input image | Vector Overlay |
---|---|
Anglular Overview | WOP Overview |
Mean WOP value of this image is 0.47, which indicates a highly structured image.
Plugin Overview
To use the plugin, open an image and click Plugins > RFT > Analyze Angles This opens the following window:
It contains the following tabs/settings:
- Processing Tab: Contains settings related to analysis of current images
- Settings Tab: Contains various paths and settings that need little changing
- Help Tab: Contains detailed information, similar to this readme.
- Credits Tab: Contains link to paper, GitHub, etc.
- Processing Settings:
- Processing Window: window size used for analysis in px.
- Overlap: How much does each window overlap in x- and y-axis (fractional 0-1).
- Buffer: Distance from the top and left edge to start in px.
- Run Python toggle: When you press Run, execute the python part automatically
- Requires the Python block to be filled in the Settings Tab
- Run: Run RFT and python if enabled
- Save Data: After running, save the data to a CSV
- Requires the Save block to be filled in the Settings Tab
- Save the Data and Run the python backend.
- Requires the Save and Python block to be filled in the Settings Tab
- Vector Field Settings:
- Vector Length: Relative length of the shown vectors
- Vector Width: Width of the shown vectors in px
- Overlay: Toggle showing the vector overlay
- Cutoffs Settings: Cutoffs to show or hide a vector in the vector overlay
- Std Cutoff: How many standard deviations does the peak intensity of an angle need to be
- Intensity Cutoff: Fraction of max intensity a region need to be
- Scan Settings: Run processing in a range of window sizes. Saves, and requires Save path set.
- Window Start: Start in px
- Window Step: Steps in px
- Window End: End in px
- Window Size Scan: Perform the scan using the Buffer and overlap set in 5.
- Settings
- Save Path: Path to save all intermediate CSV's to
- Will create an folder called inputs here, and put CSV's into it. A pickle and results folder will also be made to put python results into.
- Save format is: path\file_name
- Python Path: Python instance to use. Generally can use 'py' or 'python' here.
- Requires the following packages to be installed 'matplotlib, numpy, scipy, tqdm, openpyxl, astropy'
- Install using
python.exe -m pip install matplotlib numpy scipy tqdm openpyxl astropy
- Script path: Folder where the python script
gaussian_order.py
is located - Show Graph: This will show all graphs in matplotlib window. Warning: they are not scaled to monitor, so will be big window.
- Python Parameters: Additional parameters to pass to
gaussian_order.py
. See Python section for these.
- Save Path: Path to save all intermediate CSV's to
Macro
The plugin can be run from a macro using the following syntax:
run("Analyze Angles", "buffer=0 window=101 overlap=0.75 path='path\\to\\folder with spaces'");
or to run on a folder with python automatically
input = "path\\to\\folder";
setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++){
open(input + list[i]);
if (nImages>=1) {
run("Analyze Angles", "buffer=0 window=350 overlap=0.25 save_path='save\\path' python_path='py' script_path='path\\to\\script' run_python=True");
close();
}
}
setBatchMode(false);
All arguments follow the format of keyword=value
using the period as the separator. When a path contains spaces, use single quote ticks to ensure the proper path is captured.
Note that when using macro mode, the program will always save, and thus save_path
is required.
The arguments and their defaults are as follows:
- buffer: 0
- window: 50
- cutoff: 2.0
- overlap: 0.75
- intensity_cutoff: 0.2
- start: 50
- end: 300
- step: 50
- scanning_range: False
- vector_overlay: off
- vector_length: 1
- vector_width: 3
- save_path: null
- python_path: null
- python_arguments: null
- Format:
python_arguments='-single_threaded -filter_edges 1'
- See python section for details
- Format:
- show_graphs: False
- run_python: False
The python script takes in data formatted in the following way:
-
The header row must be:
x, y, width, height, Max Index, Mask Median, Angle, Relevance, Profile Data
-
Then follow a number of rows such that each x and y combination is mentioned (
n_rows = unique(x)* unique(y)
)- x and y: coordinates of the top-left corner of this window in px
- width and height: width and height of this window in px
- Max Index: index of the maximum value in Profile Data
- Mask Median: Median intensity in this window
- Angle: angle associated with Max Index
- Relevance: standard deviations of the peak amplitude above the mean
- Profile Data: the intensity of each angle for this window
- ImageJ plugin produces 200 values spread over a range of 180°.
- This can be more of fewer values, but assumption is that they cover a range of 180°.
- Example Row:
0, 0, 151, 151, 144, 199, 129.6, 2.54, 4.04, 4.06, etc.
The python section takes in a csv file created by the ImageJ plugin, but will work on any data formatted the correct way.
The python script can also be imported and called directly using either an argument string or setting each argument individually. The named arguments take precedent over arguments set via a string.
Filenames are always given without .csv
Examples:
gaussian_order.run(argument_string="-force_recalculation -c path\\to\\input -absolute -f file1,file2)
gaussian_order.run(force_recalculation=True, core_path="path\\to\\input", absolute=True, filenames=["file1", "file2"])
Arguments
- match_angle: How far apart angles must be to be considered separate.
- Angles closer than this will be clustered together
- max_neighbourhood: Maximum region to calculate the WOP for.
- Will continue until either this value is reached or the maximum size the image allows
- filter_edges: How many windows to leave out on each edge
- prominence: Percentage of max value above mimum that a peak must have (0-1)
- min_peak_width: minimum width a peak must have in degrees
- min_distance: minimum distance between peaks in degrees
- singlethreaded: Run software in singlethreaded mode.
- Some users have reported issue using multiprocessing modes, so this disables that. Will be slower for large data sets.
- image_format: Image format that matplotlib will save graphs in, e.g. png, svg
- testing: Will enable testing mode and display detailed fit information for a single window.
- Enter an integer, e.g. 1 or 2, to display that window and stop analysis then
- seed: A custom seed to set rng. By default it is initialised with the same seed
- show_graph: Shows the graphs generated. Will always save them.
- all_angles: calculate the WOP on individual angles alongside the collective of angles. Together with the match_angle can allow one to analyse the distribution within clusters of angles and filter out unwanted angles.
- no_recalculation: Store the data in a pickle file and reload if analysis is done again. Useful when analysing the same file multiple times or changing the pipeline after fitting.
- The unique identifier is the filename, which includes window size, but not overlap.
- core_path: The folder to use as input.
- If absolute mode is turned on, will look at this filepath, otherwise, it will look in the script folder and append
\\input\\<core_path>
- If absolute mode is turned on, will look at this filepath, otherwise, it will look in the script folder and append
- filenames: A comma-separated list of all the filenames to analyse. can also be set to
all
to recursively analyse each folder incore_path
If you use this software for your paper, please cite Rotated Fourier transform (RFT) enables the quantification of anisotropic structure in high-moisture plant-protein extrudates. doi:10.26434.