StitchingWobbly

Wobbly stitching module handles the alginment of large volumetric data sets.

The module alings stacks allowing them to wobble around a wobble axis, i.e. due to oscillatory movements during image aquisition.

class Verbose(verbose=True, save=None, directory=None)[source]

Bases: object

copy()[source]
create_directory(prefix=None)[source]
full_filename(filename)[source]
has_flag(flag)[source]
flags = {'figure': 4, 'save': 2}
class WobblyAlignment(pre=None, post=None, shifts=None, displacements=None, qualities=None, status=None, axis=2, shift=None, displacement=None, quality=None)[source]

Bases: ClearMap.Alignment.Stitching.StitchingRigid.Alignment

align_wobbly_axis(**kwargs)[source]
coordinate_to_local(coordinate)[source]
displacement_at_coordinate(coordinate)[source]
fix_unaligned()[source]

Linearly interpolate between unaligned coordinates

overlay_mip_wobbly(overlap=True, mip_axis=None, percentile=98, normalize=True)[source]
overlay_wobbly(overlap=True)[source]
plot_mip_wobbly(overlap=True, mip_axis=None, percentile=98)[source]
plot_overlay_wobbly()[source]
quality_at_coordinate(coordinate)[source]
set_status_at_coordinate(coordinate, status)[source]
smooth_displacements(min_quality=-inf, **kwargs)[source]
status_at_coordinate(coordinate)[source]
valids(min_quality=-inf)[source]
ALIGNED = 2
FIXED = 3
INVALID = -1
MEASURED = 1
NOMINIMA = -4
NOSIGNAL = -5
UNALIGNED = -3
UNTRACED = -2
VALID = 0
property displacements
property lower_coordinate
property shifts
status_to_description = {-5: 'no signal', -4: 'no minima', -3: 'unaligned', -2: 'untraced', -1: 'invalid', 0: 'valid', 1: 'measured', 2: 'aligned', 3: 'fixed'}
property upper_coordinate
class WobblyLayout(sources=None, expression=None, tile_axes=None, tile_shape=None, tile_positions=None, positions=None, overlaps=None, alignments=None, axis=2, position=None, shape=None, dtype=None, order=None)[source]

Bases: ClearMap.Alignment.Stitching.StitchingRigid.TiledLayout

Layout to handle stitching of wobbly sources.

alignment_info(tile_position, coordinate, plot=True, use_displacements=True, **kwargs)[source]

Gathers all alignment info for a slice of a certain tile.

layouts_along_axis_wobbly(coordinates=None)[source]

Returns a list of Layouts representing the placed wobbly sources in each wobbly-axis slice of this layout.

Arguments

coordinateslist of ints, all, or None

The positions of the slices along the wobble axis. If all or None take all possible slices.

Returns

sliceslist of SlicedLayout classes

The layouts in each wobble-axis-plane.

Note

The slices layouts can be used for stitching of the wobbly stacks.

plot_wobble()[source]
set_positions(positions)[source]

Set the positions of all wobbly slices and sources.

slice_along_axis_wobbly(coordinate)[source]

Returns a layout corresponding to a slice along the wobble axis in this layout.

Arguments

coordinateint

The coordinate at which to take the slice.

axisint

The axis to take the slice in.

Returns

layoutLayout class

The sliced layout.

Note

The underlying sources are converted to virtual for parallel stitching.

property lower_wobbly

Calculates the lower position of the entire layout.

Returns

lowertuple of ints

The lower position of the full layout.

property origin_wobbly
property shape_wobbly
property upper_wobbly

Calculates the upper position of the entire layout.

Returns

uppertuple of ints

The upper position of the full layout.

class WobblySource(source, wobble=None, status=None, axis=2, position=None, tile_position=None)[source]

Bases: ClearMap.Alignment.Stitching.StitchingRigid.Source

Class to handle source data and positions of wobbly stacks.

array_wobbly()[source]

Returns the array in the wobbly form with zeros at empty positions.

Returns

arrayarray

The data of the array.

coordinate_from_local(local_coordinate)[source]

Converts a local wobble axis coordiante to the non-local coordinate.

Arguments

local_coordinateint

The local coordiante within the source.

Returns

coordianteint

The non-local coordiante.

coordinate_to_local(coordinate)[source]

Converts a wobble axis coordinate to the a local coordinate wrt to the sources origin.

Arguments

coordinateint

The non-local coordinate.

Returns

loacl_coordinateint

The local coordinate within this source.

fix_isolated(exclude_borders=False)[source]

Fix the positons of isolated slices.

is_valid(coordinate)[source]
position_at_coordinate(coordinate)[source]

Returns the wobbly position of the source at the specified coordinate along the wobble axis.

Arguments

coordinateint

The coordinate along the wobble axis.

Returns

positiontuple of int.

The non-local position of the specified coordainte slice.

set_invalid(coordinate)[source]
set_isolated(coordinate)[source]
set_status_at_coordinate(coordinate, status)[source]
smooth_positions(smooth={'method': 'window', 'window': 'bartlett', 'window_length': 10})[source]
status_at_coordinate(coordinate)[source]
wobble_at_coordinate(coordinate)[source]

Returns the wobbly position of the source at the specified coordinate along the wobble axis.

Arguments

coordinateint

The coordinate along the wobble axis.

Returns

positiontuple of int.

The non-local position of the specified coordainte slice.

wobble_from_positions(positions)[source]
FIXED = 2
INVALID = -1
ISOLATED = -2
VALID = 0
property axis

The axis along which the source is assumed to be wobbly.

Returns

axisint

The wobble axes.

property coordinate
property height
property lower_wobbly

The lower corner of the wobbly source.

Returns

lowertuple of int

The coordinates of the lower corner of the source.

property name

The name of this source.

Returns

namestr

Name of this source.

property positions

The positions of the lower corners of all slices along the wobble axis.

Returns

positionsarray

The coordinates of the lower corner of the slices along the wobble axis.

property status

The status of each slice of this source.

Returns

statusarray of ints

The status for each position along the wobble axes.

status_to_description = {-2: 'isolated', -1: 'invalid', 0: 'valid', 2: 'fixed'}
property upper_wobbly

The upper corner of the source.

Returns

uppertuple of int

The coordinates of the upper corner of the source.

property valids
property wdim
property wobble

The wobblyness of this source.

Returns

wobblearray of ints

The deviations from the source position along the wobble axes.

align_layout(layout, axis_range=None, max_shifts=10, axis_mip=None, validate=None, prepare='normalization', validate_slice=None, prepare_slice=None, find_shifts='minimization', verbose=False, processes=None)[source]
align_wobbly_axis(source1, source2, axis=2, axis_range=None, max_shifts=10, axis_mip=None, validate=None, prepare='normalization', validate_slice=None, prepare_slice=None, find_shifts='minimization', with_errors=False, with_overlaps=False, verbose=True)[source]

Create shifts along the wobble axis, estimate smooth shifts and mark invalid slices, accounts for jumps in minima using multiple minima.

detect_local_minima(error, distance=1)[source]
fix_isolated(self, exclude_borders=False)[source]

Fix the positons of isolated slices.

fix_unaligned(displacements, status, qualities)[source]

Linearly interpolate between unaligned coordinates

inspect_align_layout(alignment, verbose)[source]

Parse the infomration saved during a align_layout.

Returns

errorsarray

The error landscape for each slice.

minimaarray

Coordinates of the detected minima

trajectorieslist

List of coordaintes of the detected trajectories.

trajectories_optimallist

List of the optimal trajectories.

place_layout(layout, min_quality=None, method='optimization', smooth=None, smooth_optimized=None, fix_isolated=True, lower_to_origin=True, processes=None, verbose=False)[source]

Place a layout with the WobblyAlignments.

prepare_normalization(array, clip=None, normalize=True)[source]
shifts_from_minimization(errors, status)[source]
shifts_from_tracing(errors, status, cutoff=None, new_trajectory_cost=None, minima='local_minima', verbose=False, **kwargs)[source]
smooth_binary(x, width=1)[source]

Remove displacements smaller than a certain width.

smooth_displacements(displacements, valids, method='window', **kwargs)[source]

Smooth displacements in valid regions.

smooth_positions(positions, valids, method='window', **kwargs)[source]

Smooth positions in valid regions.

smooth_window(x, window_length=10, window='bartlett', binary=None)[source]

Convolutional smoothing filter

stitch_layout(layout, sink, method='interpolation', processes=None, verbose=True)[source]

Stitches the wobbly sources in a wobbly layout.

Arguments

layout: WobblyLayout class

The layout of the stacks to stitch.

method‘interpolation’, ‘max’, ‘min’, ‘mean’

The method to use to stitch the sources.

processesint or ‘serial’

Number of processor to use for parallel processing, if ‘serial’ process in serial.

verbosebool

If True, print progress information.

Returns

layoutLayout

The layout with updated z-alignments.

validate_foreground(array, valid_range=(800, None), size=None, fraction=None, verbose=True)[source]
verbose_has_flag(verbose, flag)[source]