fibsem package

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.autoscript.initialize(ip_address='10.0.0.1')[source]

Initialize connection to microscope.

fibsem.autoscript.patterning_engine(microscope)[source]

Start Autoscript toolkit patterning engine.

fibsem.autoscript.reset_patterning_state(microscope)[source]

Reset patterning state

fibsem.conversions module

fibsem.conversions.meters_to_pixels(amount, pixel_size)[source]

Convert meters to pizels.

fibsem.conversions.pixels_to_meters(amount, pixel_size)[source]

Convert pixel size to meters.

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.display.quick_plot(image)[source]

Display image with matplotlib.pyplot

Parameters:image (Adorned image or numpy array) – Input image.
Returns:Matplotlib figure and axis objects.
Return type:fig, ax

fibsem.main module

fibsem.main.run_milling(host='10.0.0.1', config='/home/docs/checkouts/readthedocs.org/user_builds/fibsem/checkouts/latest/fibsem/../config_default.yml')[source]

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: object

AdornedImage 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.

set_imagedata(image)[source]
set_pixelsize(x, y)[source]
class fibsem.mocktypes.MockBinaryResult[source]

Bases: object

Mock binary_result subclass.

class fibsem.mocktypes.MockMetadata[source]

Bases: object

Mock metadata subclass.

class fibsem.mocktypes.MockPixelSize(x=None, y=None)[source]

Bases: object

Pixel 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.
set_pixelsize(x, y)[source]
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.Sample

Class for FIB-SEM embryos.

display_crosshairs()[source]
display_milling_axes()[source]
display_milling_rois()[source]
display_milling_rois_mask()[source]
orientation()[source]
set_axes_for_milling(settings)[source]
set_head_position()[source]
set_milling_rois(settings)[source]
class fibsem.sample.Sample[source]

Bases: object

Abstract base class for FIB-SEM samples. NOT FOR DIRECT USE

move_to_stage_position(microscope)[source]
print_vars()[source]
save_vars(output_filename)[source]
set_image(microscope)[source]
set_mask()[source]
set_pixel_size()[source]
set_stage_position(microscope)[source]
fibsem.sample.add_samples(microscope, settings, display_matplotlib=False)[source]

Interactive function to add samples to list.

Parameters:
  • microscope (Autoscript microscope object.) –
  • settings (User input argument settings.) –
Returns:

List of FIB-SEM sample objects.

Return type:

samples

fibsem.user_input module

fibsem.user_input.configure_parser()[source]

Configure parser and add user input arguments.

Returns:args – Parsed user input arguments.
Return type:argparse arguments
fibsem.user_input.load_config(yaml_filename)[source]
fibsem.user_input.response(message)[source]

Module contents