elektronn2.data.skeleton module

elektronn2.data.skeleton.trace_to_kzip(trace_xyz, fname)[source]
class elektronn2.data.skeleton.SkeletonMFK(aniso_scale=2, name=None, skel_num=None)[source]

Bases: object

Joints: all branches and end points / node terminations (nodes not of deg 2) Branches: Joints of degree >= 3

calc_max_dist_to_skels()[source]
static find_joints(node_list)[source]
get_closest_node(position_s)[source]
get_hull_branch_direc_cutoff(**kwargs0)[source]
get_hull_branch_dist_cutoff(**kwargs0)[source]
get_hull_points_inner(**kwargs0)[source]
get_hull_skel_direc_rel(**kwargs0)[source]
get_kdtree(**kwargs0)[source]
get_knn(**kwargs0)[source]
get_loss_and_gradient(new_position_s, cutoff_inner=0.3333333333333333, rise_factor=0.1)[source]

prediction_c (zxy) Zoned error surface: flat in inner hull (selected at cutoff_inner) constant gradient in “outer” hull towards nearest inner hull voxel gradient increasing with distance (scaled by rise_factor) for predictions outside hull

static get_scale_factor(radius, old_factor, scale_strenght)[source]
Parameters:
  • radius (predicted radius (not the true radius)) –
  • old_factor (factor by which the radius prediction and the image was scaled) –
  • scale_strenght (limits the maximal scale factor) –
Returns:

Return type:

new_factor

getbatch(prediction, scale_strenght, **get_batch_kwargs)[source]
Parameters:
  • prediction ([[new_position_c, radius, ]]) –
  • scale_strenght (limits the maximal scale factor for zoom) –
  • get_batch_kwargs
Returns:

batch

Return type:

img, target_img, target_grid, target_node

init_from_annotation(skeleton_annotatation, min_radius=None, interpolation_resolution=0.5, interpolation_order=1)[source]
interpolate_bone(bone, max_k=1, resolution=0.5)[source]
interpolate_prop(old_bone, old_prop, new_bone, discrete=False)[source]
make_grid = <elektronn2.utils.utils_basic.cache object>
map_hull(hull_points)[source]

Distances take already into account the anisotropy in z (i.e. they are true distances) But all coordinates for hulls and vectors are still pixel coordinates

plot_debug_traces(grads=True, fig=None)[source]
plot_hull(fig=None)[source]
plot_hull_inner(cutoff, fig=None)[source]
plot_radii(fig=None)[source]
plot_skel(fig=None)[source]
plot_vec(substep=15, dict_name='skel', key='direc', vec=None, fig=None)[source]
static point_potential(r, margin_scale, size, repulsion=None)[source]
sample_local_direction_iso(point, n_neighbors=6)[source]

For a point gives the local skeleton direction/orientation by fitting a line through the nearest neighbours, sign is randomly assigned

sample_skel_point(rng, joint_ratio=None)[source]
sample_tracing_direction_iso(rng, local_direction_iso, c=0.5)[source]

Sample a direction close to the local direction there is a prior so that the normalised (0,1) angle of deviation a has this distribution: p(a) = 1/N * (1-c*a), where N= 1 - c/2, tmp is the inverse cdf of this.

sample_tube_point(rng, r_max_scale=0.9, joint_ratio=None)[source]

This is skeleton node based sampling: Go to a random node, sample a random orthogonal direction go a random distance into direction (uniform over the [0, r_max_scale * local maximal radius])

save(fname)[source]
step_feedback(new_position_s, new_direction_is, pred_c, pred_features, cutoff_inner=0.3333333333333333, rise_factor=0.1)[source]
step_grid_update(grid, radius, bio)[source]
class elektronn2.data.skeleton.Trace(linked_skel=None, aniso_scale=2, max_cutoff=200, uturn_detection_k=40, uturn_detection_thresh=0.45, uturn_detection_hold=10, feature_count=7)[source]

Bases: object

Unless otherwise state all coordinates are in skeleton system (xyz) with z-axis anisotrope and all distances are in pixels (conversion to mu: 1/100)

add_offset(off)[source]
append(coord, coord_cnn=None, grad=None, features=None)[source]
append_serial(*args)[source]
avg_dist_self
avg_dist_skel
avg_seg_length
max_dist_skel
min_dist_self
min_normed_dist_self
new_cut_trace(start, stop)[source]
new_reverted_trace()[source]
plot(grads=True, skel=True, rand_color=False, fig=None)[source]
runlength
save(fname)[source]
save_to_kzip(fname)[source]
split_uturns(return_accum_pathlength=False, print_stat=False)[source]
tortuosity(start=None, end=None)[source]