TIE_params module¶
Class for TIE reconstruction parameters.
A class for holding TIE images and reconstruction parameters. Also has several methods relating to doing the reconstruction, namely making masks and interactively cropping the image stacks.
AUTHOR: Arthur McCray, ANL, Summer 2019
-
class
TIE_params.TIE_params(imstack=None, flipstack=[], defvals=None, flip=None, data_loc=None, no_mask=False, v=1)[source]¶ Bases:
objectAn object for holding the data and parameters for the reconstruction.
Some params will be obtained directly from the metadata, others given by the user. Also holds some other useful values. An instance is created by the load_data() function in TIE_helper.py.
For more information on how to organize the directory and load the data, as well as how to setup the .fls file please refer to the README or the TIE_template.ipynb notebook.
-
imstack¶ A list of hyperspy Signal2D objects, one per image in the through focus series (tfs).
Type: list
-
flipstack¶ A list of hyperspy Signal2D objects for the flip tfs if there is one.
Type: list
-
defvals¶ List of defocus values in nm from least to most defocus. This assumes a symmetric defocus over/under, so expects 2 values for a 5 image tfs.
Type: list
-
flip¶ Boolean for whether or not to reconstruct using the flip stack. Even if the flip stack exists the reconstruction will only use the unflip stack if self.flip = False.
Type: bool
-
data_loc¶ String for location of data folder.
Type: str
-
no_mask¶ Eliminates mask (generally used with simulated data).
Type: bool
-
num_files¶ Equiv to len(self.imstack)
Type: int
-
axes¶ Hyperspy axes_manager from unflip infocus image. Contains useful information such as scale if loaded from dm3.
Type: hyperspy.signal2D.axes_manager
-
shape¶ Shape of original image data (y, x)
Type: tuple
-
scale¶ Scale of images (nm/pixel). Taken from the dm3 metadata or set with the
set_scale()method.Type: float
-
rotation¶ The rotation to apply to the image before reconstruction in deg.
Type: float, int
-
x_transl¶ The x_translation to apply to the image before reconstruction in pix.
Type: int
-
y_transl¶ The y_translation to apply to the image before reconstruction in pix.
Type: int
-
infocus¶ Averaged infocus image between unflip and flip stacks. If no flip stack, just unflip infocus image.
Type: 2D array
-
qi¶ 2D inverse frequency array, possibly modified with Tikhonov filter.
Type: 2D array
-
roi¶ hyperspy region-of-interest object. Initialized to central quarter of image, but changes interactively with self.select_region() method. Values for the roi are in nm, and continue to change as the interactive region is adjusted.
Type: hyperspy.roi.RectangularROI
-
crop¶ Region of interest in pixels used to select the are to be reconstructed. self.roi is converted from nm to pixels with the self.crop_ims() method, and does not change as the roi is adjusted. Initialized to full image.
Type: tuple
-
mask¶ Binary mask made form all the images. 1 where all images have nonzero data, 0 where any do not. Made by self.make_mask()
Type: 2D array
-
crop_ims()[source]¶ Sets self.crop in pixels as region to be reconstructed.
Converts self.roi (in units of nm) to pixels and asks for user input if this an acceptable shape.
Input options:
- “y”: sets self.crop
- “n”: does not set self.crop
- “reset”: sets self.crop to be full image size. (This is the default initialized value.)
Crops the full dm3 + flip_dm3 stack to the specified shape as defined by roi (hyperspy region of interest). Adjusts other axes accordingly.
-
make_mask(imstack=None, threshold=0)[source]¶ Sets self.mask to be a binary bounding mask from imstack and flipstack.
Makes all images binary using a threshold value, and then multiplies these arrays. Can also take a stack of images that aren’t signal2D.
The inverse Laplacian reconstruction does not deal well with a mask that is all ones, that is accounted for in TIE() function rather than here.
Parameters: - imstack (list) – (optional) List of arrays or Signal2D objects from which to make mask Default will use self.imstack and self.flipstack
- threshold (float) – (optional) Pixel value with which to threshold the images. Default is 0.
Returns: None. Assigns result to self.mask()
-
pre_Lap(pscope, def_step=1)[source]¶ Scaling prefactor used in the TIE reconstruction.
Parameters: - pscope (
Microscopeobject) – Microscope object from microscopes.py - def_step (float) – The defocus value for which is being reconstructed. If using a longitudinal derivative, def_step should be 1.
Returns: Numerical prefactor
Return type: float
- pscope (
-
select_region(infocus=True)[source]¶ Interactively crop imstack to smaller size.
This method sets self.roi to be the region (square or otherwise) as selected by the user. Default is central quarter of image.
Parameters: infocus (bool) – If True, will display the infocus image for selecting a sub-region. If False, will display a defocused image this is useful for datasets which have no in-focus contrast). Returns: None
-