xdesign.plot

Functions:

plot_phantom(phantom[, axis, labels, ...]) Plots a phantom to the given axis.
plot_feature(feature[, axis, alpha, c]) Plots a feature on the given axis.
plot_mesh(mesh[, axis, alpha, c]) Plots a mesh to the given axis.
plot_polygon(polygon[, axis, alpha, c]) Plots a polygon to the given axis.
plot_curve(curve[, axis, alpha, c]) Plots a curve to the given axis.
discrete_phantom(phantom, size[, ratio, ...]) Returns discrete representation of the property function, prop, in the phantom.
sidebyside(p[, size, labels, prop]) Displays the geometry and the discrete property function of the given phantom side by side.
multiroll(x, shift[, axis]) Roll an array along each axis.
plot_metrics(imqual) Plots full reference metrics of ImageQuality data.
plot_mtf(faxis, MTF[, labels]) Plots the MTF.
plot_nps(X, Y, NPS) Plots the 2D frequency plot for the NPS.
plot_neq(freq, NEQ) Plots the NEQ.
plot_histograms(images[, masks, thresh]) Plots the normalized histograms for the pixel intensity under each mask.
xdesign.plot.plot_phantom(phantom, axis=None, labels=None, c_props=[], c_map=None)[source]

Plots a phantom to the given axis.

Parameters:
  • labels (bool, optional) – Each feature is numbered according to its index in the phantom.
  • c_props (list of str, optional) – List of feature properties to use for colormapping the geometries.
  • c_map (function, optional) – A function which takes the a list of prop(s) for a Feature as input and returns a matplolib color specifier.
xdesign.plot.plot_feature(feature, axis=None, alpha=None, c=None)[source]

Plots a feature on the given axis.

Parameters:
xdesign.plot.plot_mesh(mesh, axis=None, alpha=None, c=None)[source]

Plots a mesh to the given axis.

Parameters:
xdesign.plot.plot_polygon(polygon, axis=None, alpha=None, c=None)[source]

Plots a polygon to the given axis.

Parameters:
xdesign.plot.plot_curve(curve, axis=None, alpha=None, c=None)[source]

Plots a curve to the given axis.

Parameters:
xdesign.plot.discrete_phantom(phantom, size, ratio=8, uniform=True, prop=u'mass_atten')[source]

Returns discrete representation of the property function, prop, in the phantom. The values of overlapping features are additive.

Parameters:
  • size (scalar) – The side length in pixels of the resulting square image.
  • ratio (scalar, optional) – The antialiasing works by supersampling. This parameter controls how many pixels in the larger representation are averaged for the final representation. e.g. if ratio = 8, then the final pixel values are the average of 64 pixels.
  • uniform (boolean, optional) – When set to False, changes the way pixels are averaged from a uniform weights to gaussian weigths.
  • prop (str, optional) – The name of the property function to discretize
Returns:

image (numpy.ndarray) – The discrete representation of the phantom that is size x size.

xdesign.plot.sidebyside(p, size=100, labels=None, prop=u'mass_atten')[source]

Displays the geometry and the discrete property function of the given phantom side by side.

xdesign.plot.multiroll(x, shift, axis=None)[source]

Roll an array along each axis.

Parameters:
  • x (array_like) – Array to be rolled.
  • shift (sequence of int) – Number of indices by which to shift each axis.
  • axis (sequence of int, optional) – The axes to be rolled. If not given, all axes is assumed, and len(shift) must equal the number of dimensions of x.
Returns:

y (numpy array, with the same type and size as x) – The rolled array.

Notes

The length of x along each axis must be positive. The function does not handle arrays that have axes with length 0.

See also

numpy.roll()

Example

Here’s a two-dimensional array:

>>> x = np.arange(20).reshape(4,5)
>>> x
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19]])

Roll the first axis one step and the second axis three steps:

>>> multiroll(x, [1, 3])
array([[17, 18, 19, 15, 16],
       [ 2,  3,  4,  0,  1],
       [ 7,  8,  9,  5,  6],
       [12, 13, 14, 10, 11]])

That’s equivalent to:

>>> np.roll(np.roll(x, 1, axis=0), 3, axis=1)
array([[17, 18, 19, 15, 16],
       [ 2,  3,  4,  0,  1],
       [ 7,  8,  9,  5,  6],
       [12, 13, 14, 10, 11]])

Not all the axes must be rolled. The following uses the axis argument to roll just the second axis:

>>> multiroll(x, [2], axis=[1])
array([[ 3,  4,  0,  1,  2],
       [ 8,  9,  5,  6,  7],
       [13, 14, 10, 11, 12],
       [18, 19, 15, 16, 17]])

which is equivalent to:

>>> np.roll(x, 2, axis=1)
array([[ 3,  4,  0,  1,  2],
       [ 8,  9,  5,  6,  7],
       [13, 14, 10, 11, 12],
       [18, 19, 15, 16, 17]])

References

Warren Weckesser http://stackoverflow.com/questions/30639656/numpy-roll-in-several-dimensions

xdesign.plot.plot_metrics(imqual)[source]

Plots full reference metrics of ImageQuality data.

Parameters:imqual (ImageQuality) – The data to plot.

References

Colors taken from this gist <https://gist.github.com/thriveth/8560036>

xdesign.plot.plot_mtf(faxis, MTF, labels=None)[source]

Plots the MTF. Returns the figure reference.

xdesign.plot.plot_nps(X, Y, NPS)[source]

Plots the 2D frequency plot for the NPS. Returns the figure reference.

xdesign.plot.plot_neq(freq, NEQ)[source]

Plots the NEQ. Returns the figure reference.

xdesign.plot.plot_histograms(images, masks=None, thresh=0.025)[source]

Plots the normalized histograms for the pixel intensity under each mask.

Parameters:
  • images (list of ndarrays, ndarray) – image(s) for comparing histograms.
  • masks (list of ndarrays, float, optional) – If supplied, the data under each mask is plotted separately.
  • strict (boolean) – If true, the mask takes values >= only. If false, the mask takes all values > 0.