hyperspy.samfire_utils.strategy module¶
-
class
hyperspy.samfire_utils.strategy.GlobalStrategy(name)¶ Bases:
hyperspy.samfire_utils.strategy.SamfireStrategyA SAMFire strategy that operates in “parameter space” - i.e the pixel positions are not important, and only parameter value distributions are segmented to be used as starting point estimators.
-
clean()¶ Purges the currently saved values (not the database).
-
plot(fig=None)¶ Plots the current database of histograms
- Parameters
fig ({None, HistogramTilePlot}) – If given updates the plot.
-
refresh(overwrite, given_pixels=None)¶ Refreshes the database (i.e. constructs it again from scratch)
-
segmenter= None¶
-
values(ind=None)¶ Returns the saved most frequent values that should be used for prediction
-
-
class
hyperspy.samfire_utils.strategy.LocalStrategy(name)¶ Bases:
hyperspy.samfire_utils.strategy.SamfireStrategyA SAMFire strategy that operates in “pixel space” - i.e calculates the starting point estimates based on the local averages of the pixels. Requires some weighting method (e.g. reduced chi-squared).
-
clean()¶ Purges the currently saved values.
-
plot(fig=None)¶ Plots the current marker in a flat image
- Parameters
fig ({Image, None}) – if an already plotted image, then updates. Otherwise creates a new one.
- Returns
fig – the resulting image. If passed again, will be updated (computationally cheaper operation).
- Return type
Image
-
property
radii¶ A tuple of >=0 floats that show the “radii of relevance”
-
refresh(overwrite, given_pixels=None)¶ Refreshes the marker - recalculates with the current values from scratch.
- Parameters
overwrite (Bool) – If True, all but the given_pixels will be recalculated. Used when part of already calculated results has to be refreshed. If False, only use pixels with marker == -scale (by default -1) to propagate to pixels with marker >= 0. This allows “ignoring” pixels with marker < -scale (e.g. -2).
given_pixels (boolean numpy array) – Pixels with True value are assumed as correctly calculated.
-
property
samf¶ The SAMFire that owns this strategy.
-
values(ind)¶ Returns the current starting value estimates for the given pixel. Calculated as the weighted local average. Only returns components that are active, and parameters that are free.
-
property
weight¶ A Weight object, able to assign significance weights to separate pixels or maps, given the model.
-
-
class
hyperspy.samfire_utils.strategy.SamfireStrategy¶ Bases:
objectA SAMFire strategy base class.
-
close_plot= None¶
-
name= ''¶
-
remove()¶ Removes this strategy from its SAMFire
-
samf= None¶
-
-
hyperspy.samfire_utils.strategy.make_sure_ind(inds, req_len=None)¶ Given an object, constructs a tuple of floats the required length. Either removes items that cannot be cast as floats, or adds the last valid item until the required length is reached.
- Parameters
inds (sequence) – the sequence to be constructed into tuple of floats
req_len ({None, number}) – The required length of the output
- Returns
indices
- Return type
tuple of floats
-
hyperspy.samfire_utils.strategy.nearest_indices(shape, ind, radii)¶ Returns the slices to slice a given size array to get the required size rectangle around the given index. Deals nicely with boundaries.
- Parameters
- Returns
slices (tuple of slices) – The slices to slice the large array to get the required region.
center (tuple of ints) – The index of the original centre (ind) position in the new (sliced) array.