Previous topic

medpy.graphcut.graph.GCGraph.set_tweight

Next topic

medpy.graphcut.graph.GCGraph.set_tweights_all

This Page

medpy.graphcut.graph.GCGraph.set_tweights

GCGraph.set_tweights(tweights)[source]

Set multiple t-weights to the current collection of t-weights, overwriting already existing ones.

Parameters:

tweights : dict

A dictionary with node_ids as keys and (weight-to-source, weight-to-sink) tuples as values.

Raises:

ValueError

If a passed node id does not refer to any node of the graph (i.e. it is either higher than the initially set number of nodes or lower than zero).

Notes

Since this method overrides already existing t-weights, it is strongly recommended to run set_source_nodes and set_sink_nodes after the last call to this method.

The weights for nodes directly connected to either the source or the sink are best set using set_source_nodes or set_sink_nodes to ensure consistency of their maximum values.