repic.utils.common

Common functions and libraries shared across REPIC scripts

Attributes

print

partial function to have all print statements flush buffer

box_id

NetworkX initial vertex (particle bounding box) ID

Functions

adjust_plot_attributes(ax, xlabel, ylabel[, fontsize])

Adjusts general Matplotlib plot parameters

is_float(val)

Checks if Python object can be converted to float datatype

create_dir(dir_path)

Creates directory at provided location

del_dir(dir_path)

Deletes directory if it exists

get_box_coords(pattern[, key, size, return_weights])

Parses particle bounding box file and returns particle bounding box coordinates

get_box_vertex_entry(coord, clique_size, index)

Returns particle bounding box coordinates of a clique as a vector

get_multi_in_coords(in_file)

Parses a particle bounding box file that contains multiple boxes per line (optimal cliques) and returns their coordinates, labels, and weights

write_pickle(data, out_file)

Writes provided data to storage in Pickle format

Module Contents

repic.utils.common.print

partial function to have all print statements flush buffer

Type:

func

repic.utils.common.box_id = 0

NetworkX initial vertex (particle bounding box) ID

Type:

int

repic.utils.common.adjust_plot_attributes(ax, xlabel, ylabel, fontsize=32)

Adjusts general Matplotlib plot parameters

Parameters:
  • ax (obj) – Matplotlib axis object

  • xlabel (str) – x-axis label

  • ylabel (str) – y-axis label

Keyword Arguments:

fontsize (int, default=32) – font size of plot text

Returns:

None

repic.utils.common.is_float(val)

Checks if Python object can be converted to float datatype

Parameters:

val (obj) – Python object

Returns:

True if string can be converted (False otherwise)

Return type:

bool

repic.utils.common.create_dir(dir_path)

Creates directory at provided location

Parameters:

dir_path (str) – file path to directory

Returns:

file path to directory

Return type:

str

repic.utils.common.del_dir(dir_path)

Deletes directory if it exists

Parameters:

dir_path (str) – file path to directory

Returns:

file path to directory

Return type:

str

repic.utils.common.get_box_coords(pattern, key=1.0, size=None, return_weights=False)

Parses particle bounding box file and returns particle bounding box coordinates

Parameters:

pattern (str) – filename RegEx pattern

Keyword Arguments:
  • key (float, default=1.) – method key for k-d tree building

  • size (int or None) – restrict the number of coordinates returned to this value

  • return_weight (bool, default=False) – flag to include particle bounding box score or confidence in return

Returns:

list of particle bounding box coordinates

Return type:

list

repic.utils.common.get_box_vertex_entry(coord, clique_size, index)

Returns particle bounding box coordinates of a clique as a vector

Parameters:
  • coord (list) – particle bounding box coordinates

  • clique_size (int) – size of clique

  • index (int) – position of particle bounding boxes in clique (determined by order of particle picking algorithms)

Returns:

particle coordinates formatted for multi-out output

Return type:

list

repic.utils.common.get_multi_in_coords(in_file)

Parses a particle bounding box file that contains multiple boxes per line (optimal cliques) and returns their coordinates, labels, and weights

Parameters:

in_file (str) – filepath to particle bounding box file

Returns:

lists of particle bounding box coordinates, labels, and weights

Return type:

list, list, list

repic.utils.common.write_pickle(data, out_file)

Writes provided data to storage in Pickle format

Parameters:
  • data (obj) – NumPy array object

  • out_file (str) – filepath for output file

Returns:

None