Postprocessing

particletracker.postprocess.postprocessing_methods.absolute(df, f_index=None, parameters=None, call_num=None)

Returns new column with absolute value of input column

Parameters
  • column_name (name of column containing input values) –

  • df – The dataframe for all data

  • f_index – Integer for the frame in twhich calculations need to be made

  • parameters – Nested dict object

  • call_num

Returns

  • df with additional column containing absolute value of input_column.

  • New column is named “column_name” + “_abs”

particletracker.postprocess.postprocessing_methods.add_frame_data(df, f_index=None, parameters=None, call_num=None)

Add frame data allows you to manually add a new column of df to the dfframe.

Notes

This is done by creating a .csv file and reading it in within the gui. The file should have one column with the data for each frame listed on the correct line.

Parameters
  • data_filename – filename with extension for the df to be loaded. Assumes file is in same directory as video

  • new_column_name – Name for column to which data is to be imported.

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.angle(df, f_index=None, parameters=None, call_num=None)

Angle calculates the angle specified by two components.

Notes

Usually angle is used following calculating the difference along x and y trajectories. It assumes you want to calculate from x_column as dx and y_column as dy it uses tan2 so that -dx and +dy give a different result to +dx and -dy Angles are output in radians or degrees given by parameters[‘angle’][‘units’]

Parameters
  • x_column – x component for calculating angle

  • y_column – y component for calculating angle

  • output_name – New column name to store angle df

  • units – ‘degrees’ or ‘radians’

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.audio_frequency(df, f_index=None, parameters=None, call_num=None)

Decodes the audio frequency in our videos. We use this to encode information about the acceleration being applied to a video directly into the audio channel. This enables us to get the info back out

Parameters
  • ([type]) (df) –

  • ([type] (call_num) –

  • optional) ([description]. Defaults to None.) –

  • ([type]

  • optional)

  • ([type]

  • optional)

Returns

[type]

Return type

[description]

particletracker.postprocess.postprocessing_methods.classify(df, f_index=None, parameters=None, call_num=None)

Classifies particles based on values in a particular column

Notes

Takes a column of data and classifies whether its values are within the specified range. If it is a True is put next to that particle in that frame in a new classifier column. This can be used to select subsets of particles for later operations.

Parameters
  • column_name – input data column

  • output_name – column name for classification (True or False)

  • lower_threshold – min value to belong to classifier

  • upper_threshold – max value to belong to classifier

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.contour_boxes(df, f_index=None, parameters=None, call_num=None)

Contour boxes calculates the rotated minimum area bounding box

Notes

This method is designed to work with contours. It calculates the minimum rotated bounding rectangle that contains the contour. This is useful for calculating the orientation of shapes.

‘box_cx’ - Centre of mass x coord of calculated box ‘box_cy’ - Centre of mass y coord of calculated box ‘box_angle’ - the angle of the long axis of the box relative to the x axis ‘box_length’- Long dimension of box ‘box_width’ - Short dimension of box ‘box_area’ - Area of box

All values in units of pixels.

Parameters
  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.difference(df, f_index=None, parameters=None, call_num=None)

Difference of a particles values on user selected column.

Notes

Returns the difference of a particle’s values on a particular column at span separation in frames to a new column. Please be aware this is the difference between current frame and frame - span for each particle.

Parameters
  • column_name – Input column name

  • output_name – Column name for median data

  • span – number of frames over which to calculate rolling median

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.hexatic_order(df, f_index=None, parameters=None, call_num=None)

Calculates the hexatic order parameter of each particle. Neighbours are calculated using the Delaunay network with a cutoff distance defined by “cutoff” parameter.

Parameters
  • cutoff – Distance threshold for calculation of neighbors

  • df – The dataframe for all data

  • f_index – Integer for the frame in twhich calculations need to be made

  • parameters – Nested dict object

  • call_num

Return type

df with additional column

particletracker.postprocess.postprocessing_methods.logic_AND(df, f_index=None, parameters=None, call_num=None)

Applys a logical and operation to two columns of boolean values.

column_name

input data column

column_name2

input data column

output_name

column name for the result

Parameters
  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.logic_NOT(df, f_index=None, parameters=None, call_num=None)

Apply a logical not operation to a column of boolean values.

Parameters
  • column_name – input data column

  • column_name2 – input data column

  • output_name – column name for the result

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.logic_OR(df, f_index=None, parameters=None, call_num=None)

Apply a logical or operation to two columns of boolean values.

Parameters
  • column_name – input data column

  • column_name2 – input data column

  • output_name – column name for the result

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.magnitude(df, f_index=None, parameters=None, call_num=None)

Calculates the magnitude of 2 input columns (x^2 + y^2)^0.5 = r

Parameters
  • column_name (Second column) –

  • column_name

  • output_name (Column name for magnitude df) –

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.mean(df, f_index=None, parameters=None, call_num=None)

Rolling mean of a particles values.

Notes

Returns the rolling mean of a particle’s values to a new column. Useful to reduce fluctuations or tracking inaccuracies. The value of the mean is placed at the centre of the rolling window. i.e [2,4,6,8,4] with window 3 would result in [NaN, 4, 6, 6, Nan].

Parameters
  • column_name – Input column name

  • output_name – Column name for mean data

  • span – number of frames over which to calculate rolling mean

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.median(df, f_index=None, parameters=None, call_num=None)

Median of a particles values.

Notes

Returns the median of a particle’s values to a new column. Useful before classification to answer to which group a particle’s properties usually belong. The value of the median is placed at the centre of the rolling window. i.e [2,4,4,8,4] with window 3 would result in [NaN, 4, 4, 4, Nan].

Parameters
  • column_name – Input column name

  • output_name – Column name for median data

  • span – number of frames over which to calculate rolling median

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.neighbours(df, f_index=None, parameters=None, call_num=None)

Find the nearest neighbours of a particle

Notes

Neighbours uses two different methods to find the nearest neighbours: a kdtree (https://en.wikipedia.org/wiki/K-d_tree) or a delaunay method (https://en.wikipedia.org/wiki/Delaunay_triangulation) to locate the neighbours of particles in a particular frame. It returns the indices of the particles found to be neighbours in a list. You can also select a cutoff distance above which two particles are no longer considered to be neighbours. To visualise the result you can use “networks” in the annotation section.

Parameters
  • method – ‘delaunay’ or ‘kdtree’

  • neighbours – max number of neighbours to find. This is only relevant for the kdtree.

  • cutoff – distance in pixels beyond which particles are no longer considered neighbours

‘neighbours’ - A list of particle indices which are neighbours

Parameters
  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.rate(df, f_index=None, parameters=None, call_num=None)

Rate of change of a particle property with frame

Notes

Rate function takes an input column and calculates the rate of change of the quantity. Nans are inserted at end and beginning of particle trajectories where calc is not possible. The rate is calculated from diff between current frame and frame - span.

Parameters
  • column_name – Input column names

  • output_name – Output column name

  • fps – numerical value indicating the number of frames per second

  • span – number of frames over which to calculate rolling difference

  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column

particletracker.postprocess.postprocessing_methods.real_imag(df, f_index=None, parameters=None, call_num=None)

Extracts the real, imaginary, complex magnitude and complex angle from a complex number and puts them in new columns. Mainly useful for subsequent annotation with dynamic colour map.

Parameters
  • column_name (name of column containing complex values) –

  • df – The dataframe for all data

  • f_index – Integer for the frame in twhich calculations need to be made

  • parameters – Nested dict object

  • call_num

Returns

  • df with 3 additional columns containing real, imaginary and complex angle

  • New columns are called “column_name” + “_Re” or “_Im” or “_Ang”

particletracker.postprocess.postprocessing_methods.voronoi(df, f_index=None, parameters=None, call_num=None)

Calculate the voronoi network of particle.

Notes

The voronoi network is explained here: https://en.wikipedia.org/wiki/Voronoi_diagram This function also calculates the associated area of the voronoi cells.To visualise the result you can use “voronoi” in the annotation section.

‘voronoi’ - The voronoi coordinates that surround a particle ‘voronoi_area’ - The area of the voronoi cell associated with a particle

Parameters
  • df – The dataframe in which all data is stored

  • f_index – Integer specifying the frame for which calculations need to be made.

  • parameters – Nested dictionary like object (same as .param files or output from general.param_file_creator.py)

  • call_num – Usually None but if multiple calls are made modifies method name with get_method_key

Return type

updated dataframe including new column