Documented functions with links to source

Program to extract overlapping segments from micrographs

class segment_prep.SegmentPar[source]

Class to initiate default dictionary with input parameters including help and range values and status dictionary

Methods

define_parameters_and_their_properties

define_program_states

set_center_and_remove_ends_for_helices

set_center_option

set_ctf_correct

set_ctf_correct_option

set_frame_first_and_last_frame

set_frame_processing_option

set_helix_or_particle_centering

set_invert_option

set_normalization_option

set_perturb_step_option

set_ref_db_frame_processing

set_remove_helix_ends_option

set_rotation_option

set_rows_normalization_option

set_segment_coordinate_files

set_segment_or_window_features

set_segment_size

set_segmentation_step

set_straightening_option

set_segment_or_window_features()[source]
set_center_and_remove_ends_for_helices()[source]
set_helix_or_particle_centering()[source]
define_parameters_and_their_properties()[source]
define_program_states()[source]
set_segment_coordinate_files(feature_set)[source]
set_segment_size(feature_set)[source]
set_segmentation_step(feature_set)[source]
set_perturb_step_option(feature_set)[source]
set_invert_option(feature_set)[source]
set_center_option(feature_set)[source]
set_remove_helix_ends_option(feature_set)[source]
set_normalization_option(feature_set)[source]
set_rotation_option(feature_set)[source]
set_straightening_option(feature_set)[source]
set_ctf_correct_option(feature_set)[source]
set_rows_normalization_option(feature_set)[source]
set_ctf_correct(feature_set)[source]
set_frame_processing_option(feature_set)[source]
set_frame_first_and_last_frame(feature_set)[source]
set_ref_db_frame_processing(feature_set)[source]
class segment_prep.SegmentAssign[source]

Methods

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

remove_helices_segments_from_tables

Function to create symbolic link in new directory

  1. Input: micfile (file for wich symbolic link is to be created), overlapdir = new directory for symbolic link location

  2. Output: symbolic link absolute path

  3. Usage: micabsfile = create_link(micfile, ovelapdir)

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)[source]
  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

  1. Input: list of 3-tuples (micrograph file, segment file, overlapping letters)

  2. Output: None

  3. Usage: reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

assign_micrograph_segment_pairs(micrograph_files, coordinate_files)[source]
  • Function to assign pairs of micrographs and segment files based on their common filenames

  1. Input: micrograph_files = list of input micrographs, coordinate_files = list of segment files

  2. Ouput: list of tuples consisting micrograph, corresponding segment file and their common base filename

  3. Usage: assign_micrograph_segment_pairs(micrograph_files, coordinate_files)

>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> mics = ['A.tif', 'B.tif', 'C.tif', 'Y.tif']
>>> boxes = ['A.box', 'B.box', 'C.box', 'Z.box']
>>> s.assign_micrograph_segment_pairs(mics, boxes)
[('A.tif', 'A.box', 'A'), ('B.tif', 'B.box', 'B'), ('C.tif', 'C.box', 'C')]
>>> boxes = ['A_boxes.txt', 'B_boxes.txt', 'C_boxes.txt', 'Z_boxes.txt']
>>> s.assign_micrograph_segment_pairs(mics, boxes)
[('A.tif', 'A_boxes.txt', 'A'), ('B.tif', 'B_boxes.txt', 'B'), ('C.tif', 'C_boxes.txt', 'C')]
remove_helices_segments_from_tables(session, segments, combined_included_segments, segment_table, helix_table, red_helix_ids)[source]
perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb(db_name)[source]
assign_reorganize(micrograph_files, coordinate_files)[source]
  • Function to match micrographs and corresponding segment file

  1. Input: list of input micrographs, list of segment files

  2. Output: assigned pair of micrograph and segments

  3. Usage: assign_reorganize(micrograph_files, coordinate_files)

class segment_prep.SegmentPreparation(parset=None)[source]
  • Class that holds functions for extracting segments from micrographs

  • __init__ Function to interpret multi-input parameters

Methods

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

adjust_gray_values_for_print_and_optimal_display

check_whether_spring_db_entries_match_provided_micrographs

define_ctf_parameters

define_segment_or_window_parameters

get_message_for_frame_missing

get_statistics_from_image

get_strip_frame

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

remove_helices_segments_from_tables

validate_input

define_segment_or_window_parameters(p)[source]
define_ctf_parameters(p)[source]
get_strip_frame(first_frame)[source]
get_message_for_frame_missing(first_frame, first_str, mics)[source]
check_whether_provided_frame_number_matches_provided_micrographs(micrographs, input_mics, frame_range)[source]
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> mics = ['test.hdf', 'tost.hdf']
>>> input_mics = ['test_{0:03}.hdf'.format(each) for each in list(range(5))]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs(mics, input_mics, (0, 4))
[('test.hdf', ['test_000.hdf', 'test_001.hdf', 'test_002.hdf', 'test_003.hdf', 'test_004.hdf'])]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs(mics, input_mics, (2, 4))
[('test.hdf', ['test_002.hdf', 'test_003.hdf', 'test_004.hdf'])]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs(mics, input_mics, (2, 7)) 
Traceback (most recent call last):
    ...
ValueError: Specified last frame 7 cannot be found in pool of provided 
micrographs (test_000.hdf, test_001.hdf, test_002.hdf, test_003.hdf, 
test_004.hdf). Double-check existance of frame or correct last frame entry.
check_whether_provided_frame_number_matches_provided_micrographs_old(micrographs, input_mics, frame_count)[source]
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> mics = ['test.hdf', 'tost.hdf']
>>> input_mics = ['test_{0:03}.hdf'.format(each) for each in list(range(5))]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs_old(mics, input_mics, 5)
[('test.hdf', ['test_000.hdf', 'test_001.hdf', 'test_002.hdf', 'test_003.hdf', 'test_004.hdf'])]
>>> input_mics = ['test_{0:02}.hdf'.format(each) for each in list(range(5))]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs_old(mics, input_mics, 5)
[('test.hdf', ['test_00.hdf', 'test_01.hdf', 'test_02.hdf', 'test_03.hdf', 'test_04.hdf'])]
>>> input_mics = ['test_{0:02}.hdf'.format(each) for each in list(range(5, 10))]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs_old(mics, input_mics, 5)
[('test.hdf', ['test_05.hdf', 'test_06.hdf', 'test_07.hdf', 'test_08.hdf', 'test_09.hdf'])]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs_old(mics, input_mics, 6) 
Traceback (most recent call last):
    ...
ValueError: The number of provided frames (=6) from test_05.hdf, 
test_06.hdf, test_07.hdf, test_08.hdf, test_09.hdf does not match the 
'Processing frame number' (=6) specified. Please, change input 
files of frames or the 'Processing frame number'.
>>> input_mics = ['test_ttt.hdf'.format(each) for each in list(range(5))]
>>> s.check_whether_provided_frame_number_matches_provided_micrographs_old(mics, input_mics, 4) 
Traceback (most recent call last):
    ...
ValueError: The provided frames (test_ttt.hdf, test_ttt.hdf, 
test_ttt.hdf, test_ttt.hdf, test_ttt.hdf) can not be 
assigned because they do not follow the pattern: test.hdf - 
test_000.hdf, test_001.hdf, test_002.hdf, test_003.hdf, test_004.hdf.
Please rename to make frames assignable to previous micrograph.
check_whether_spring_db_entries_match_provided_micrographs()[source]
validate_input()[source]
determine_boxsize_closest_to_fast_values(boxsize_ori, ten=False)[source]

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

class segment_prep.SegmentPreparationFileRead(parset=None)[source]

Methods

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

define_ctf_parameters

define_segment_or_window_parameters

get_message_for_frame_missing

get_statistics_from_image

get_strip_frame

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

remove_helices_segments_from_tables

validate_input

read_coordinate_lines_from_eman_format_and_separate_helices(box_coord)[source]
>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']
>>> lines += ['30\t30\t100\t100\t-2\n', '20\t20\t100\t100\t-1\n',]
>>> box_coord = lines + ['10\t10\t100\t100\t-2\n']
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> s.read_coordinate_lines_from_eman_format_and_separate_helices(box_coord) 
['50\t50\t100\t100\t-1\n40\t40\t100\t100\t0\n30\t30\t100\t100\t-2\n', 
'20\t20\t100\t100\t-1\n10\t10\t100\t100\t-2\n']
add_start_or_end_flag(bsoft_coord, id_pos, helixcoord, helix, previous_helix_id, each_index, current_helix_id)[source]
append_final_helix(helixcoord, helix)[source]
read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(bsoft_coord, segment_size=40.0)[source]
>>> bsoft = [ '_particle.select\n']
>>> ln1 = '1    1       0  1.0000  366.00 2058.00    0.00  20.000  20.0'
>>> ln1 += '00   0.000  1.0000  0.0000  0.0000   34.79  1.0000    1\n'
>>> ln2 = '2    1       0  1.0000  382.43 2046.59    0.00  20.000  20.0'
>>> ln2 += '00   0.000  1.0000  0.0000  0.0000   34.79  1.0000    1\n'
>>> ln3 = '3    2       0  1.0000 1326.17 2107.80    0.00  20.000  20.0'
>>> ln3 += '00   0.000  1.0000  0.0000  0.0000  -54.08  1.0000    2\n'
>>> ln4 = '4    2       0  1.0000 1326.17 2107.80    0.00  20.000  20.0'
>>> ln4 += '00   0.000  1.0000  0.0000  0.0000  -54.08  5.0000    2\n'
>>> ln5 = '5    2       0  1.0000 1326.17 2107.80    0.00  20.000  20.0'
>>> ln5 += '00   0.000  1.0000  0.0000  0.0000  -54.08  5.0000    2\n'
>>> bsoft += [ln1, ln2, ln3, ln4, ln5, '\n', '\n', 'loop_\n']
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> s.read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(bsoft) 
['346.0\t2038.0\t40.0\t40.0\t-1\n362.43\t2026.59\t40.0\t40.0\t-2\n', 
'1306.17\t2087.8\t40.0\t40.0\t-1\n1306.17\t2087.8\t40.0\t40.0\t0\n1306.17\t2087.8\t40.0\t40.0\t-2\n']
>>> bsoft = [ '_filament.z\n','      1      1  366.00 2058.00    0.00\n']
>>> bsoft += ['      1      2  461.00 1992.00    0.00\n']
>>> bsoft += ['      2      1  553.00 1905.00    0.00\n']
>>> bsoft += ['      3      1  641.00 1838.00    0.00\n']
>>> bsoft += ['      3      2  707.33 1800.67    0.00\n', '\n']
>>> s.read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(bsoft)
[]
read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(bsoft_coord, segment_size=40.0)[source]
>>> bsoft =  [ '_filament.z\n']
>>> bsoft += ['      1      1  366.00 2058.00    0.00\n']
>>> bsoft += ['      1      2  461.00 1992.00    0.00\n']
>>> bsoft += ['      1      3  553.00 1905.00    0.00\n']
>>> bsoft += ['      2      1  641.00 1838.00    0.00\n']
>>> bsoft += ['      2      2  707.33 1800.67    0.00\n', '\n']
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> s.read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(bsoft) 
['346.0\t2038.0\t40.0\t40.0\t-1\n441.0\t1972.0\t40.0\t40.0\t0\n533.0\t1885.0\t40.0\t40.0\t-2\n', 
'621.0\t1818.0\t40.0\t40.0\t-1\n687.33\t1780.67\t40.0\t40.0\t-2\n']
>>> bsoft = ['_filament.id\n', '_filament.node_id\n']
>>> bsoft += ['_filament.id\n', '_filament.node_id\n', '_filament.x\n']
>>> bsoft += ['_filament.y\n', '_filament.z\n'] 
>>> bsoft += ['      1      1  100.00  100.00    0.00\n']
>>> bsoft += ['      1      2   60.00   60.00    0.00\n', '\n', '\n']
>>> s.read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(bsoft)
['80.0\t80.0\t40.0\t40.0\t-1\n40.0\t40.0\t40.0\t40.0\t-2\n']
class segment_int.SegmentInterpolation(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

fill_in_helix_info_from_coordinates

get_message_for_frame_missing

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

prepare_segmentation

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_helices_segments_from_tables

validate_input

make_helixinfo_named_tuple()[source]
convert_coordinate_line_to_xy_coordinates(each_coordinate_line)[source]
compute_cumulative_distances_from_start_of_helix(x_coordinates, y_coordinates)[source]
>>> from spring.segment2d.segment import Segment
>>> x_coordinates = y_coordinates = np.arange(10)
>>> s = Segment()
>>> s.compute_cumulative_distances_from_start_of_helix(x_coordinates, y_coordinates)
array([ 0.        ,  1.41421356,  2.82842712,  4.24264069,  5.65685425,
        7.07106781,  8.48528137,  9.89949494, 11.3137085 , 12.72792206])
>>> x_coordinates = 10 * np.ones(10)
>>> y_coordinates = np.arange(10)
>>> s.compute_cumulative_distances_from_start_of_helix(x_coordinates, y_coordinates)
array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
enter_helixinfo_into_helices_and_write_boxfiles(helices, micfile, overlap, helixfile, ipangle, curvature, picked_coordinates, int_xy_coordinates)[source]
enter_helixinfo_into_helices(helices, micfile, overlap, helixfile, ipangle, curvature, picked_coordinates, int_xy_coordinates)[source]
perform_interpolation_perturbation_removal_if_required(helices, segfile, stepsize, pixelsize, helixwidth, micfile, overlap, helixfile, x_coordinates, y_coordinates)[source]
fill_in_helix_info_from_coordinates(helices, segfile, stepsize, pixelsize, helixwidth, micfile, overlap, mic_hindex, x_coordinates, y_coordinates)[source]
compute_new_coordinates_with_given_stepsize(helices, segfile, stepsize, pixelsize, helixwidth, micfile, overlap, helixcoord)[source]
get_picked_coordinates_from_database(micfile, db_name, session)[source]
get_picked_coordinates_from_file(segfile, overlap)[source]
assign_ids_based_on_new_frames(inp_stack_ids, inp_mics, mic_coord)[source]
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> mic_coord = [list(zip(np.arange(3), np.arange(3))), list(zip(np.arange(5), np.arange(5)))]
>>> first = s.assign_ids_based_on_new_frames([], list(range(5)), mic_coord)
>>> first 
[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]
>>> s.assign_ids_based_on_new_frames(first, list(range(5)), mic_coord) 
[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 
11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15]
>>> helices = [1, 2]
>>> s.assign_ids_based_on_new_frames([], list(range(5)), helices)
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
single_out(pair, stepsize, pixelsize, assigned_mics)[source]
  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

  1. Input: list of 3-tuples (micrograph file, segment file, overlapping letters), stepsize, pixelsize

  2. Output: list of helices containing micrograph, segment_list, directory, coordinates, inplane_angle

  3. Usage: self.helices = single_out(pair, stepsize, pixelsize)

prepare_segmentation()[source]
determine_angle_to_rotate_coordinates_to_minimal_slope(xcoord, ycoord, helixwidth)[source]
rotate_coordinates_by_angle(xcoord, ycoord, angle_in_deg, center_x=0, center_y=0)[source]
  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

  1. Input: x- and y-array, angle_in_deg to be rotated

  2. Output: rotated x- and y-array

  3. Usage: rotx, roty = rotate_coordinates_by_angle(xcoord, ycoord, angle_in_deg)

>>> import numpy as np
>>> np.arange(0, 10)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.zeros(10)
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> rot_x, rot_y = s.rotate_coordinates_by_angle(np.arange(10), np.zeros(10), -90.0) 
>>> np.rint(rot_x)
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> np.rint(rot_y)
array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
>>> s.rotate_coordinates_by_angle(np.array([5]), np.array([0]), 180)
(array([-5.]), array([-6.123234e-16]))
>>> s.rotate_coordinates_by_angle(0, 0, 180, 4, 3)
(8.0, 6.0)
recalculate_xcoordinate_stepsize_to_perform_interpolation(rotated_xcoord, stepsize, new_stepsize)[source]
perform_interpolation_of_ycoordinates(rotated_xcoord, rotated_ycoord, interpolated_rotated_xcoord, segfile)[source]
perform_interpolation_derivative_for_in_plane_angle_rotation(interpolated_rotated_xcoord, interpolated_rotated_ycoord, rotated_xcoord, rotated_ycoord, segfile)[source]
write_boxfile(interpolated_xcoord=None, interpolated_ycoord=None, segsizepix=None, filename=None)[source]
  • Function to write out new boxparameters

  1. Input: interpolated x- and y-array, segment size (pixel), filename

  2. Output: written file filename

  3. Usage: write_boxfile(interpolated_xcoord, interpolated_ycoord, segsizepix, filename)

compute_persistence_length_m_from_coordinates_A(coord_x_A, coord_y_A)[source]
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> coord_x_A = np.arange(20) 
>>> coord_y_A = coord_x_A ** 2
>>> s.compute_persistence_length_m_from_coordinates_A(coord_x_A, coord_y_A)
5.146314847399703e-06
>>> coord_y_A = coord_x_A ** 1
>>> s.compute_persistence_length_m_from_coordinates_A(coord_x_A, coord_y_A)
1.0
>>> coord_y_A = 10 * np.sin(coord_x_A)
>>> s.compute_persistence_length_m_from_coordinates_A(coord_x_A, coord_y_A)
0.0
interpolate_coordinates(xcoord, ycoord, pixelsize, stepsize, helixwidth, segfile, new_stepsize=True)[source]
  • Function to interpolate x and y coordinates according to new stepsize

  1. Input: xarray and yarray of segment coordinates, pixelsize, stepsize and helixwidth in Angstrom

  2. Output: interpolated x and y-array, computed in-plane angle

  3. Usage: interpolated_xcoord, interpolated_ycoord, ipangle = interpolate_coordinates(xcoord, ycoord, pixelsize, stepsize, helixwidth, segfile)

>>> import numpy as np
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> i_xcoord, i_ycoord, in_plane_angle, curvature =             s.interpolate_coordinates(np.arange(10), np.arange(10), 1, 0.5, 3, 'test.box')
>>> np.round(i_xcoord, 2)
array([-0.  ,  0.35,  0.71,  1.06,  1.41,  1.77,  2.12,  2.47,  2.83,
        3.18,  3.54,  3.89,  4.24,  4.6 ,  4.95,  5.3 ,  5.66,  6.01,
        6.36,  6.72,  7.07,  7.42,  7.78,  8.13,  8.49,  8.84])
>>> np.round(i_ycoord, 2)
array([0.  , 0.35, 0.71, 1.06, 1.41, 1.77, 2.12, 2.47, 2.83, 3.18, 3.54,
       3.89, 4.24, 4.6 , 4.95, 5.3 , 5.66, 6.01, 6.36, 6.72, 7.07, 7.42,
       7.78, 8.13, 8.49, 8.84])
>>> np.round(in_plane_angle, 2)
array([135., 135., 135., 135., 135., 135., 135., 135., 135., 135., 135.,
       135., 135., 135., 135., 135., 135., 135., 135., 135., 135., 135.,
       135., 135., 135., 135.])
>>> interpolated_x_coordinates, interpolated_y_coordinates, in_plane_rotation_angle, curvature =                                     Segment().interpolate_coordinates(np.arange(10), 2*np.arange(10), 1, 3, 3, 'test.box')
>>> np.round(interpolated_x_coordinates, 1)
array([-0. ,  1.3,  2.7,  4. ,  5.4,  6.7,  8. ])
>>> np.round(interpolated_y_coordinates, 1)
array([ 0. ,  2.7,  5.4,  8. , 10.7, 13.4, 16.1])
>>> in_plane_rotation_angle
array([153.43494882, 153.43494882, 153.43494882, 153.43494882,
       153.43494882, 153.43494882, 153.43494882])
>>> # helix parallel to image rows
...
>>> interpolated_x_coordinates, interpolated_y_coordinates, in_plane_rotation_angle, curvature =                                     Segment().interpolate_coordinates(np.arange(10), np.zeros(10), 1, 3, 3, 'test.box')
>>> interpolated_x_coordinates
array([0., 3., 6.])
>>> np.round(interpolated_y_coordinates, 2)
array([0., 0., 0.])
>>> in_plane_rotation_angle
array([90., 90., 90.])
>>> # helix parallel to image columns
...
>>> interpolated_x_coordinates, interpolated_y_coordinates, in_plane_rotation_angle, curvature =                                     Segment().interpolate_coordinates(np.zeros(10), np.arange(10), 10, 20, 30, 'test.box')
>>> np.round(interpolated_y_coordinates, 0)
array([0., 2., 4., 6., 8.])
>>> in_plane_rotation_angle
array([180., 180., 180., 180., 180.])
>>> np.round(interpolated_x_coordinates, 2)
array([-0.,  0.,  0.,  0.,  0.])
class segment_int.SegmentStraighten(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

fill_in_helix_info_from_coordinates

fit_square_function_path_of_coordinates

get_message_for_frame_missing

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

prepare_segmentation

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_helices_segments_from_tables

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

select_coordinates_within_segment_dimensions(coordinates, current_center, segment_size_pix)[source]
>>> from spring.segment2d.segment import Segment
>>> Segment().select_coordinates_within_segment_dimensions(list(zip(np.arange(20.), np.arange(20., 40.))), (10, 30), 10.0)
(array([ 6.,  7.,  8.,  9., 10., 11., 12., 13., 14.]), array([26., 27., 28., 29., 30., 31., 32., 33., 34.]))
compute_bending_path_row_wise(length, polyfit, angle)[source]
>>> from spring.segment2d.segment import Segment
>>> Segment().compute_bending_path_row_wise(20.0, [1/20.0, -1.0, 15.0], 0)
(array([15.  , 14.05, 13.2 , 12.45, 11.8 , 11.25, 10.8 , 10.45, 10.2 ,
       10.05, 10.  , 10.05, 10.2 , 10.45, 10.8 , 11.25, 11.8 , 12.45,
       13.2 , 14.05]), array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10., 11., 12.,
       13., 14., 15., 16., 17., 18., 19.]), array([315.        , 318.0127875 , 321.34019175, 325.0079798 ,
       329.03624347, 333.43494882, 338.19859051, 343.30075577,
       348.69006753, 354.28940686, 360.        ,   5.71059314,
        11.30993247,  16.69924423,  21.80140949,  26.56505118,
        30.96375653,  34.9920202 ,  38.65980825,  41.9872125 ]))
>>> Segment().compute_bending_path_row_wise(20.0, [1/20.0, -1.0, 15.0], 90)
(array([20., 19., 18., 17., 16., 15., 14., 13., 12., 11., 10.,  9.,  8.,
        7.,  6.,  5.,  4.,  3.,  2.,  1.]), array([15.  , 14.05, 13.2 , 12.45, 11.8 , 11.25, 10.8 , 10.45, 10.2 ,
       10.05, 10.  , 10.05, 10.2 , 10.45, 10.8 , 11.25, 11.8 , 12.45,
       13.2 , 14.05]), array([225.        , 228.0127875 , 231.34019175, 235.0079798 ,
       239.03624347, 243.43494882, 248.19859051, 253.30075577,
       258.69006753, 264.28940686, 270.        , 275.71059314,
       281.30993247, 286.69924423, 291.80140949, 296.56505118,
       300.96375653, 304.9920202 , 308.65980825, 311.9872125 ]))
shift_and_rotate_image_linear(image, inplane_angle, each_x, each_y)[source]
convert_rotate_shift_to_shift_rotate_order(inplane_angle, each_x, each_y)[source]
>>> from spring.segment2d.segment import Segment
>>> a, b, c = Segment().convert_shift_rotate_to_rotate_shift_order(50,22,2)
>>> Segment().convert_rotate_shift_to_shift_rotate_order(a, b, c)
(49.99999868188684, 22.0, 2.0)
convert_shift_rotate_to_rotate_shift_order(inplane_angle, each_x, each_y)[source]
>>> from spring.segment2d.segment import Segment
>>> Segment().convert_shift_rotate_to_rotate_shift_order(50,22,2)
(49.99999868188683, 15.673417091369629, -15.567402839660645)
shift_and_rotate_image(image, inplane_angle, each_x, each_y)[source]
straighten_segment(helix_img, img_size, cols, rows, inplane_angles, mode='straighten')[source]
compute_rotated_helix_path_on_segment_locally(current_coordinates, cut_coordinates, current_inplane_angle, large_segsizepix, filtered_x, filtered_y)[source]
>>> from spring.segment2d.segment import Segment
>>> Segment().compute_rotated_helix_path_on_segment_locally((17.0, 87.0), (17, 87), 180.0, 10.0, np.arange(10, 20), np.arange(80, 90))
(array([12., 11., 10.,  9.,  8.,  7.,  6.,  5.,  4.,  3.]), array([12., 11., 10.,  9.,  8.,  7.,  6.,  5.,  4.,  3.]))
set_polyfit_variable(large_segsizepix, current_inplane_angle, second_order_fit)[source]
fit_square_function_path_of_coordinates(large_segsizepix, helix_coordinates, current_coordinates, cut_coordinates, current_inplane_angle, second_order_fit=None)[source]
unbend_segment_using_coordinates(segment, large_segsizepix, helix_coordinates, current_coordinates, cut_coordinates, current_inplane_angle, second_order_fit=None)[source]

Program to correct helical segments by determined CTF

class segmentctfapply.SegmentCtfApplyPar[source]

Class to initiate default dictionary with input parameters including help and range values and status dictionary

Methods

add_ctf_correct_option_as_relative

define_parameters_and_their_properties

define_program_states

set_astigmatism_option

set_ctf_correct

set_ctfconvolve_or_ctfphase_flip_option

set_ctffind_or_ctftilt_choice

define_parameters_and_their_properties()[source]
define_program_states()[source]
add_ctf_correct_option_as_relative(feature_set, inp7)[source]
set_ctffind_or_ctftilt_choice(feature_set)[source]
set_ctfconvolve_or_ctfphase_flip_option(feature_set)[source]
set_astigmatism_option(feature_set)[source]
set_ctf_correct(feature_set)[source]
class segmentctfapply.SegmentCtfApplyCtfFindCtfTilt(parset=None)[source]

Methods

define_ctf_correction_parameters

define_ctf_correction_parameters(obj, p)[source]
class segmentctfapply.SegmentCtfApplyConversion(parset=None)[source]

Methods

compute_local_defocus_from_ctftilt_parameters(…)

>>> from spring.segment2d.segmentctfapply import SegmentCtfApply

convert_mrc_defocus_to_sparx_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

convert_mrc_defocus_to_spider_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

define_ctf_correction_parameters

compute_local_defocus_from_ctftilt_parameters(coord_x, coord_y, df1, df2, center_x, center_y, pixelsize, taxis, tangle)[source]
>>> from spring.segment2d.segmentctfapply import SegmentCtfApply
>>> s = SegmentCtfApply()
>>> s.compute_local_defocus_from_ctftilt_parameters(500, 500, 37735.65, 42714.57, 500, 500, 5.0, 135.10, -19.97)
(37735.65, 42714.57)
>>> s.compute_local_defocus_from_ctftilt_parameters(1, 1000, 37735.65, 42714.57, 500, 500, 5.0, 135.10, -19.97)
(37739.1747698892, 42718.0947698892)
>>> s.compute_local_defocus_from_ctftilt_parameters(1, 1, 37735.65, 42714.57, 500, 500, 5.0, 135.10, -19.97)
(36453.48835358775, 41432.40835358775)
>>> s.compute_local_defocus_from_ctftilt_parameters(1000, 1, 37735.65, 42714.57, 500, 500, 5.0, 135.10, -19.97)
(37734.69469232806, 42713.61469232806)
>>> c_x = np.array([1000, 500])
>>> c_y = np.array([1, 500])
>>> s.compute_local_defocus_from_ctftilt_parameters(c_x, c_y, 37735.65, 42714.57, 500, 500, 5.0, 135.10, -19.97)
(array([37734.69469233, 37735.65      ]), array([42713.61469233, 42714.57      ]))
convert_mrc_defocus_to_sparx_defocus(defocus1, defocus2, astigmation_angle)[source]
>>> from spring.micprgs.micctfdetermine import MicCtfDetermine
>>> SegmentCtfApply().convert_mrc_defocus_to_sparx_defocus(18000.0, 22000.0, 20.0)
(20000.0, 4000.0, 25.0)
>>> SegmentCtfApply().convert_mrc_defocus_to_sparx_defocus(18000.0, 22000.0, 80.0)
(20000.0, 4000.0, 145.0)
>>> SegmentCtfApply().convert_mrc_defocus_to_sparx_defocus(22000.0, 18000.0, 80.0)
(20000.0, 4000.0, 55.0)
convert_mrc_defocus_to_spider_defocus(defocus1, defocus2, astigmation_angle)[source]
>>> from spring.micprgs.micctfdetermine import MicCtfDetermine
>>> SegmentCtfApply().convert_mrc_defocus_to_spider_defocus(18000.0, 22000.0, 20.0)
(20000.0, 4000.0, 155.0)
>>> SegmentCtfApply().convert_mrc_defocus_to_spider_defocus(18000.0, 22000.0, 80.0)
(20000.0, 4000.0, 35.0)
>>> SegmentCtfApply().convert_mrc_defocus_to_spider_defocus(22000.0, 18000.0, 80.0)
(20000.0, 4000.0, 125.0)
class segmentctfapply.SegmentCtfApplyDatabase(parset=None)[source]

Methods

compute_local_defocus_from_ctftilt_parameters(…)

>>> from spring.segment2d.segmentctfapply import SegmentCtfApply

convert_mrc_defocus_to_sparx_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

convert_mrc_defocus_to_spider_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

define_ctf_correction_parameters

get_ctf_values_from_database_and_compute_local_ctf_based_if_demanded

get_ctfparameters_from_database

get_micrograph_from_database_by_micid

get_micrograph_from_database_by_micname

raise_error_if_not_found

update_ctfparameters_in_database

raise_error_if_not_found(spring_path, matched_mic_find)[source]
get_micrograph_from_database_by_micid(session, mic_id, spring_path)[source]
get_micrograph_from_database_by_micname(session, micrograph_file, spring_path)[source]
get_ctfparameters_from_database(ctffind_or_ctftilt_choice, astigmatism_option, pixelsize, session, each_segment, matched_mic_find, spring_path)[source]
update_ctfparameters_in_database(ctffind_or_ctftilt_choice, convolve_or_phaseflip_choice, astigmatism_option, session, each_segment, avg_defocus, astigmatism, astig_angle)[source]
get_ctf_values_from_database_and_compute_local_ctf_based_if_demanded(ctffind_or_ctftilt_choice, convolve_or_phaseflip_choice, astigmatism_option, pixelsize, spring_path)[source]
class segmentctfapply.SegmentCtfApply(parset=None)[source]

Methods

compute_local_defocus_from_ctftilt_parameters(…)

>>> from spring.segment2d.segmentctfapply import SegmentCtfApply

convert_mrc_defocus_to_sparx_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

convert_mrc_defocus_to_spider_defocus(…)

>>> from spring.micprgs.micctfdetermine import MicCtfDetermine

apply_ctf_to_segment_stack

apply_ctf_to_segments

define_ctf_correction_parameters

filter_image_by_ctf_convolve_or_phaseflip

get_ctf_values_from_database_and_compute_local_ctf_based_if_demanded

get_ctfparameters_from_database

get_micrograph_from_database_by_micid

get_micrograph_from_database_by_micname

raise_error_if_not_found

update_ctfparameters_in_database

filter_image_by_ctf_convolve_or_phaseflip(convolve_or_phaseflip_choice, segment, each_segment_ctf_p)[source]
apply_ctf_to_segments(segment_ids, ctf_parameters, convolve_or_phaseflip_choice, infile_stack, outfile_stack)[source]
apply_ctf_to_segment_stack()[source]
segmentctfapply.main()[source]
class segment.SegmentCut(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

center_xycoordinates([xcoord, ycoord, …])

  • Function to apply shift perpedicular to helix to xy coordinates

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_new_micsize_if_coordinates_at_edges(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

cut_segments([helices, imgstack])

  • Function to cut segments from helices dictionary including micrograph information,

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

invert([img])

  • Function to invert segment image densities for cryo data (protein=white)

minimize_xposition([rowsaddimg, xshift])

  • Function to center helix axis due to 2fold symmetry of projection

normalize([img])

  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

verticalize_segment([im_out, ipangle])

  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

window_segment(micrograph, xcoord, ycoord, …)

  • Function to window segment from image part of cut_segments

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compare_centered_coordinates_with_picked_coordinates_and_smooth_path

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

fill_in_helix_info_from_coordinates

fit_square_function_path_of_coordinates

get_ctfinfo_header

get_log_info_header

get_message_for_frame_missing

get_mic_slice_from_mrc_stack

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

make_segment_info_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

pre_loop_setup

prepare_segmentation

read_micrograph_and_get_ctf_info

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_helices_segments_from_tables

rotate_and_unbend_segment_if_required

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

window_segment_and_invert_normalize_and_ctf_correct

compute_new_micsize_if_coordinates_at_edges(xcoord, ycoord, segsizepix, mic_xsize, mic_ysize)[source]
>>> from spring.segment2d.segment import Segment
>>> s = Segment()
>>> s.compute_new_micsize_if_coordinates_at_edges(10, 10, 30, 2000, 4000)
(2012, 4012, -990, -1990)
>>> s.compute_new_micsize_if_coordinates_at_edges(1995, 3995, 30, 2000, 4000)
(2022, 4022, 995, 1995)
>>> s.compute_new_micsize_if_coordinates_at_edges(-10, 10, 30, 2000, 4000)
(2052, 4012, -1010, -1990)
>>> s.compute_new_micsize_if_coordinates_at_edges(2005, 4005, 30, 2000, 4000)
(2042, 4042, 1005, 2005)
>>> s.compute_new_micsize_if_coordinates_at_edges(13463, 1924, 1216, 10880, 14035)
(17264, 14035, 8023, -5093)
window_segment(micrograph, xcoord, ycoord, segsizepix)[source]
  • Function to window segment from image part of cut_segments

  1. Input: x and y coordinates, segment size (pixel)

  2. Output: windowed segment

  3. Usage: im_out = window_segment(micrograph_img, xcoord, ycoord, segsizepix)

invert(img=None)[source]
  • Function to invert segment image densities for cryo data (protein=white)

  1. Input: segment image

  2. Output: inverted image segment

  3. Usage: im_out = normalize(img)

normalize(img=None)[source]
  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

  1. Input: segment image

  2. Output: normalized image segment

  3. Usage: im_out = normalize(img)

verticalize_segment(im_out=None, ipangle=None)[source]
  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

  1. Input: image, angle to be rotated

  2. Output: written rtstack file

  3. Usage: verticalize_segment(im_out, ipangle)

minimize_xposition(rowsaddimg=None, xshift=None)[source]
  • Function to center helix axis due to 2fold symmetry of projection

  1. Input: 1D helix projection

  2. Output: image shift required for centering perpendicular to helix axis

  3. Usage: centerx = minimize_xposition(rowsaddimg)

center_xycoordinates(xcoord=None, ycoord=None, centerx=None, ipangle=None)[source]
  • Function to apply shift perpedicular to helix to xy coordinates

  1. Input: x and y coordinates, x-shift (pixel), in-plane rotation angle

  2. Output: centered x and y coordinates

  3. Usage: newxcoord, newycoord = center_xycoordinates(xcoor, ycoord, centerx, ipangle)

>>> import numpy as np
>>> from spring.segment2d.segment import Segment
>>> # helix oriented along image columns
...
>>> s = Segment()
>>> x, y = s.center_xycoordinates(np.zeros(10), np.arange(10), 1, 0)
>>> x 
array([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.])
>>> y
array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
>>> # helix oriented along image rows
...
>>> x = np.arange(10)
>>> y = np.zeros(10)
>>> s_xcoord, s_ycoord = s.center_xycoordinates(x, y, 1, 90)
>>> s_xcoord
array([-6.123234e-17,  1.000000e+00,  2.000000e+00,  3.000000e+00,
        4.000000e+00,  5.000000e+00,  6.000000e+00,  7.000000e+00,
        8.000000e+00,  9.000000e+00])
>>> s_ycoord
array([-1., -1., -1., -1., -1., -1., -1., -1., -1., -1.])
>>> # helix oriented by 45 degrees
...
>>> y = x
>>> s_xcoord, s_ycoord = s.center_xycoordinates(x, y, 1, -45)
>>> s_xcoord
array([-0.70710678,  0.29289322,  1.29289322,  2.29289322,  3.29289322,
        4.29289322,  5.29289322,  6.29289322,  7.29289322,  8.29289322])
>>> s_ycoord
array([0.70710678, 1.70710678, 2.70710678, 3.70710678, 4.70710678,
       5.70710678, 6.70710678, 7.70710678, 8.70710678, 9.70710678])
>>> # helix oriented by -45 degrees
...
>>> s_xcoord, s_ycoord = s.center_xycoordinates(x, np.flipud(x), 1, 45)
>>> s_xcoord
array([-0.70710678,  0.29289322,  1.29289322,  2.29289322,  3.29289322,
        4.29289322,  5.29289322,  6.29289322,  7.29289322,  8.29289322])
>>> s_ycoord
array([ 8.29289322,  7.29289322,  6.29289322,  5.29289322,  4.29289322,
        3.29289322,  2.29289322,  1.29289322,  0.29289322, -0.70710678])
make_segment_info_named_tuple()[source]
pre_loop_setup()[source]
get_mic_slice_from_mrc_stack(micrograph_name)[source]
read_micrograph_and_get_ctf_info(micrograph_img, matched_mic_find, micrograph_name, session, each_helix)[source]
window_segment_and_invert_normalize_and_ctf_correct(session, large_segsizepix, each_helix, micrograph_img, matched_mic_find, xcoord, ycoord, ctf_info, each_image_index)[source]
rotate_and_unbend_segment_if_required(imgstack, each_image_index, large_segsizepix, each_helix, each_segment_index, coordpair, windowed_segment)[source]
get_ctfinfo_header()[source]
get_log_info_header()[source]
cut_segments(helices=None, imgstack=None)[source]
  • Function to cut segments from helices dictionary including micrograph information,

  1. Input: helix dictionary containing: micrograph, segment_list, directory, coordinates, in-plane angle; outfilestack

  2. Output: written stack

  3. Usage: cut_segments(helices, outfile)

compare_centered_coordinates_with_picked_coordinates_and_smooth_path(helices)[source]
class segment.SegmentDatabase(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

center_xycoordinates([xcoord, ycoord, …])

  • Function to apply shift perpedicular to helix to xy coordinates

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_new_micsize_if_coordinates_at_edges(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

cut_segments([helices, imgstack])

  • Function to cut segments from helices dictionary including micrograph information,

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

invert([img])

  • Function to invert segment image densities for cryo data (protein=white)

minimize_xposition([rowsaddimg, xshift])

  • Function to center helix axis due to 2fold symmetry of projection

normalize([img])

  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

verticalize_segment([im_out, ipangle])

  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

window_segment(micrograph, xcoord, ycoord, …)

  • Function to window segment from image part of cut_segments

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compare_centered_coordinates_with_picked_coordinates_and_smooth_path

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

copy_and_duplicate_refined_helix_entries_to_new_database

copy_and_duplicate_refined_segment_entries_to_new_database

copy_micrograph_info_on_ctffind_and_ctftilt

copy_refinement_info_into_new_refinement_database

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helix_info_into_segments_and_helix_tables

enter_helix_parameters_in_database

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

enter_parameters_into_helix_table

enter_parameters_into_segment_table

fill_in_helix_info_from_coordinates

fit_square_function_path_of_coordinates

get_ctfinfo_header

get_log_info_header

get_message_for_frame_missing

get_mic_slice_from_mrc_stack

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

make_segment_info_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

pre_loop_setup

prepare_segmentation

read_micrograph_and_get_ctf_info

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_all_previous_entries

remove_helices_segments_from_tables

rotate_and_unbend_segment_if_required

round_and_calculate_coordinate_in_Angstrom

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

window_segment_and_invert_normalize_and_ctf_correct

remove_all_previous_entries(session, column_name)[source]
enter_parameters_into_helix_table(session, each_helix, current_mic)[source]
round_and_calculate_coordinate_in_Angstrom(each_helix_coordinate, pixelsize)[source]
enter_parameters_into_segment_table(session, stack_id, each_helix, current_mic, helix, distances, lavg_inplane_angles, lavg_curvatures)[source]
enter_helix_info_into_segments_and_helix_tables(helices, session)[source]
copy_micrograph_info_on_ctffind_and_ctftilt(assigned_mics, source_session, new_session)[source]
copy_and_duplicate_refined_segment_entries_to_new_database(assigned_stack_ids, ref_source_session, new_ref_session)[source]
copy_and_duplicate_refined_helix_entries_to_new_database(assigned_helix_ids, ref_source_session, new_ref_session)[source]
copy_refinement_info_into_new_refinement_database(assigned_stack_ids, assigned_helix_ids)[source]
enter_helix_parameters_in_database(helices, assigned_stack_ids, assigned_helix_ids)[source]
class segment.Segment(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

binstack([imgstack, binned_imgstack, binfactor])

  • Function to bin image stack by factor

center_xycoordinates([xcoord, ycoord, …])

  • Function to apply shift perpedicular to helix to xy coordinates

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_new_micsize_if_coordinates_at_edges(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

cut_segments([helices, imgstack])

  • Function to cut segments from helices dictionary including micrograph information,

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

invert([img])

  • Function to invert segment image densities for cryo data (protein=white)

minimize_xposition([rowsaddimg, xshift])

  • Function to center helix axis due to 2fold symmetry of projection

normalize([img])

  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

verticalize_segment([im_out, ipangle])

  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

window_segment(micrograph, xcoord, ycoord, …)

  • Function to window segment from image part of cut_segments

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compare_centered_coordinates_with_picked_coordinates_and_smooth_path

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

copy_and_duplicate_refined_helix_entries_to_new_database

copy_and_duplicate_refined_segment_entries_to_new_database

copy_micrograph_info_on_ctffind_and_ctftilt

copy_refinement_info_into_new_refinement_database

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helix_info_into_segments_and_helix_tables

enter_helix_parameters_in_database

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

enter_parameters_into_helix_table

enter_parameters_into_segment_table

fill_in_helix_info_from_coordinates

fit_square_function_path_of_coordinates

get_ctfinfo_header

get_log_info_header

get_message_for_frame_missing

get_mic_slice_from_mrc_stack

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

make_segment_info_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

pre_loop_setup

prepare_segmentation

read_micrograph_and_get_ctf_info

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_all_previous_entries

remove_helices_segments_from_tables

rotate_and_unbend_segment_if_required

round_and_calculate_coordinate_in_Angstrom

segment

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

window_segment_and_invert_normalize_and_ctf_correct

binstack(imgstack=None, binned_imgstack=None, binfactor=None)[source]
  • Function to bin image stack by factor

  1. Input: image stack to be binned, bining factor (1 = no binning)

  2. Output: binned stack

  3. Usage: binnedimgstack = binstack(imgstack, binfactor)

segment()[source]
segment.main()[source]
class segment_mpi.SegmentMpiPreparation(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

binstack([imgstack, binned_imgstack, binfactor])

  • Function to bin image stack by factor

center_xycoordinates([xcoord, ycoord, …])

  • Function to apply shift perpedicular to helix to xy coordinates

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_new_micsize_if_coordinates_at_edges(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

cut_segments([helices, imgstack])

  • Function to cut segments from helices dictionary including micrograph information,

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

invert([img])

  • Function to invert segment image densities for cryo data (protein=white)

minimize_xposition([rowsaddimg, xshift])

  • Function to center helix axis due to 2fold symmetry of projection

normalize([img])

  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

verticalize_segment([im_out, ipangle])

  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

window_segment(micrograph, xcoord, ycoord, …)

  • Function to window segment from image part of cut_segments

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compare_centered_coordinates_with_picked_coordinates_and_smooth_path

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

copy_and_duplicate_refined_helix_entries_to_new_database

copy_and_duplicate_refined_segment_entries_to_new_database

copy_micrograph_info_on_ctffind_and_ctftilt

copy_refinement_info_into_new_refinement_database

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helix_info_into_segments_and_helix_tables

enter_helix_parameters_in_database

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

enter_parameters_into_helix_table

enter_parameters_into_segment_table

fill_in_helix_info_from_coordinates

fit_square_function_path_of_coordinates

get_ctfinfo_header

get_log_info_header

get_message_for_frame_missing

get_mic_slice_from_mrc_stack

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

make_segment_info_named_tuple

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

pre_loop_setup

prepare_segmentation

prepare_segmentation_mpi

read_micrograph_and_get_ctf_info

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_all_previous_entries

remove_helices_segments_from_tables

rotate_and_unbend_segment_if_required

round_and_calculate_coordinate_in_Angstrom

segment

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

window_segment_and_invert_normalize_and_ctf_correct

prepare_segmentation_mpi()[source]
class segment_mpi.SegmentMpi(parset=None)[source]

Methods

assign_ids_based_on_new_frames(…)

>>> from spring.segment2d.segment import Segment

assign_micrograph_segment_pairs(…)

  • Function to assign pairs of micrographs and segment files based on their common filenames

assign_reorganize(micrograph_files, …)

  • Function to match micrographs and corresponding segment file

binstack([imgstack, binned_imgstack, binfactor])

  • Function to bin image stack by factor

center_xycoordinates([xcoord, ycoord, …])

  • Function to apply shift perpedicular to helix to xy coordinates

check_whether_provided_frame_number_matches_provided_micrographs(…)

>>> from spring.segment2d.segment import Segment

check_whether_provided_frame_number_matches_provided_micrographs_old(…)

>>> from spring.segment2d.segment import Segment

compute_bending_path_row_wise(length, …)

>>> from spring.segment2d.segment import Segment

compute_cumulative_distances_from_start_of_helix(…)

>>> from spring.segment2d.segment import Segment

compute_new_micsize_if_coordinates_at_edges(…)

>>> from spring.segment2d.segment import Segment

compute_persistence_length_m_from_coordinates_A(…)

>>> from spring.segment2d.segment import Segment

compute_rotated_helix_path_on_segment_locally(…)

>>> from spring.segment2d.segment import Segment

convert_rotate_shift_to_shift_rotate_order(…)

>>> from spring.segment2d.segment import Segment

convert_shift_rotate_to_rotate_shift_order(…)

>>> from spring.segment2d.segment import Segment

create_link(micfile, overlapdir)

Function to create symbolic link in new directory

cut_segments([helices, imgstack])

  • Function to cut segments from helices dictionary including micrograph information,

determine_boxsize_closest_to_fast_values(…)

# Values taken from http://blake.bcm.edu/emanwiki/EMAN2/BoxSize >>> from spring.segment2d.segment import Segment >>> s = Segment() >>> s.determine_boxsize_closest_to_fast_values(333) 352 >>> s.determine_boxsize_closest_to_fast_values(333, ten=True) 360

interpolate_coordinates(xcoord, ycoord, …)

  • Function to interpolate x and y coordinates according to new stepsize

invert([img])

  • Function to invert segment image densities for cryo data (protein=white)

minimize_xposition([rowsaddimg, xshift])

  • Function to center helix axis due to 2fold symmetry of projection

normalize([img])

  • Function to normalize segment to image densities of average 0 and standard deviation of 1 and truncate dark spots

read_coordinate_lines_from_bsoft_filament_format_and_convert_to_eman_format(…)

>>> bsoft =  [ '_filament.z\n']

read_coordinate_lines_from_bsoft_particle_format_and_convert_to_eman_format(…)

>>> bsoft = [ '_particle.select\n']

read_coordinate_lines_from_eman_format_and_separate_helices(…)

>>> lines = ['50\t50\t100\t100\t-1\n', '40\t40\t100\t100\t0\n']

readmic(inputimg)

  • Function to load micrograph and define sizes

reorganize_micrographs_and_coordinate_files_into_separate_directories(pair)

  • Function to reorganize micrographs and coordinate files into separate directories micrograph and corresponding segment file into separate subdirectories using symbolic links

rotate_coordinates_by_angle(xcoord, ycoord, …)

  • Function to rotate coordinates clockwise by angle_in_deg around origin (in correspondence to EMAN2 convention)

select_coordinates_within_segment_dimensions(…)

>>> from spring.segment2d.segment import Segment

single_out(pair, stepsize, pixelsize, …)

  • Function to single out individual helices from entire micrograph, re-interpolates coordinates according to specified stepsize,

verticalize_segment([im_out, ipangle])

  • Function to align helix axis to perpendicular image rows, includes additional windowing to get rid of rotation artefacts at edges

window_segment(micrograph, xcoord, ycoord, …)

  • Function to window segment from image part of cut_segments

write_boxfile([interpolated_xcoord, …])

  • Function to write out new boxparameters

add_start_or_end_flag

adjust_gray_values_for_print_and_optimal_display

append_final_helix

check_whether_spring_db_entries_match_provided_micrographs

compare_centered_coordinates_with_picked_coordinates_and_smooth_path

compute_new_coordinates_with_given_stepsize

convert_coordinate_line_to_xy_coordinates

copy_and_duplicate_refined_helix_entries_to_new_database

copy_and_duplicate_refined_segment_entries_to_new_database

copy_micrograph_info_on_ctffind_and_ctftilt

copy_refinement_info_into_new_refinement_database

define_ctf_parameters

define_segment_or_window_parameters

determine_angle_to_rotate_coordinates_to_minimal_slope

enter_helix_info_into_segments_and_helix_tables

enter_helix_parameters_in_database

enter_helixinfo_into_helices

enter_helixinfo_into_helices_and_write_boxfiles

enter_parameters_into_helix_table

enter_parameters_into_segment_table

extract_segments_mpi

fill_in_helix_info_from_coordinates

finish_segmentation_mpi

fit_square_function_path_of_coordinates

gather_distributed_helices_to_root

get_ctfinfo_header

get_log_info_header

get_message_for_frame_missing

get_mic_slice_from_mrc_stack

get_picked_coordinates_from_database

get_picked_coordinates_from_file

get_statistics_from_image

get_strip_frame

make_helixinfo_named_tuple

make_segment_info_named_tuple

perform_binning_if_demanded

perform_helix_based_segment_selection_incl_segment_helix_removal_from_springdb

perform_interpolation_derivative_for_in_plane_angle_rotation

perform_interpolation_of_ycoordinates

perform_interpolation_perturbation_removal_if_required

pre_loop_setup

prepare_segmentation

prepare_segmentation_mpi

read_micrograph_and_get_ctf_info

recalculate_xcoordinate_stepsize_to_perform_interpolation

remove_all_previous_entries

remove_helices_segments_from_tables

rotate_and_unbend_segment_if_required

round_and_calculate_coordinate_in_Angstrom

segment

set_polyfit_variable

shift_and_rotate_image

shift_and_rotate_image_linear

straighten_segment

unbend_segment_using_coordinates

validate_input

window_segment_and_invert_normalize_and_ctf_correct

gather_distributed_helices_to_root(comm, helices)[source]
extract_segments_mpi(tempdir)[source]
perform_binning_if_demanded(imgstack, local_windowed_stack)[source]
finish_segmentation_mpi(tempdir, imgstack, local_windowed_stack, assigned_stack_ids, assigned_helix_ids)[source]
segment()[source]
segment_mpi.main()[source]