polyTEM.crystal_peaks.crystal_stack_3D.CrystalStack3D¶
- class polyTEM.crystal_peaks.crystal_stack_3D.CrystalStack3D(stack_list, tilt_angles, domain_collections, auto_populate=True, orient_perpendicular=False)¶
Bases:
objectAssumptions: * the sample datacube parameters were used to generate each of the crystal stacks. Thus, the resolution and shape is the same.
- Variables:
stack_list – list of crystal stacks
tilt_angles – list of tilt angles corresponding to each stack in stack_list
domain_collections – list of DomainCollections correspond to each stack in stack_list
shape – (x,y) shape
resolution – resolution of tilt stack (afer sliding fft)
vector_field – each row is from one fft peak and contains (x,y,a,b,c) for vector field direction
threshold_func – function for peak finding
Ks (Kb,) – Frank Elastic Constants in Angstroms
- __init__(stack_list, tilt_angles, domain_collections, auto_populate=True, orient_perpendicular=False)¶
Methods
__init__(stack_list, tilt_angles, ...[, ...])adjacency_probability_matrix(savedir[, ...])saves the adjacency probabilities in the directory 'savedir' with the format {savedir}/node{##}.npz, where ## is the starting row index for that submatrix.
align_vector_field(window_size, step_size, ...)Shifts the (x,y) coordinates in the vector field based on the marker alignment results and convert to (u,v) where u = x/cos(alpha) and v=y
apply_threshold_func([threshold_func])Sets the threshold function of every stack in the stack list
build_vector_graph(file_dir, node_range)Build vector graph representation from adjacency probability matrix.
create_vector_field([rotate90_orientation])Creates vector field (x,y,alpha,a,b,c), where x is the x-axis of the image (across the columns of the data) y is the y-axis of the image (across the rows of the data) alpha is the tilt angle a,b,c represents the unit vector field of chain orientation, centered at (x,y)
estimate_bending_stiffness([flip])Estimates the bending stiffness by calculating the orientation correlation length Under the Worm-Like-Chain model, the orientation correlation length == bending stiffness
find_peak_threshold(alpha[, inverse])Use the fft intensities for high tilt angles to estimate noise floor to set threshold function for fft peak finding of lower tilt angles
save(savedir[, prefix])Saves the stacks based on their individual outdirs, with the prefix inserted in front of crystalstack.pkl Saves the tilt angles at savedir, tilt_angles.json Saves the vector field at savedir, vector_field.json
- adjacency_probability_matrix(savedir, resolution=1.15, max_distance_pxl=32, alpha_cutoff=70, threads=8, node_group_size=100, model='nematic', **kwargs)¶
saves the adjacency probabilities in the directory ‘savedir’ with the format {savedir}/node{##}.npz, where ## is the starting row index for that submatrix. :param savedir: Directory to save adjacency probability sub-matrices :type savedir: str :param Resolution: original imaging resolution of raw TEM image :param max_distance: int, pixel limit to build possible connections :param alpha_cutoff: int, tilt angle cutoff to build possible connections :param threads: int, for multiprocessing :param node_group_size: int, to segment nodes for multiprocessing :param model: “single-chain” or “nematic” :param **kwargs: keyword-argument parameters for bending probability function :param –: :param Lp: float, A, persistence length for “single-chain” model :param Kb: Frank Elastic Constants for nematic, dimensionless :param Ks: Frank Elastic Constants for nematic, dimensionless
- align_vector_field(window_size, step_size, alignment_result, alignment_indices, origin_shift=None)¶
Shifts the (x,y) coordinates in the vector field based on the marker alignment results and convert to (u,v) where u = x/cos(alpha) and v=y
this returns a vector field where (u,v) has the pixel resolution of the original image, before downsampling with the sliding fft
- Parameters:
window_size – int, parameter used during sliding fft scan
step_size – int, parameter used during sliding fft scan
alignment_result – AlignmentResult object
alignment_indices – the image index in AlignmentResult that corresponds to the images used to create the CrystalStack3D
origin_shift – any origin shift applied during alignment
- Returns:
vector field containing (u,v,alpha,a,b,c) of each fft peak feature
- apply_threshold_func(threshold_func=None)¶
Sets the threshold function of every stack in the stack list
- Parameters:
threshold_func – default None, uses self.threshold_func, otherwise input argument will override
- build_vector_graph(file_dir, node_range)¶
Build vector graph representation from adjacency probability matrix.
The Adjacency Probability Matrix is stored in the format {prob_dir}/node{##}.npz where the ## is the start index of the first node in that numpy array. The graph is built by iterating through the probabilities in {prob_dir}/node{start_index) for start_index in node_range
- Parameters:
file_dir (str) – Directory
node_range (range) – the set of starting indexes for all of the .npz files to iterate through e.g. np.arange(0,total_nodes,node_group_size) where node_group_size was set in CrystalStack3D.adjacency_probability_matrix()
- Returns:
networkx graph
- create_vector_field(rotate90_orientation=False)¶
Creates vector field (x,y,alpha,a,b,c), where x is the x-axis of the image (across the columns of the data)
y is the y-axis of the image (across the rows of the data) alpha is the tilt angle a,b,c represents the unit vector field of chain orientation, centered at (x,y)
- estimate_bending_stiffness(flip=False)¶
Estimates the bending stiffness by calculating the orientation correlation length Under the Worm-Like-Chain model, the orientation correlation length == bending stiffness
- Parameters:
flip – bool, swaps perpendicular and parallel orientations. i.e. set True if director orientation was obtained as “lamellar” but was actually “backbone”
- Returns:
average orientation correlation length stderr: standard error of the mean of Ld
- Return type:
Ld
- find_peak_threshold(alpha, inverse=False)¶
Use the fft intensities for high tilt angles to estimate noise floor to set threshold function for fft peak finding of lower tilt angles
- Parameters:
alpha – the angle cutoff to divide the tilt angles
inverse – default False, selects tilt angles greater than alpha. if True, selects tilt angles smaller.
- Returns:
lambda function
- Return type:
threshold_func
- save(savedir, prefix='')¶
Saves the stacks based on their individual outdirs, with the prefix inserted in front of crystalstack.pkl Saves the tilt angles at savedir, tilt_angles.json Saves the vector field at savedir, vector_field.json