Documented functions with links to source

Program to split large scan into individual micrographs. The location of individual micrographs is determined by a dummy micrograph reference.

class scansplit.Micrograph[source]

Methods

readmic(inputimg)

  • Function to load micrograph and define sizes

adjust_gray_values_for_print_and_optimal_display

get_statistics_from_image

readmic(inputimg)[source]
  • Function to load micrograph and define sizes

  1. Usage: img, nx, ny = readmic(inputimg)

  2. Input: inputimg

  3. Output: image, x and y dimension

get_statistics_from_image(image, mask=None)[source]
adjust_gray_values_for_print_and_optimal_display(mic)[source]
class scansplit.ScanSplitPar[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_cc_threshold

set_contact_print_option

set_final_print_option

set_label_width_and_height

set_mic_crop_count

set_mic_out_pattern

set_mic_width_and_height

set_normscan_option

set_rows_and_cols_count

define_parameters_and_their_properties()[source]
define_program_states()[source]
set_mic_out_pattern(feature_set)[source]
set_rows_and_cols_count(feature_set)[source]
set_mic_crop_count(feature_set)[source]
set_mic_width_and_height(feature_set)[source]
set_label_width_and_height(feature_set)[source]
set_cc_threshold(feature_set)[source]
set_contact_print_option(feature_set)[source]
set_final_print_option(feature_set)[source]
set_normscan_option(feature_set)[source]
class scansplit.ScanSplitRough(parset=None)[source]
  • Class that holds all functions required for splitting micrographs

  • __init__ Function to read in the entered parameter dictionary, load micrograph and initialize unique temporary directory

  1. Usage: ScanSplit(pardict)

  2. Input: pardict = OrderedDict of program parameters

Methods

roughsplit(scanimg, row_count, column_count, …)

  • Function to roughly split scan into micrographs based on given number of rows and columns

roughsplit(scanimg, row_count, column_count, no_mics)[source]
  • Function to roughly split scan into micrographs based on given number of rows and columns

  1. Usage: roughsplit(row_count, column_count, mic_count)

  2. Input: number of rows, number of columns, number of micrographs,

  3. Output: dictionary of roughly windowed micrographs (EMData objects)

>>> from spring.micprgs.scansplit import ScanSplit
>>> import numpy as np
>>> from EMAN2 import EMNumPy
>>> scanimg = EMNumPy.numpy2em(np.reshape(np.arange(0., 100.), (20, 5)))
>>> mic_one, decfactor = ScanSplit().roughsplit(scanimg, 2, 1, 2)
>>> np.rint(EMNumPy.em2numpy(mic_one[0]))
array([[ 0.,  1.,  2.,  3.,  4.],
       [ 5.,  6.,  7.,  8.,  9.],
       [10., 11., 12., 13., 14.],
       [15., 16., 17., 18., 19.],
       [20., 21., 22., 23., 24.],
       [25., 26., 27., 28., 29.],
       [30., 31., 32., 33., 34.],
       [35., 36., 37., 38., 39.],
       [40., 41., 42., 43., 44.],
       [45., 46., 47., 48., 49.]], dtype=float32)
>>> scanimg = EMNumPy.numpy2em(np.reshape(np.arange(0., 100.), (10, 10)))
>>> mic_one, decfactor = ScanSplit().roughsplit(scanimg, 1, 2, 2)
>>> np.rint(EMNumPy.em2numpy(mic_one[0]))
array([[ 0.,  1.,  2.,  3.,  4.],
       [10., 11., 12., 13., 14.],
       [20., 21., 22., 23., 24.],
       [30., 31., 32., 33., 34.],
       [40., 41., 42., 43., 44.],
       [50., 51., 52., 53., 54.],
       [60., 61., 62., 63., 64.],
       [70., 71., 72., 73., 74.],
       [80., 81., 82., 83., 84.],
       [90., 91., 92., 93., 94.]], dtype=float32)
class scansplit.ScanSplitFind(parset=None)[source]

Methods

adjust_refmic(refmic, miclist)

  • Function to adjust size of reference microgrph to the size of rough split

findlabel(miclist, decimation_factor_find, …)

  • Function to locate micrograph position using cross-correlation map with reference micrograph

make_refmic([mwidth, mheight, lwidth, …])

  • Function to generate a reference micrograph including black label at bottom with the given dimensions

roughsplit(scanimg, row_count, column_count, …)

  • Function to roughly split scan into micrographs based on given number of rows and columns

determine_micrograph_offset_against_reference_micrograph

make_refmic(mwidth=None, mheight=None, lwidth=None, lheight=None, scanstep=None)[source]
  • Function to generate a reference micrograph including black label at bottom with the given dimensions

  1. Usage: make_refmic(mwidth, mheight, lwidth, lheight, scanstep)

  2. Input: micrograph widht, micrograph height, label width, label height, scanner stepsize

  3. Output: reference micrograph

>>> from spring.micprgs.scansplit import ScanSplit
>>> refmic = ScanSplit().make_refmic(9, 10, 3, 2, 10000)
>>> import numpy as np
>>> from EMAN2 import EMNumPy
>>> np.rint(EMNumPy.em2numpy(refmic))
array([[1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1., 1., 1., 1., 1.],
       [1., 1., 1., 0., 0., 0., 1., 1., 1.],
       [1., 1., 1., 0., 0., 0., 1., 1., 1.]], dtype=float32)
adjust_refmic(refmic, miclist)[source]
  • Function to adjust size of reference microgrph to the size of rough split

determine_micrograph_offset_against_reference_micrograph(refmic_with_label_top, refmic_with_label_bottom, micrograph)[source]
findlabel(miclist, decimation_factor_find, scanstep)[source]
  • Function to locate micrograph position using cross-correlation map with reference micrograph

  1. Usage: findlabel(refmic, miclist)

  2. Input: stack of roughly split micrographs, reference micrograph, number of micrographs, dictionary that holds micrograph objects, number of micrographs

  3. Output: Position of X-offset and Y-offset and cross-correlation peak value of match

class scansplit.ScanSplitOptions(parset=None)[source]

Methods

adjust_refmic(refmic, miclist)

  • Function to adjust size of reference microgrph to the size of rough split

assign_edge_value_to_edge_columns(…)

>>> ScanSplit().assign_edge_value_to_edge_columns(2, 100)

bin_micrographs(miclist, binfactor)

  • Function to bin series of micrographs by binfactor

contactprint(scanimg, infile)

  • Function to generate a contact print of the negative scan

finalprint(miclist)

  • Function to generate final prints of the cropped micrographs

findlabel(miclist, decimation_factor_find, …)

  • Function to locate micrograph position using cross-correlation map with reference micrograph

make_refmic([mwidth, mheight, lwidth, …])

  • Function to generate a reference micrograph including black label at bottom with the given dimensions

normalize_columns(micrograph)

determine number of columns pull out each column normalize

normscan(miclist)

  • Function to normalize micrograph columns from Zeiss scans

prepare_print(img, infile, outfile[, fig_number])

  • Function to write print

roughsplit(scanimg, row_count, column_count, …)

  • Function to roughly split scan into micrographs based on given number of rows and columns

determine_micrograph_offset_against_reference_micrograph

assign_edge_value_to_edge_columns(column_number, column_count)[source]
>>> ScanSplit().assign_edge_value_to_edge_columns(2, 100)
6
>>> ScanSplit().assign_edge_value_to_edge_columns(66, 100)
66
>>> ScanSplit().assign_edge_value_to_edge_columns(95, 100)
94
normalize_columns(micrograph)[source]

determine number of columns pull out each column normalize

normscan(miclist)[source]
  • Function to normalize micrograph columns from Zeiss scans

  1. Usage: normscan(normscanpath, miclist)

  2. Input: list of micrographs

  3. Output: Series of normalized micrographs, list of normalized micrograph filenames

contactprint(scanimg, infile)[source]
  • Function to generate a contact print of the negative scan

  1. Usage: contactprint(scanimg, infile)

  2. Input: micrograph EMData object, input filename

  3. Output: compressed contact print ( file)

prepare_print(img, infile, outfile, fig_number=None)[source]
  • Function to write print

  1. Usage: fig = prepare_print(img, infile, outfile, fig_number)

  2. Input: image to be printed, input filename, outputfilename, figure number

  3. Output: figure to be saved

finalprint(miclist)[source]
  • Function to generate final prints of the cropped micrographs

  1. Usage: finalprint(miclist, scanstep, tempdir)

  2. Input: list of micrographs, scanner stepsize, temporary directory

  3. Output: series of final prints (compressed JPG file)

bin_micrographs(miclist, binfactor)[source]
  • Function to bin series of micrographs by binfactor

  1. Usage: bin_micrographs(miclist, binfactor)

  2. Input: list of micrograph names, binfactor (1x = nobinning)

  3. Output: micrograph names will be appended by -binfactorxbinned.ext

class scansplit.ScanSplit(parset=None)[source]

Methods

adjust_refmic(refmic, miclist)

  • Function to adjust size of reference microgrph to the size of rough split

assign_edge_value_to_edge_columns(…)

>>> ScanSplit().assign_edge_value_to_edge_columns(2, 100)

bin_micrographs(miclist, binfactor)

  • Function to bin series of micrographs by binfactor

check_and_adjust_windowing_paramters(…)

  • Function to adjust windowing parameter in case of incompletely scanned micrographs

contactprint(scanimg, infile)

  • Function to generate a contact print of the negative scan

finalprint(miclist)

  • Function to generate final prints of the cropped micrographs

findlabel(miclist, decimation_factor_find, …)

  • Function to locate micrograph position using cross-correlation map with reference micrograph

finesplit(row_count, column_count, mwidth, …)

  • Function to finely split scan into micrographs according to found micrograph location

make_refmic([mwidth, mheight, lwidth, …])

  • Function to generate a reference micrograph including black label at bottom with the given dimensions

normalize_columns(micrograph)

determine number of columns pull out each column normalize

normscan(miclist)

  • Function to normalize micrograph columns from Zeiss scans

prepare_print(img, infile, outfile[, fig_number])

  • Function to write print

roughsplit(scanimg, row_count, column_count, …)

  • Function to roughly split scan into micrographs based on given number of rows and columns

split_output_string(outfile)

>>> ScanSplit().split_output_string('test_???.mrc')

compute_micrograph_center_in_scan

determine_micrograph_offset_against_reference_micrograph

perform_splitscan

perform_splitscan_by_finding_location_with_respect_to_reference_micrograph

split_output_string(outfile)[source]
>>> ScanSplit().split_output_string('test_???.mrc')
['test_', '.mrc']
>>> ScanSplit().split_output_string('test_??.mrc')
['test_', '.mrc']
>>> ScanSplit().split_output_string('test_?.mrc')
['test_', '.mrc']
>>> ScanSplit().split_output_string('test_*.mrc')
['test_', '.mrc']
>>> ScanSplit().split_output_string('test_%02d.mrc')
['test_', '.mrc']
compute_micrograph_center_in_scan(col_row_number, col_row_count, size, offset, mic_number)[source]
check_and_adjust_windowing_paramters(scan_dimension, mic_dimension, center)[source]
  • Function to adjust windowing parameter in case of incompletely scanned micrographs

>>> ScanSplit().check_and_adjust_windowing_paramters((1500, 1000), (500, 500), (300, 300))
(500, 450, 300, 275)
>>> ScanSplit().check_and_adjust_windowing_paramters((1000, 1000), (500, 500), (300, 300))
(450, 450, 275, 275)
>>> ScanSplit().check_and_adjust_windowing_paramters((1500, 1500), (500, 500), (300, 300))
(500, 500, 300, 300)
finesplit(row_count, column_count, mwidth, mheight, scanstep, xoffset, yoffset, ccpeaks, cc_threshold, outfile)[source]
  • Function to finely split scan into micrographs according to found micrograph location

  1. Usage: finesplit(row_count, column_count, mwidth, mheight, scanstep, xoffset, yoffset, ccpeaks, cc_threshold, outfile)

  2. Input: number of rows, number of colums, number of micrographs, micrograph width, micrograph height, scanner stepsize, X-offset center, Y-offset center, list of cross-correlation peaks, cross-correlation threshold

  3. Output: series of cropped micrographs

perform_splitscan_by_finding_location_with_respect_to_reference_micrograph(micrograph_files, outfiles)[source]
perform_splitscan()[source]
scansplit.main()[source]
class scansplit_mpi.ScanSplitMpi(parset=None)[source]

Methods

adjust_refmic(refmic, miclist)

  • Function to adjust size of reference microgrph to the size of rough split

assign_edge_value_to_edge_columns(…)

>>> ScanSplit().assign_edge_value_to_edge_columns(2, 100)

bin_micrographs(miclist, binfactor)

  • Function to bin series of micrographs by binfactor

check_and_adjust_windowing_paramters(…)

  • Function to adjust windowing parameter in case of incompletely scanned micrographs

contactprint(scanimg, infile)

  • Function to generate a contact print of the negative scan

finalprint(miclist)

  • Function to generate final prints of the cropped micrographs

findlabel(miclist, decimation_factor_find, …)

  • Function to locate micrograph position using cross-correlation map with reference micrograph

finesplit(row_count, column_count, mwidth, …)

  • Function to finely split scan into micrographs according to found micrograph location

make_refmic([mwidth, mheight, lwidth, …])

  • Function to generate a reference micrograph including black label at bottom with the given dimensions

normalize_columns(micrograph)

determine number of columns pull out each column normalize

normscan(miclist)

  • Function to normalize micrograph columns from Zeiss scans

prepare_print(img, infile, outfile[, fig_number])

  • Function to write print

roughsplit(scanimg, row_count, column_count, …)

  • Function to roughly split scan into micrographs based on given number of rows and columns

split_output_string(outfile)

>>> ScanSplit().split_output_string('test_???.mrc')

compute_micrograph_center_in_scan

determine_micrograph_offset_against_reference_micrograph

end_scan_mpi_programs

perform_splitscan

perform_splitscan_by_finding_location_with_respect_to_reference_micrograph

startup_scan_mpi_programs

perform_splitscan()[source]
scansplit_mpi.main()[source]