Particle Tracker

class particle_tracker_one_d.ParticleTracker(frames, time, automatic_update=True)[source]

Dynamic Particle tracker object which finds trajectories in the frames. Trajectories are automatically updated when properties are changed.

Parameters:
frames: np.array

The frames in which trajectories are to be found. The shape of the np.array should be (nFrames,xPixels). The intensity of the frames should be normalised according to \(I_n = (I-I_{min})/(I_{max}-I_{min})\), where \(I\) is the intensity of the frames, \(I_{min}\), \(I_{max}\) are the global intensity minima and maxima of the frames.

time: np.array

The corresponding time of each frame.

Attributes:
frames

np.array:

time

np.array:

boxcar_width

int:

integration_radius_of_intensity_peaks

int:

particle_detection_threshold

float:

maximum_number_of_frames_a_particle_can_disappear_and_still_be_linked_to_other_particles

int:

maximum_distance_a_particle_can_travel_between_frames

int:

particle_positions

list:

Methods

change_cost_coefficients([a, b, c, d]) Change the coefficients of the cost function \(c(p_1,p_2) = a\cdot (x_{p_1} - x_{p_2})^2 + b \cdot (m_0(p_1)-m_0(p_2))^2 + b \cdot (m_2(p_1)-m_2(p_2))^2) + d \cdot (t_{p_1}-t_{p_2})^2\)
get_frame_at_time(time) time: float
normalise_intensity(frames) frames: np.array
plot_all_frames([ax]) ax: matplotlib axes instance
plot_all_particles([ax]) ax: matplotlib axes instance
plot_frame(frame_index[, ax]) frame_index: index
plot_frame_at_time(time[, ax]) time: float
plot_moments([ax]) ax: matplotlib axes instance
boxcar_width
int:
Number of values used in the boxcar averaging of the frames.
change_cost_coefficients(a=1, b=1, c=1, d=1)[source]

Change the coefficients of the cost function \(c(p_1,p_2) = a\cdot (x_{p_1} - x_{p_2})^2 + b \cdot (m_0(p_1)-m_0(p_2))^2 + b \cdot (m_2(p_1)-m_2(p_2))^2) + d \cdot (t_{p_1}-t_{p_2})^2\)

a: float

b: float

c: float

d: float

frames
np.array:
The frames which the particle tracker tries to find trajectories in. If the property boxcar_width!=0 it will return the smoothed frames.
get_frame_at_time(time)[source]
time: float
Time of the frame which you want to get.
Returns:
np.array

Returns the frame which corresponds to the input time.

integration_radius_of_intensity_peaks
int:
Number of pixels used when integrating the intensity peaks. No particles closer than twice this value will be found. If two peaks are found within twice this value, the one with highest intensity moment will be kept.
maximum_distance_a_particle_can_travel_between_frames
int:
Max number of pixels a particle can travel between two consecutive frames.
maximum_number_of_frames_a_particle_can_disappear_and_still_be_linked_to_other_particles
int:
Number of frames a particle can be invisible and still be linked in a trajectory.
static normalise_intensity(frames)[source]
frames: np.array
Normalises the intensity of the frames according to \(I_n = (I-I_{min})/(I_{max}-I_{min})\), where \(I\) is the intensity of the frames, \(I_{min}\), \(I_{max}\) are the global intensity minima and maxima of the frames.
Returns:
np.array

The normalised intensity.

particle_detection_threshold
float:
Defines the threshold value for finding intensity peaks. Local maximas below this threshold will not be considered as particles. Should be a value between 0 and 1.
particle_positions
list:
List with numpy arrays containing all particle positions.
plot_all_frames(ax=None, **kwargs)[source]
ax: matplotlib axes instance
The axes which you want the frames to plotted on. If none is provided a new instance will be created.
**kwargs:
Plot settings, any settings which can be used in matplotlib.pyplot.imshow method.
Returns:
matplotlib axes instance

Returns the axes input argument or creates and returns a new instance of an matplotlib axes object.

plot_all_particles(ax=None, **kwargs)[source]
ax: matplotlib axes instance
The axes which you want the particle detections to be plotted on. If none is provided a new instance will be created.
**kwargs:
Plot settings, any settings which can be used in matplotlib.pyplot.scatter method.
Returns:
matplotlib axes instance

Returns the axes input argument or creates and returns a new instance of an matplotlib axes object.

plot_frame(frame_index, ax=None, **kwargs)[source]
frame_index: index
The index of the frame you want to plot.
ax: matplotlib axes instance
The axes which you want the frames to plotted on. If none is provided a new instance will be created.
**kwargs:
Plot settings, any settings which can be used in matplotlib.pyplot.plot method.
Returns:
matplotlib axes instance

Returns the axes input argument or creates and returns a new instance of an matplotlib axes object.

plot_frame_at_time(time, ax=None, **kwargs)[source]
time: float
The time of the frame you want to plot.
ax: matplotlib axes instance
The axes which you want the frames to plotted on. If none is provided a new instance will be created.
**kwargs:
Plot settings, any settings which can be used in matplotlib.pyplot.plot method.
Returns:
matplotlib axes instance

Returns the axes input argument or creates and returns a new instance of an matplotlib axes object.

plot_moments(ax=None, **kwargs)[source]
ax: matplotlib axes instance
The axes which you want the moments to plotted on. If none is provided a new instance will be created.
**kwargs:
Plot settings, any settings which can be used in matplotlib.pyplot.scatter method.
Returns:
matplotlib axes instance

Returns the axes input argument or creates and returns a new instance of an matplotlib axes object.

time
np.array:
The time for each frame.
trajectories
list:
Returns a list with all found trajectories of type class: Trajectory.