Algorithm Model Details
Last updated
Last updated
Programmed in MATLAB
Programmed in Python
The main test code, Test_Cyrus
, performs a series of tests on various methods to compute the percent error in determining the position of a particle based on its projections. The methods are compared over a series of runs to determine their accuracy. Finally, the results are plotted for visual comparison.
Cumulative_NOS
: Cumulative number of shots or projections taken.
theta_degree
: Rotation angle between projections in degrees.
noise_ratio
: Ratio of position value to the error for each projection.
Original Method Test:
This method tests the original approach using pairs of shots.
Results are stored in Original_Result_PercentError
.
Consecutive Number Average Method Test:
This approach tests using consecutive shots.
Results are stored in Consecutive_Result_PercentError
.
Original Method with Bigger Matrix Test:
This method uses the original approach but with a bigger matrix to account for the z-axis.
Results are stored in OriginalBigger_Result_PercentError
.
Big Matrix Method Test:
This method tests using the BigMatrix2
function.
Results are stored in BigMatrix_Result_PercentError
.
Consecutive Method with Kalman Filter Test:
This method tests the consecutive approach but incorporates a Kalman filter.
Results are stored in Kalman_Result_PercentError
.
In each method file:
Inputs
true_position_3d
: A 1x3 vector containing the true x, y, z positions of the particle.
noise
: The amount of random noise introduced in the projection.
NOS
: Number of shots or projections taken.
theta_degree
: Rotation angle between projections in degrees.
Output
percent_error
: The percent error between the predicted and true x-position of the particle.
Testing with synthetic particle data shows that the Big Matrix method had the lowest percent error, so we moved forward with the linear least square approach.
Phase2_pt_3d
aims to estimate the 3D position and velocities of a particle over time using a series of projections. The particle's position is rotated and translated over time. The function constructs a system of equations based on the particle's projected positions and solves them to estimate the particle's position and velocities.
Inputs
initial_position_3d
: Initial 3D position of the particle as a column vector [x0; y0; z0]
.
noise
: Deviation of the projection measurement from the perfect measurement (68% chance).
delta_T
: Time interval between shots.
NOS
: Number of shots or projections.
theta_degree
: Rotation angle between projections in degrees.
Outputs
results
: Estimated 3D position and velocities.
Code Highlights
Initialization: Set parameters, velocity function, and errors.
Projection Generation: Generate projections of the particle based on rotations and velocity function.
Estimating True Position: Estimate particle's position from the projections and derive velocity terms.
Helper Functions:
Coordinate Rotation Function (T): Rotate a point in 3D space about the y-axis.
proj2r0 Function: Estimate the original position and velocities of the particle using projections.
In this phase, we sought to deal with situations involving a constant acceleration. The Phase3_pt_3d_success
function builds upon Phase 2 by incorporating an additional movement model that considers constant acceleration. It then visualizes the real and estimated positions in 3D space, offering a tool for assessing the accuracy of the estimation process.
Inputs
initial_position_3d
: Initial position of the particle in 3D space.
noise
: The deviation of the projection measurement from a perfect measurement.
delta_T
: Time interval between successive camera shots.
NOS
: Number of shots or projections taken.
theta_degree
: Clockwise rotation angle of the camera before each shot.
v
: Velocity function representing the particle's movement in 3D space.
Visualization
This segment plots the real positions (red) and estimated positions (blue) of the particle in a 3D space.
proj2r0
Upgraded to Include Acceleration
Compared to Phase 2:
Similarities:
The core structure of the proj2r0
function remains the same, with equations being formulated based on magnification and transformation.
The function still aims to predict the 3D coordinates of the particle based on its projections.
Differences:
The matrix A
in Phase 3 is expanded further to accommodate six new variables (3 for velocity and 3 for acceleration) compared to Phase 2.
The equations in this phase account for the effect of constant acceleration on the particle's position over time.
The critical aspect of developing this phase is to generalize the movement of a particle, which could be stationary, moving with a linear velocity, with a constant acceleration, or changing accelerations. To address that, Phase 3's code is used over a section of the particle's movement, to estimate its path over a smaller time range, with the assumption that in a smaller time interval, the movement can be characterized by a simple acceleration model. This assumption is valid because the experimental data mostly focuses on particles moving in a slow flow field.
Before introducing the strategies, we introduce a variable named NOS_per_section
. If there exists n NOS (number of snapshots), NOS_per_section dictates the number of snapshots that will be fed into the proj2r0
algorithm for an estimated path. In other words, it represents the size of a batch of data that will be analyzed.
Two strategies are implemnted to divide the data, discussed as below.
Given NOS
, and NOS_per_section
= M, this strategy breaks the entire snapshot data set into M chunks, each containing a unique set of snapshots. Each chunk is then analyzed through the linear big matrix to get the estimated 3D positions of each time step, termed "subpath." After all subpaths are generated, they are connected in a head-to-tail fashion to form the final estimated 3D path for the particle. The main advantage of the strategy is speed, as every snapshot is only evaluated once. However, it does not work well when the particle is relatively stationary, since fewer iterations on the same time step do not have the resilience against noise.
Strategy 2: Overlap
Following the methodology of Strategy 1, Strategy 2 adopts an overlapping approach to analyze the snapshot data set. In this strategy, the data is divided into overlapping chunks, where each chunk contains a sequence of snapshots from the 1st to the k th, followed by the 2nd to the (k + 1) th, and so on. This creates a series of overlapping sections, each containing a distinct but partially shared set of snapshots. The linear big matrix is then applied to each chunk to estimate the 3D positions for each time step, termed a "subpath."
Unlike Strategy 1, where subpaths are connected directly, Strategy 2 involves averaging the 3D position estimates of points that are evaluated multiple times due to the overlap. This results in a more refined and potentially accurate final estimated 3D path for the particle, as it incorporates repeated assessments of the same points, reducing uncertainty and improving precision in the trajectory estimation. It also requires less NOS to produce the same number of batches. However, this strategy does not work well when the angle between each shot is large.
Here is a diagram for visualizing and comparing the strategies:
In this phase, there are two main goals:
Convert all code to Python
Develop the sorting algorithm that can take a 2D snapshot (image) with the 2D coordinates of the particles, and match each position with a particle. The idea is to classify the positions in each image into shadows of different particles. Then, when all particles receive a time-serial chain of 2D positions, this chain will be fed into the 2D to 3D big matrix to generate the 3D paths.
We first converted all code to Python. Take projr20
, one of the fundamental blocks of the algorithm, as an example. Its Python form is as follows:
Then, I tackled the 2D sorting section, which turned out to be the most difficult part of the algorithm development.
The main challenge is that
In this phase (Phase 3), the function has been expanded to consider not just initial position and velocity but also constant acceleration. This is reflected in the introduction of acceleration components in the matrix A
.