Documented functions with links to source¶
Program to trace helices from micrographs
-
class
michelixtrace.
MicHelixTracePar
[source]¶ Class to initiate default dictionary with input parameters including help and range values and status dictionary
Methods
set_compute_recall_precision
(feature_set)define_input_and_output_michelixtrace
define_michelixtrace_parameters
define_parameters_and_their_properties
define_program_states
set_a_threshold
set_absolute_threshold
set_absolute_threshold_option
set_box_file_step
set_ground_truth_coord_file
set_helix_length
set_helix_reference
set_invert_option
set_order_fit
set_parameter_search_option
set_pruning_cutoff
-
class
michelixtrace.
MicHelixTrace
(parset=None)[source]¶ Class that holds functions for examining micrograph quality
__init__ Function to read in the entered parameter dictionary and load micrograph
Usage: MicrographExam(pardict)
Input: pardict = OrderedDict of program parameters
Methods
bwmorph_thin
(image[, n_iter])Perform morphological thinning of a binary image
>>> from spring.micprgs.michelixtrace import MicHelixTrace
determine_xy_center_grid
(tile_size, overlap, …)>>> from spring.micprgs.michelixtrace import MicHelixTrace
gold_particles_mask
(mic_1d[, thr])- param mic_1d
Ravelled (1D) micrograph
model_circle
(radius_y, radius_x, ydim, xdim)>>> from spring.micprgs.michelixtrace import MicHelixTrace
model_square
(length_y, length_x, ydim, xdim)>>> from spring.micprgs.michelixtrace import MicHelixTrace
Updated Util.multiref_polar_ali_2d(currimg, [polarrefs], [txrng], [tyrng], ringstep, mode, alignrings, halfdim, halfdim) 2020-12-04 1.
>>> from spring.micprgs.michelixtrace import MicHelixTrace
smooth_mask_helix
(pixelsize, reference)- return
boxfunction with smooth edges for masking the reference helix
build_cc_image_of_helices
compute_length_of_fit
compute_persistence_length
compute_precision_and_recall_of_traces_with_respect_ground_truth
compute_step_size
correct_coordinates_and_visualize_traces
define_all_michelixtrace_parameters
enter_helixinfo_into_springdb
find_translations_by_cc
fit_and_create_coordinates_according_to_order
generate_and_plot_parameter_search_summary
generate_stack_of_overlapping_images_powers
get_branch_point_response
get_interactively_traced_helices_to_compare
get_lookup_table_for_bwmorph_thin
get_mask
get_rid_of_branchpoints_and_crossings
mask_micrograph_edges
perform_absolute_thresholding_of_ccmap
perform_connected_component_analysis
perform_thresholding_of_ccmap
prepare_compute_rho_theta_cc_based_on_overlapping_tiles
prepare_power_from_reference
preprocess_micrograph
prune_helices_and_plot_persistence_length_summary
trace_helices
trace_helices_in_micrographs
treshold_and_clean_up_binary_map
update_plot_info_and_helix_info_for_each_micrograph
write_boxfiles_from_helix_info
write_helixinfo
write_out_determined_tracing_criteria_in_database
-
gold_particles_mask
(mic_1d, thr=0.001)[source]¶ - Parameters
mic_1d – Ravelled (1D) micrograph
thr – Threshold when to treat pixel value as gold particle. Corresponds to alpha value in hypothesis testing when we test for every pixel value if it deviates (left-sided) from the null hypothesis
- Returns
1D mask that is 1 where the micrograph contains a gold particle, otherwise 0.
-
smooth_mask_helix
(pixelsize, reference)[source]¶ - Returns
boxfunction with smooth edges for masking the reference helix
-
determine_xy_center_grid
(tile_size, overlap, x_size, y_size)[source]¶ >>> from spring.micprgs.michelixtrace import MicHelixTrace >>> MicHelixTrace().determine_xy_center_grid(15, 50, 50, 100) array([[(7.0, 7.0), (7.0, 14.0), (7.0, 21.0), (7.0, 28.0), (7.0, 35.0), (7.0, 42.0), (7.0, 49.0), (7.0, 56.0), (7.0, 63.0), (7.0, 70.0), (7.0, 77.0), (7.0, 84.0), (7.0, 91.0)], [(14.0, 7.0), (14.0, 14.0), (14.0, 21.0), (14.0, 28.0), (14.0, 35.0), (14.0, 42.0), (14.0, 49.0), (14.0, 56.0), (14.0, 63.0), (14.0, 70.0), (14.0, 77.0), (14.0, 84.0), (14.0, 91.0)], [(21.0, 7.0), (21.0, 14.0), (21.0, 21.0), (21.0, 28.0), (21.0, 35.0), (21.0, 42.0), (21.0, 49.0), (21.0, 56.0), (21.0, 63.0), (21.0, 70.0), (21.0, 77.0), (21.0, 84.0), (21.0, 91.0)], [(28.0, 7.0), (28.0, 14.0), (28.0, 21.0), (28.0, 28.0), (28.0, 35.0), (28.0, 42.0), (28.0, 49.0), (28.0, 56.0), (28.0, 63.0), (28.0, 70.0), (28.0, 77.0), (28.0, 84.0), (28.0, 91.0)], [(35.0, 7.0), (35.0, 14.0), (35.0, 21.0), (35.0, 28.0), (35.0, 35.0), (35.0, 42.0), (35.0, 49.0), (35.0, 56.0), (35.0, 63.0), (35.0, 70.0), (35.0, 77.0), (35.0, 84.0), (35.0, 91.0)], [(42.0, 7.0), (42.0, 14.0), (42.0, 21.0), (42.0, 28.0), (42.0, 35.0), (42.0, 42.0), (42.0, 49.0), (42.0, 56.0), (42.0, 63.0), (42.0, 70.0), (42.0, 77.0), (42.0, 84.0), (42.0, 91.0)]], dtype=object)
-
orient_reference_power_with_overlapping_powers
(pw_stack, ref_power, xy_center_grid)[source]¶ Updated Util.multiref_polar_ali_2d(currimg, [polarrefs], [txrng], [tyrng], ringstep, mode, alignrings, halfdim, halfdim) 2020-12-04 1. EMAN::EMData*, 2. list std::__1::vector<EMAN::EMData*, std::__1::allocator<EMAN::EMData*> > 3. list std::__1::vector<float, std::__1::allocator<float>, 4. list std::__1::vector<float, std::__1::allocator<float> >, 5. float 6. std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 7. std::__1::vector<int, std::__1::allocator<int> > 8. float 9. float
-
build_cc_image_of_helices
(rhos, thetas, cross_corr, xy_center_grid, x_size, y_size, tilesize, overlap_percent)[source]¶
-
bwmorph_thin
(image, n_iter=None)[source]¶ Perform morphological thinning of a binary image
- Parameters
- imagebinary (M, N) ndarray
The image to be thinned.
- n_iterint, number of iterations, optional
Regardless of the value of this parameter, the thinned image is returned immediately if an iteration produces no change. If this parameter is specified it thus sets an upper bound on the number of iterations performed.
- Returns
- outndarray of bools
Thinned image.
See also
skeletonize
Notes
This algorithm [1] works by making multiple passes over the image, removing pixels matching a set of criteria designed to thin connected regions while preserving eight-connected components and 2 x 2 squares [2]. In each of the two sub-iterations the algorithm correlates the intermediate skeleton image with a neighborhood mask, then looks up each neighborhood in a lookup table indicating whether the central pixel should be deleted in that sub-iteration.
References
- 1
Z. Guo and R. W. Hall, “Parallel thinning with two-subiteration algorithms,” Comm. ACM, vol. 32, no. 3, pp. 359-373, 1989.
- 2
Lam, L., Seong-Whan Lee, and Ching Y. Suen, “Thinning Methodologies-A Comprehensive Survey,” IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol 14, No. 9, September 1992, p. 879
Examples
>>> from spring.micprgs.michelixtrace import MicHelixTrace >>> m = MicHelixTrace() >>> square = np.zeros((7, 7), dtype=np.uint8) >>> square[1:-1, 2:-2] = 1 >>> square[0,1] = 1 >>> square array([[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]], dtype=uint8) >>> skel = m.bwmorph_thin(square) >>> skel.astype(np.uint8) array([[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
-
set_up_branch_point_response
()[source]¶ >>> from spring.micprgs.michelixtrace import MicHelixTrace >>> m = MicHelixTrace() >>> b = m.set_up_branch_point_response() >>> assert b == m.get_branch_point_response()
-
model_circle
(radius_y, radius_x, ydim, xdim, center_y=None, center_x=None)[source]¶ >>> from spring.micprgs.michelixtrace import MicHelixTrace >>> m = MicHelixTrace() >>> m.model_circle(3, 5, 10, 12) array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 0., 0.], [0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.], [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], [0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.], [0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 0., 0.], [0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
>>> m.model_circle(3, 3, 10, 12, -1, 1) array([[1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
-
model_square
(length_y, length_x, ydim, xdim, center_y=None, center_x=None)[source]¶ >>> from spring.micprgs.michelixtrace import MicHelixTrace >>> m = MicHelixTrace() >>> m.model_square(6., 3., 10, 12) array([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 1., 1., 1., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
>>> m.model_square(6, 6, 10, 12, -1, 1) array([[1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
-
define_thresholds_and_minimum_helix_lengths
(parametersearch_option, a_threshold, min_helix_length, max_helix_length, absolutethresholdoption, absolute_threshold)[source]¶ >>> from spring.micprgs.michelixtrace import MicHelixTrace >>> m = MicHelixTrace() >>> m.define_thresholds_and_minimum_helix_lengths(False, 0.01, 500, 1000, False, 0) ([0.01], [(500, 1000)]) >>> m.define_thresholds_and_minimum_helix_lengths(True, 0.01, 500, 1000, False, 0) ([0.0001, 0.001, 0.01, 0.1, 1.0], [(200, 500), (350, 875), (500, 1250), (650, 1625), (800, 2000)]) >>> m.define_thresholds_and_minimum_helix_lengths(True, 0.01, 500, 1000, True, 0.5) ([0.09999999999999998, 0.3, 0.5, 0.7, 0.9], [(200, 500), (350, 875), (500, 1250), (650, 1625), (800, 2000)])
-
prepare_compute_rho_theta_cc_based_on_overlapping_tiles
(micrograph_files, ref_power, ref, each_id, each_mic)[source]¶
-
compute_precision_and_recall_of_traces_with_respect_ground_truth
(parameter_info, ground_truth_info, each_mic_name, size_y, size_x, each_threshold, each_min_helix_length, helices)[source]¶