Annotation Methods

particletracker.annotate.annotation_methods.boxes(frame, data, f, parameters=None, call_num=None)

Boxes places a rotated rectangle on the image that encloses the contours of specified particles.

Notes

This method requires you to have used contours for the tracking and run boxes in postprocessing.

Parameters
  • cmap_type – Options are ‘static’ or ‘dynamic’

  • cmap_column – Name of column containing data to specify colour in dynamic mode,

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_scale – Scale factor for colour map

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • classifier_column – None selects all particles, column name of classifier values to specify subset of particles

  • classifier – The value in the classifier column which applies to subset (True or False)

  • thickness – Thickness of box. -1 fills the box in

  • frame – This is the unmodified frame of the input movie

  • data – This is the dataframe that stores all the tracked data

  • f – frame index

  • 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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.circles(frame, data, f, parameters=None, call_num=None)

Circles places a ring on every specified particle

Parameters
  • xdata_column – Name of column to use for x coordinates

  • ydata_column – Name of column to use for y coordinates

  • rad_from_data – Specify radius manually: False or use measured rad: True. Only works for Hough transform.

  • radius – If rad_from_data = False this specifies the radius of circle

  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode,#for dynamic

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_scale – Scale factor for colour map

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to (True or False)

  • thickness – Thickness of circle. -1 fills the circle in solidly.

  • frame (np.ndarray) – This is the unmodified frame of the input movie

  • data (pandas dataframe) – This is the dataframe that stores all the tracked data

  • f (int) – frame index

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

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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.contours(frame, data, f, parameters=None, call_num=None)

Contours draws the tracked contour returned from Contours tracking method onto the image.

Notes

Requires the contours tracking method.

Parameters
  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_scale – Scale factor for colour map

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to (True or False).

  • thickness – Thickness of contour. -1 will fill in contour

  • frame – This is the unmodified frame of the input movie

  • data – This is the dataframe that stores all the tracked data

  • f – frame index

  • 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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.networks(frame, data, f, parameters=None, call_num=None)

Networks draws a network of lines between particles

Notes

The network must previously have been calculated in postprocessing. See “neighbours” in postprocessing.

Parameters
  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode,#for dynamic

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_scale – Scale factor for colour map

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to.

  • thickness – Thickness of network lines

  • frame (np.ndarray) – This is the unmodified frame of the input movie

  • data (pandas dataframe) – This is the dataframe that stores all the tracked data

  • f (int) – frame index

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

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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.particle_labels(frame, data, f, parameters=None, call_num=None)

Annotates image with particle info from one column. The most common use is to indicate the particle index but any column of data could be used.

Notes

For particle ids to be meaningful, you must have already run ‘processed part’ with linking selected. This is particularly useful if you want to extract information about specific particles. Annotate their ids to identify the reference id of the one you are interested in and then you can pull the subset of processed data out. See examples in Jupyter notebook. Any particle level data can however be displayed.

Parameters
  • values_column – Name of column containing particle info to be displayed.

  • position – Coordinates of upper left corner of text

  • font_colour – Colour of font specified in (B,G,R) format where values are integers from 0-255

  • font_size – Size of font

  • font_thickness – Thickness of font

  • frame – This is the unmodified frame of the input movie

  • data – This is the dataframe that stores all the tracked data

  • f – frame index

  • 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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.text_label(frame, data, f, parameters=None, call_num=None)

Text labels place a static label on an image at specific location.

Notes

This function is for adding titles or info that doesn’t change

Parameters
  • text – Text to be displayed

  • position – Coordinates of upper left corner of text

  • font_colour – Colour of font specified in (B,G,R) format where values are integers from 0-255

  • font_size – Size of font

  • font_thickness – Thickness of font

  • frame – This is the unmodified frame of the input movie

  • data – This is the dataframe that stores all the tracked data

  • f – frame index

  • 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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.trajectories(frame, data, f, parameters=None, call_num=None)

Trajectories draws the historical track of each particle onto an image.

Notes

Requires data from other frames hence you must have previously processed the video and then toggled use_part_processed button.

Parameters
  • x_column – column name of x coordinates of particle,

  • y_column – column name of y coordinates of particle,

  • traj_length – number of historical frames to include in each trajectory.

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to (True or False).

  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode,

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_min – Specifies min data value for colour map in dynamic mode

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • thickness – Thickness of line.

  • frame (np.ndarray) – This is the unmodified frame of the input movie

  • data (pandas dataframe) – This is the dataframe that stores all the tracked data

  • f (int) – frame index

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

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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.var_label(frame, data, f, parameters=None, call_num=None)

Var labels puts text on an image at specific location for each frame. The value displayed in that frame is mapped to a column in the dataframe. The values next to each frame should all be the same for that column. Use for example to specify the temperature.

Notes

This function is for adding data specific to a single frame. For example you could indicate the temperature of the sample or time. The data for a given frame should be stored in a particular column specified in the ‘var_column’ section of the dictionary.

Parameters
  • var_column – Column name containing the info to be displayed on each frame

  • position – Coordinates of upper left corner of text

  • font_colour – Colour of font specified in (B,G,R) format where values are integers from 0-255

  • font_size – Size of font

  • font_thickness – Thickness of font

  • frame – This is the unmodified frame of the input movie

  • data – This is the dataframe that stores all the tracked data

  • f – frame index

  • 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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.vectors(frame, data, f, parameters=None, call_num=None)

Vectors draw info onto images in the form of arrows.

Notes

Vectors draws an arrow starting at each particle with a length and direction specified by 2 components. The magnitude of the vector can be scaled to be appropriate.

Parameters
  • dx_column – Column name of x component of vector, defaults to ‘x’

  • dy_column – Column name of y component of vector, defaults to ‘y’

  • vector_scale – scaling between vector data and length of displayed line

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to.

  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode,

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_min – Specifies min data value for colour map in dynamic mode

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • line_type – OpenCV parameter can be -1, 4, 8, 16

  • thickness – Thickness of line. Defaults to 2

  • tip_length – Controls length of arrow head

  • frame (np.ndarray) – This is the unmodified frame of the input movie

  • data (pandas dataframe) – This is the dataframe that stores all the tracked data

  • f (int) – frame index

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

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

Returns

annotated frame

Return type

np.ndarray

particletracker.annotate.annotation_methods.voronoi(frame, data, f, parameters=None, call_num=None)

Voronoi draws the voronoi network that surrounds each particle

Notes

The voronoi cells must previously have been calculated in postprocessing. See “voronoi” in postprocessing.

Parameters
  • cmap_type – Options are static or dynamic

  • cmap_column – Name of column containing data to specify colour in dynamic mode,#for dynamic

  • cmap_max – Specifies max data value for colour map in dynamic mode

  • cmap_min – Specifies min data value for colour map in dynamic mode

  • cmap_scale – Scale factor for colour map

  • colour – Colour to be used for static cmap_type (B,G,R) values from 0-255

  • classifier_column – None - selects all particles, column name of classifier values to apply to subset of particles

  • classifier – The value in the classifier column to apply colour map to.

  • thickness – Thickness of network lines

  • frame (np.ndarray) – This is the unmodified frame of the input movie

  • data (pandas dataframe) – This is the dataframe that stores all the tracked data

  • f (int) – frame index

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

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

Returns

annotated frame

Return type

np.ndarray