mycelyso.highlevel package

Submodules

mycelyso.highlevel.nodeframe module

The nodeframe module contains the NodeFrame class, a representation of the graph of one time lapse frame.

class mycelyso.highlevel.nodeframe.NodeFrame(pf)[source]

Bases: object

Node frame is a representation of an image stack frame on the graph/node level, it populates its values from a PixelFrame passed.

cleanup_adjacency()[source]

Cleans up the adjacency matrix after alterations on the node level have been performed.

Returns:
cycles

Detects whether a cycle exists in the graph.

Returns:
generate_derived_data()[source]

Generates derived data from the current adjacency matrix.

Derived data are shortest paths, as well as connected components.

Returns:
get_connected_nodes(some_node)[source]

Get all nodes which are (somehow) connected to node some_node.

Parameters:some_node
Returns:
get_networkx_graph(with_z=0, return_positions=False)[source]

Convert the adjacency matrix based internal graph representation to a networkx graph representation.

Positions are additionally set based upon the pixel coordinate based positions of the nodes.

Parameters:
  • with_z – Whether z values should be set based upon the timepoint the nodes appear on
  • return_positions – Whether positions should be returned jointly with the graph
Returns:

get_path(start_node, end_node)[source]

Walks from start_node to end_node in the graph and returns the list of nodes (including both).

Parameters:
  • start_node
  • end_node
Returns:

is_endpoint(i)[source]

Returns whether node i is an endpoint.

Parameters:i
Returns:
is_junction(i)[source]

Returns whether node i is a junction.

Parameters:i
Returns:
prepare_graph(pf)[source]

Prepares the graph from the data stored in the PixelFrame pf. :param pf: PixelFrame :return:

track(successor)[source]

Tracks nodes on this frame to nodes on a successor frame.

Parameters:successor
Returns:

mycelyso.highlevel.pipeline module

The pipeline module contains the mycelyso-Pipeline, assembled from various functions.

class mycelyso.highlevel.pipeline.Mycelyso[source]

Bases: mycelyso.pilyso.application.application.App

The Mycelyso App, implementing a pilyso App.

arguments(argparser)[source]
handle_args()[source]
interactive_run()[source]
options()[source]
class mycelyso.highlevel.pipeline.MycelysoPipeline(args)[source]

Bases: mycelyso.pilyso.pipeline.pipeline.PipelineExecutionContext

The MycelysoPipeline, defining the pipeline (with slight alterations based upon arguments passed via command line).

mycelyso.highlevel.pixelframe module

The pixelframe module contains the PixelFrame class, a representation of one time lapse frame at the binary mask/pixel level.

class mycelyso.highlevel.pixelframe.PixelFrame(image, timepoint=0.0, calibration=1.0)[source]

Bases: object

A PixelFrame represents the pixel graph of one (skeletonized) image stack frame.

create_graph()[source]

Creates the graph from the pixel skeleton.

Returns:

mycelyso.highlevel.steps module

The steps module contains most of the individual, albeit mycelyso-specific processing steps.

mycelyso.highlevel.steps.binarize(image, binary=None)[source]

Binarizes the input image using the experimental thresholding technique.

Parameters:
  • image
  • binary
Returns:

mycelyso.highlevel.steps.clean_up(calibration, binary)[source]

Cleans up the image by removing holes smaller than the configured size.

Parameters:
  • calibration
  • binary
Returns:

>>> clean_up(0.1, np.array([[ True,  True,  True],
...                         [ True, False,  True],
...                         [ True,  True,  True]]))
array([[ True,  True,  True],
       [ True,  True,  True],
       [ True,  True,  True]])
mycelyso.highlevel.steps.convert_to_nodes(skeleton, timepoint, calibration, pixel_frame=None, node_frame=None)[source]

Passes the input skeleton into a PixelFrame and instantiates a NodeFrame based upon that.

Parameters:
  • skeleton
  • timepoint
  • calibration
  • pixel_frame
  • node_frame
Returns:

mycelyso.highlevel.steps.generate_graphml(node_frame, result)[source]

Generates a GraphML representation of a particular frame.

Parameters:
  • node_frame
  • result
Returns:

mycelyso.highlevel.steps.generate_overall_graphml(collected, result)[source]

Generates a GraphML representation of the whole graph of one image stack.

Parameters:
  • collected
  • result
Returns:

mycelyso.highlevel.steps.graph_statistics(node_frame, result=None)[source]

Adds some information about the graph to the results.

Parameters:
  • node_frame
  • result
Returns:

>>> pf = PixelFrame(np.array([[0, 0, 0],
...                           [1, 1, 1],
...                           [0, 0, 0]]), calibration=15.0)
>>> sorted(graph_statistics(NodeFrame(pf)).items())
[('graph_edge_count', 1.0), ('graph_edge_length', 30.0), ('graph_endpoint_count', 2), ('graph_junction_count', 0), ('graph_node_count', 2)]
mycelyso.highlevel.steps.image_statistics(image, calibration, result=None)[source]

Adds some numeric image parameters (i.e. size) to the results.

Parameters:
  • image
  • calibration
  • result
Returns:

>>> sorted(image_statistics(np.array([[0, 0, 0],
...                                   [0, 0, 0],
...                                   [0, 0, 0]]), calibration=15.0).items())
[('area', 2025.0), ('area_pixel', 9), ('input_height', 45.0), ('input_height_pixel', 3), ('input_width', 45.0), ('input_width_pixel', 3)]
mycelyso.highlevel.steps.individual_tracking(collected, tracked_fragments=None, tracked_fragments_fates=None)[source]

After correspondence has been established by NodeFrame#track, reconstructs growing paths over time.

Parameters:
  • collected
  • tracked_fragments
  • tracked_fragments_fates
Returns:

mycelyso.highlevel.steps.prepare_position_regressions(collected, result)[source]

Prepares some regressions over parameters collected per position over time.

Parameters:
  • collected
  • result
Returns:

mycelyso.highlevel.steps.prepare_tracked_fragments(collected, tracked_fragments, tracked_fragments_fates, track_table=None, track_table_aux_tables=None)[source]

Filters and converts tracked growing segments to result datasets.

Parameters:
  • collected
  • tracked_fragments
  • tracked_fragments_fates
  • track_table
  • track_table_aux_tables
Returns:

mycelyso.highlevel.steps.qimshow(image, cmap='gray')[source]

Debug function, quickly shows the passed image via matplotlibs imshow-facilities.

Parameters:
  • image
  • cmap
Returns:

mycelyso.highlevel.steps.quantify_binary(binary, calibration, result=None)[source]

Adds some information about the binary image (i.e. covered ratio, area …) to the results.

Parameters:
  • binary
  • calibration
  • result
Returns:

>>> sorted(quantify_binary(np.array([[0, 0, 0],
...                                  [1, 1, 1],
...                                  [0, 0, 0]]), calibration=15.0).items())
[('covered_area', 675.0), ('covered_area_pixel', 3), ('covered_ratio', 0.3333333333333333)]
mycelyso.highlevel.steps.remove_border_artifacts(calibration, binary)[source]

Removes structures, which are most likely artifacts because their centroid lies near the border.

Parameters:
  • calibration
  • binary
Returns:

>>> remove_border_artifacts(0.1, np.array([[ False, False, False],
...                                        [ False, False,  True],
...                                        [ False, False,  True]]))
array([[False, False, False],
       [False, False, False],
       [False, False, False]])
mycelyso.highlevel.steps.remove_small_structures(calibration, binary)[source]

Cleans up the image by removing structures smaller than the configured size.

Parameters:
  • calibration
  • binary
Returns:

>>> remove_small_structures(0.1, np.array([[ False, False, False],
...                                        [ False, False,  True],
...                                        [ False, False,  True]]))
array([[False, False, False],
       [False, False, False],
       [False, False, False]])
mycelyso.highlevel.steps.set_empty_crops(image, crop_t=None, crop_b=None, crop_l=None, crop_r=None)[source]

Defines crop parameters based upon image size, effectively not cropping at all.

Parameters:
  • image
  • crop_t
  • crop_b
  • crop_l
  • crop_r
Returns:

mycelyso.highlevel.steps.skeletonize(binary, skeleton=None)[source]

Skeletonizes the image using scikit-image’s skeletonize function.

Parameters:
  • binary
  • skeleton
Returns:

>>> skeletonize(np.array([[0, 0, 1, 1],
...                       [0, 0, 1, 1],
...                       [0, 0, 1, 1],
...                       [0, 0, 1, 1]]))
array([[False, False, False, False],
       [False, False,  True, False],
       [False, False,  True, False],
       [False, False, False, False]])
mycelyso.highlevel.steps.skip_if_image_is_below_size(min_height=4, min_width=4)[source]

Raises a Skip exception if the image size falls below the set image size.

Parameters:
  • min_height
  • min_width
Returns:

>>> skip_if_image_is_below_size(32, 32)(np.zeros((16,16)), Meta(0, 0))
Traceback (most recent call last):
 ...
mycelyso.pilyso.pipeline.executor.Skip: Meta(pos=0, t=<class 'mycelyso.pilyso.pipeline.executor.Collected'>)
mycelyso.highlevel.steps.track_multipoint(collected)[source]

Initiates tracking between consecutive NodeFrames.

Parameters:collected
Returns:

Module contents

The highlevel package contains highlevel functionality of mycelyso.