fibsem package¶
Subpackages¶
Submodules¶
fibsem.autoscript module¶
-
fibsem.autoscript.create_milling_patterns(microscope, roi_coordinates, settings)[source]¶ Creates Autoscript milling patterns from a list of coordinates.
Parameters: - microscope (Autoscript microscope object.) –
- roi_coordinates (list of lists) – [center_x, center_y, roi_width, roi_height, depth, theta]
- settings (dict) – User input settings from config yml file.
Returns: List containing the Autoscript milling patterns.
Return type: patterns
fibsem.conversions module¶
fibsem.display module¶
-
fibsem.display.draw_crosshairs(image, major_axis, minor_axis, line_color=['red', 'blue'])[source]¶ Display plot of image with major axis overlaid.
Parameters: - image (2D umpy image array.) –
- major_axis (major axis of sample segmentation.) – Coordinates are in row, column format.
- minor_axis (minor axis of sample segmentation.) – Coordinates are in row, column format.
- line_color (optional. List of colors for each axis (major and minor)) –
Returns: Matplotlib figure and axis objects.
Return type: fig, ax
-
fibsem.display.draw_milling_axes(image, major_axis, start_lamella, end_lamella, line_colors=['yellow', 'orange'])[source]¶ Display plot of image with head to tail & tail to head axis overlaid.
Parameters: - image (Adorned image or 2D umpy image array.) –
- major_axis (major axis of sample segmentation.) – Coordinates are in row, column format.
- start_lamella (float) – Distance lamella should begin from head, as a fractional percentage of the whole sample length.
- end_lamella (float) – Distance lamella should end from head, as a fractional percentage of the whole sample length.
- line_colors (list, optional) – Coulors to display milling axes (the default is [‘yellow’, ‘orange’]).
Returns: Matplotlib figure and axis objects.
Return type: fig, ax
-
fibsem.display.draw_object_axes(image, axis_coord_list, line_color='red')[source]¶ Display plot of image with major axis overlaid.
Parameters: - image (2D umpy image array.) –
- axis_coords (major axis of sample segmentation.) – Coordinates are in row, column format.
- line_color (optional. Color of matplotlib line patch.) –
Returns: Matplotlib figure and axis objects.
Return type: fig, ax
-
fibsem.display.draw_rotated_rects(rectangle_coords, image=None, show_center=True)[source]¶ Display rectangle ROIs using matplotlib.
Parameters: - rectangle_coords (list.) – List contains [center_x, center_y, width, height, depth, angle] The input angle is in radians. center_x, center_y, width, and height are in meters. depth is ignored (not needed by matplotlib).
- image (AdornedImage, optional.) – Image to display, including pixel size metadata. (the default is None, which means no background image)
- show_center (bool, optional) – Plot centerpoints of rectangles (the default is False, which means centerpoints are not displayed)
Returns: Matplotlib figure and axis objects.
Return type: fig, ax
fibsem.main module¶
fibsem.milling module¶
FIB-SEM semi-aautomated creation of ion beam milling patterns.
-
fibsem.milling.all_roi_coordinates(sample, settings)[source]¶ “Calculate all coordinates for rectangle milling patterns.
Parameters: - sample (Embryo sample object.) –
- settings (dict) – User input arguments from config yml file.
Returns: List of all ROI coordinates.
Return type: all_roi_coords
-
fibsem.milling.mill_all_samples(samples, microscope, settings, display_matplotlib=False)[source]¶ Ion beam milling for all samples in list.
Parameters: - samples (list) – List of sample objects for ion beam milling.
- microscope (autoscript_sdb_microscope_client.SdbMicroscopeClient()) – Autoscript microscope client.
- settings (dict) – User input arguments from config yml file.
-
fibsem.milling.mill_single_sample(sample, microscope, settings, wait_for_user=False)[source]¶ Ion beam milling a single sample.
Parameters: - sample (fibsem.sample.Sample()) – Sample object for ion beam milling.
- microscope (autoscript_sdb_microscope_client.SdbMicroscopeClient()) – Autoscript microscope client.
- settings (dict) – User input settings from config yml file.
- wait_for_user (bool, optional) – Ask the user to confirm (the default is False, which cancels milling).
Returns: The ion beam image of the sample after milling is finished.
Return type: milled_image
fibsem.mocktypes module¶
-
class
fibsem.mocktypes.MockAdornedImage(image, pixelsize_x=None, pixelsize_y=None)[source]¶ Bases:
objectAdornedImage mock object, with attributes for data and pixel size.
-
image_data¶ numpy array – Equivalent to image.data on a real AdornedImage type.
-
pixelsize_x¶ float, optional. – Pixel size in x dimension, in meters.
-
pixelsize_y¶ float, optional. – Pixel size in y dimension, in meters.
-
-
class
fibsem.mocktypes.MockPixelSize(x=None, y=None)[source]¶ Bases:
objectPixel size mock object, has attributes x and y.
Parameters: - x (float, optional.) – Pixel size in x dimension, in meters.
- y (float, optional.) – Pixel size in y dimension, in meters.
-
fibsem.mocktypes.mock_user_settings()[source]¶ Mock user input settings.
Returns: settings – - Settings dictionary has the ksys:
- start_lamella : float
- Where the lamella starts, as percentage of length from head.’
- end_lamella : float
- Where the lamella ends, as percentage of length from head.’
- roi_width : float
- Width of ROI milling regions, in meters.
- roi_overlap : float
- Overlap of milling rectangles, in meters.
- ion_beam_overlap : float
- Overlap of the ion beam itself, as percentage.
- depth : float
- Depth of ion beam milling, in meters.
- current_for_milling : float
- Ion beam current for milling, in Amperes.
- current_for_imaging : float
- Ion beam current for imaging, in Amperes.
Return type: dict
fibsem.orientation module¶
-
fibsem.orientation.centroid(mask_image)[source]¶ Centroid coordinate of a masked object region.
Parameters: mask_image (array of bool) – The image containing the object. Pixels with value True are considered part of the object. Returns: Centroid pixel coordinates in row, column format. Origin at top left. Return type: centroid
-
fibsem.orientation.line_length(axis_coords)[source]¶ Length in pixels of line connecting two points.
Parameters: pt2 (pt1,) – Coordinates are in row, column format. Returns: np.hypot(p1, p2) Return type: line length in units of pixels
-
fibsem.orientation.major_minor_axes_pixels(mask_image)[source]¶ Major and minor axes for object in mask image, in pixel coordinates.
Each axis contains two coordinates, the start and end of the axis line at the outer edges of the object border. Coordinates are in row, column format.
Parameters: mask_image (array of bool) – The image containing the object. Pixels with value True are considered part of the object. Returns: major_axis, minor_axis – Start and end coordinates where axis intersects with the object edge. Coordinates are in row, column format, units are pixels. Return type: tuple of numpy arrays
-
fibsem.orientation.major_minor_axes_realspace(mask_image, pixelsize, reference_coord=None)[source]¶ Major and minor axes for object in mask image, real space coordinates.
Parameters: - mask_image (array of bool) – The image containing the object. Pixels with value True are considered part of the object.
- pixelsize (Pixel size object, with attributes x and y. Units of meters.) –
Returns: Start and end coordinates where axis intersects with the object edge. Units are in meters, zero coord is at the center of the field of view. Coordinates are in row, column format.
Return type: major_axis, minor_axis
-
fibsem.orientation.multi_axis(label_image)[source]¶ Like
major_minor_axes(), but does so for each label in an image.Parameters: label_image (array of int) – The image containing one integer label per object. Returns: lines – A dictionary mapping labels (int) to start and end points for the longest axis line. Coordinates are in row, column format. Return type: dict of tuple of tuple of int
-
fibsem.orientation.rotation_angle(axis_coords)[source]¶ Find the rotation angle for Autoscript.
Autoscript requires: Positive direction is clockwise, value in radians.
Parameters: axis_coords (Start and end coordinates of axis.) – Coordinates are in row, column format. Returns: theta Return type: in radians, positive direction is clockwise.
fibsem.sample module¶
-
class
fibsem.sample.Embryo(microscope=None)[source]¶ Bases:
fibsem.sample.SampleClass for FIB-SEM embryos.