pyepri.displayers
This module provides static & interactive tools for image display.
Interactive image displayers
Tools for displaying images (currently only 4D spectral-spatial images) and interacting with the display through mouse and keyboard interactive commands (interactions are not available using notebooks).
Static (but updatable) image displayers
Static image displayers can be used to display different kind of images (2D & 3D, mono & multisource images) in different execution environments (console & notebooks).
They come with the possibility to update the displayed image at any moment (useful in an iterative framework).
Interactive image displayers
Tools for displaying images (currently only 4D spectral-spatial images) and interacting with the display through mouse and keyboard interactive commands (interactions are not available using notebooks).
Attributes
Classes
Class for display and update of different kind of images, in different running environments. |
Functions
|
Infer whether code is executed using IPython notebook or not. |
|
Interactive displayer for 4D spectral-spatial images. |
|
Initialize display for a single 2D image. |
|
Update single 2D image display. |
|
Initialize display for a single 3D image (display the three central slices of a 3D volume). |
|
Update single 3D image display. |
|
Initialize display for a sequence of 2D images. |
|
Update display for a sequence of 2D images. |
|
Initialize display for a sequence of 3D images. |
|
Update display for a sequence of 3D images. |
|
Instantiate a single 2D image displayer. |
|
Instantiate a single 3D image displayer. |
|
Instantiate a Displayer object suited to the input parameter. |
|
Retrieve displayed figure number. |
|
Factorized consistency checks for functions in this |
Module Contents
- pyepri.displayers.__EMPTY_ARRAY__
- pyepri.displayers.is_notebook() bool [source]
Infer whether code is executed using IPython notebook or not.
- pyepri.displayers.imshow4d(u, xgrid=None, ygrid=None, zgrid=None, Bgrid=None, spatial_unit='', B_unit='', figsize=None, valfmt='%0.3g', show_legend=True, legend_loc='upper right', show_colorbar=True, cmap=None, origin='lower', aspect='equal', boundaries='same', interpolation='nearest', sx_color=None, sy_color=None, sz_color=None, sb_color='g', xlim=None, ylim=None, zlim=None)[source]
Interactive displayer for 4D spectral-spatial images.
Display slices & spectra of a 4D spectral-sptatial image, and explore its content through many interactive commands (once the figure is displayed, press the h key of your keyboard to display the list of interactive commands, also listed below).
- Parameters:
u (ndarray) –
Four dimensional array containing the values of the 4D spectral-sptial image ordered as follows:
axis 0 = homogeneous magnetic field intensity axis (or B-axis);
axis 1 = spatial vertical axis (or Y-axis);
axis 2 = spatial horizontal axis (or X-axis);
axis 3 = saptial depth axis (or Z-axis).
xgrid (ndarray, optional) – Monodimensional ndarray with length
u.shape[2]
containing the sampling nodes associated to the X-axis (axis 2) of the 4D spectral-spatial imageu
.ygrid (ndarray, optional) – Monodimensional ndarray with length
u.shape[1]
containing the sampling nodes associated to the Y-axis (axis 1) of the 4D spectral-spatial imageu
.zgrid (ndarray, optional) – Monodimensional ndarray with length
u.shape[3]
containing the sampling nodes associated to the Z-axis (axis 3) of the 4D spectral-spatial imageu
.Bgrid (ndarray, optional) – Monodimensional ndarray with length
u.shape[0]
containing the sampling nodes associated to the B-axis (axis 0) of the 4D spectral-spatial imageu
.spatial_unit (str, optional) – Units associated to the X, Y and Z axes (handling of different axes units is not provided).
B_unit (str, optional) – Units associated to the homogeneous magnetic field intensity (B) axis.
figsize ((float, float), optional) – When given, figsize must be a tuple with length two and such that
figsize[0]
andfigsize[1]
are the width and height in inches of the figure to be displayed. When not given, the default setting is that of matplotlib (see key ‘figure.figsize’ of the matplotlib configuration parameterrcParams
).valfmt (str, optional) – %-format string used to format the slider values.
show_legend (bool, optional) – Decide whether the legend in the spectrum display area should be visible or not when the figure is drawn (note that once the figure is drawn, you can always show or hide the legend by pressing the ‘S’ key on your keyboard).
legend_loc (str, optional) – The location of the legend in the spectrum display area (see
matplotlib
documentation for possible choices).show_colorbar (bool, optional) – Specify whether a colorbar should be displayed next to each slice image.
cmap (str, optional) – The registered colormap name used to map scalar data to colors in matplotlib.imshow.
origin (str in {'upper', 'lower'}, optional) – Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. When not given, the default setting is that of matplotlib (see key ‘image.origin’ of the matplotlib configuration parameter
rcParams
).aspect (str in {'equal', 'auto'} or float or None, optional) –
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square (see matplotlib.imshow documentation).
When not given, the default setting is that of matplotlib (see key ‘image.aspect’ of the matplotlib configuration parameter
rcParams
).boundaries (str in {'auto', 'same'}) – Use
boundaries = 'same'
to give all subplots the same axes boundaries (in particular, this ensures that all slice images will be displayed on the screen using the same pixel size). Otherwise, a tight extent is used for each displayed slice image.interpolation (str, optional) – The interpolation method used (see
matplotlib
documentation for the possible choices).sx_color (str or None, optional) – The name of a matplotlib color for the X-slice slider progress bar (the default color is used when this optionnal input is set to
None
).sy_color (str or None, optional) – The name of a matplotlib color for the Y-slice slider progress bar (the default color is used when this optionnal input is set to
None
).sz_color (str or None, optional) – The name of a matplotlib color for the Z-slice slider progress bar (the default color is used when this optionnal input is set to
None
).sb_color (str or None, optional) – The name of a matplotlib color for the B slider progress bar (the default color is used when this optionnal input is set to
None
).xlim (tuple of float, optional) – Limits for the x-axis as a tuple
(xmin, xmax)
. If provided, sets the visible range of the x-axis. If None, the limits are determined automatically based on the data. Note that the use of this option jointly withboudnaries='same'
is discouraged and may lead to unexpected behavior.ylim (tuple of float, optional) – Limits for the y-axis as a tuple
(ymin, ymax)
. If provided, sets the visible range of the y-axis. If None, the limits are determined automatically based on the data. Note that the use of this option jointly withboudnaries='same'
is discouraged and may lead to unexpected behavior.zlim (tuple of float, optional) – Limits for the z-axis as a tuple
(zmin, zmax)
. If provided, sets the visible range of the z-axis. If None, the limits are determined automatically based on the data. Note that the use of this option jointly withboudnaries='same'
is discouraged and may lead to unexpected behavior.
- Returns:
params – A dictionary containing all graphical objects and state parameters.
- Return type:
dict
Mouse and keyboard Interactive commands
single left click : keep the display for the spectrum under the mouse cursor
x : select the X-slice slider
y : select the Y-slice slider
z : select the Z-slice slider
b : select the B-value slider
left : move the active slider back by one step
right : move the active slider forward by one step
ctrl + left : move the active slider back by 10% of its range
ctrl + right : move the active slider forward by 10% of its range
shift + left : move the active slider back by 5% of its range
shift + right : move the active slider forward by 5% of its range
up : toogle forward the slider selection (B -> X -> Y -> Z)
down : toogle back the slider selection (Z -> Y -> X -> B)
space : keep the display for spectrum under the mouse cursor
r : maximize the dynamic range of the last displayed spectrum
R : maximize the dynamic range of for all currently displayed spectra
c : maximize the contrast among the three displayed slices
d : remove the last displayed spectrum
D : remove all currently displayed spectra
S : show/hide legend
h : display help
- pyepri.displayers.init_display_monosrc_2d(u, newfig=True, figsize=None, time_sleep=0.01, units=None, display_labels=False, displayFcn=None, cmap=None, grids=None, origin='lower', aspect=None, is_notebook=False)[source]
Initialize display for a single 2D image.
- Parameters:
u (ndarray) – Two-dimensional array
newfig (bool, optional) – Specify whether the display must be done into a new figure or not.
figsize ((float, float), optional) – When given, figsize must be a tuple with length two and such that
figsize[0]
andfigsize[1]
are the width and height in inches of the figure to be displayed. When not given, the default setting is that of matplotlib (see key ‘figure.figsize’ of the matplotlib configuration parameterrcParams
).time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
units (str, optional) – Units associated to the X and Y axes (handling of different axes units is not provided).
display_labels (bool, optional) – Set
display_labels = True
to display axes labels (including units when given).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 2D imageu
into another 2D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.cmap (str, optional) – The registered colormap name used to map scalar data to colors in matplotlib.imshow.
grids (sequence, optional) –
A sequence (tuple or list) of two monodimensional ndarrays, such that grids[0] and grids[1] contain the sampling nodes associated to axes 0 (Y-axis) and 1 (X-axis) of the input array
u
.When given, the input grids are used to set the extent of the displayed image (see matplotlib.imshow documentation).
origin (str in {'upper', 'lower'}, optional) – Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. When not given, the default setting is that of matplotlib (see key ‘image.origin’ of the matplotlib configuration parameter
rcParams
).aspect (str in {'equal', 'auto'} or float or None, optional) –
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square (see matplotlib.imshow documentation).
When not given, the default setting is that of matplotlib (see key ‘image.aspect’ of the matplotlib configuration parameter
rcParams
).is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).
- Returns:
fg – Produced image instance.
- Return type:
<class ‘matplotlib.image.AxesImage’>
See also
- pyepri.displayers.update_display_monosrc_2d(u, fg, is_notebook=False, displayFcn=None, adjust_dynamic=True, time_sleep=0.01)[source]
Update single 2D image display.
- Parameters:
u (ndarray) – Two-dimensional array
fg (<class 'matplotlib.image.AxesImage'>) – Image instance to be updated.
is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 2D imageu
into another 2D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.adjust_dynamic (bool, optional) – Set
adjust_dynamic = True
to maximize the dynamic of the displayed image during the updating process, otherwise, setadjust_dynamic = False
to keep the displayed dynamic unchanged.time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
- Return type:
None
See also
- pyepri.displayers.init_display_monosrc_3d(u, newfig=True, figsize=None, time_sleep=0.01, units=None, display_labels=False, displayFcn=None, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', is_notebook=False, indexes=None)[source]
Initialize display for a single 3D image (display the three central slices of a 3D volume).
- Parameters:
u (ndarray) – Three-dimensional array
newfig (bool, optional) – Specify whether the display must be done into a new figure or not.
figsize ((float, float), optional) – When given, figsize must be a tuple with length two and such that
figsize[0]
andfigsize[1]
are the width and height in inches of the figure to be displayed. When not given, the default setting is that of matplotlib (see key ‘figure.figsize’ of the matplotlib configuration parameterrcParams
).time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
units (str, optional) – Units associated to the X, Y & Z axes (handling of different axes units is not provided).
display_labels (bool, optional) – Set
display_labels = True
to display axes labels (including units when given).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 3D imageu
into another 3D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.cmap (str, optional) – The registered colormap name used to map scalar data to colors in matplotlib.imshow.
grids (sequence, optional) –
A sequence (tuple or list) of three monodimensional ndarrays, such that grids[0], grids[1] and grids[2] contain the sampling nodes associated to axes 0 (Y-axis), axe 1 (X-axis), and axe 2 (Z-axis) of the input array
u
.When given, the input grids are used to set the extent of the displayed slices (see matplotlib.imshow documentation).
origin (str in {'upper', 'lower'}, optional) – Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. When not given, the default setting is that of matplotlib (see key ‘image.origin’ of the matplotlib configuration parameter
rcParams
).aspect (str in {'equal', 'auto'} or float or None, optional) –
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square (see matplotlib.imshow documentation).
When not given, the default setting is that of matplotlib (see key ‘image.aspect’ of the matplotlib configuration parameter
rcParams
).boundaries (str in {'auto', 'same'}) –
Use
boundaries = 'same'
to give all subplots the same axes boundaries (in particular, this ensures that all slice images will be displayed on the screen using the same pixel size).Otherwise, set
boundaries = 'auto'
to use tight extent for each displayed slice image.is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).indexes (sequence of int, optional) –
When given, indexes must be a sequence of three int,
index[j] = (id0, id1, id2)
, such that id0, id1 and id2 correspond to the indexes used along each axis of the 3D volume to extract the slices to be displayed (usingNone
to keep a particular index to its default value is possible).The default setting is
indexes = (u.shape[0]//2, u.shape[1]//2, u.shape[2]//2)
.
- Returns:
fg – Sequence of produced image instance (one instance per subplot)
- Return type:
sequence of <class ‘matplotlib.image.AxesImage’>
See also
- pyepri.displayers.update_display_monosrc_3d(u, fg, is_notebook=False, displayFcn=None, adjust_dynamic=True, time_sleep=0.01, indexes=None)[source]
Update single 3D image display.
- Parameters:
u (ndarray) – Three-dimensional array
fg (<class 'matplotlib.image.AxesImage'>) – Image instance to be updated.
is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 3D imageu
into another 3D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.adjust_dynamic (bool, optional) – Set
adjust_dynamic = True
to maximize the dynamic of the displayed slices during the updating process (the displayed dynamic will be [min, max] where min and max denote the min and max values among the three displayed slices), otherwise, setadjust_dynamic = False
to keep the displayed dynamic unchanged.time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
indexes (sequence of int, optional) –
When given, indexes must be a sequence of three int,
index[j] = (id0, id1, id2)
, such that id0, id1 and id2 correspond to the indexes used along each axis of the 3D volume to extract the slices to be displayed (usingNone
to keep a particular index to its default value is possible).The default setting is
indexes = (u.shape[0]//2, u.shape[1]//2, u.shape[2]//2)
.
- Return type:
None
See also
- pyepri.displayers.init_display_multisrc_2d(u, newfig=True, figsize=None, time_sleep=0.01, units=None, display_labels=False, displayFcn=None, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', is_notebook=False, src_labels=None)[source]
Initialize display for a sequence of 2D images.
- Parameters:
u (sequence of ndarray) – The sequence (tuple or list) of two-dimensional images to be displayed.
newfig (bool, optional) – Specify whether the display must be done into a new figure or not.
figsize ((float, float), optional) – When given, figsize must be a tuple with length two and such that
figsize[0]
andfigsize[1]
are the width and height in inches of the figure to be displayed. When not given, the default setting is that of matplotlib (see key ‘figure.figsize’ of the matplotlib configuration parameterrcParams
).time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
units (str, optional) – Units associated to the X & Y axes of the different source images (handling of different axes units is not provided).
display_labels (bool, optional) – Set
display_labels = True
to display axes labels (including units when given).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 3D imageu
into another 3D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.cmap (str, optional) – The registered colormap name used to map scalar data to colors in matplotlib.imshow.
grids (sequence, optional) –
A sequence with same length as
u
, such thatgrids[j]
is a sequence containing two monodimensional arrays (grids[j][0]
andgrids[j][1]
) corresponding to the sampling nodes associated to axes 0 (Y-axis), axe 1 (X-axis) of the j-th source imageu[j]
.When given, the input grids are used to set the extent of the displayed source images (see matplotlib.imshow documentation).
origin (str in {'upper', 'lower'}, optional) – Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. When not given, the default setting is that of matplotlib (see key ‘image.origin’ of the matplotlib configuration parameter
rcParams
).aspect (str in {'equal', 'auto'} or float or None, optional) –
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square (see matplotlib.imshow documentation).
When not given, the default setting is that of matplotlib (see key ‘image.aspect’ of the matplotlib configuration parameter
rcParams
).boundaries (str in {'auto', 'same'}) –
Use
boundaries = 'same'
to give all subplots the same axes boundaries (in particular, this ensures that all source images will be displayed on the screen using the same pixel size).Otherwise, set
boundaries = 'auto'
to use tight extent for each displayed slice image.is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).src_labels (sequence of str, optional) – When given, src_label must be a sequence with same length as
u
such thatsrc_labels[j]
corresponds to the label of the j-th sourceu[j]
(that is, a str to be added to the j-th source suptitle).
- Returns:
fg – Sequence of produced image instance (one instance per subplot).
- Return type:
sequence of <class ‘matplotlib.image.AxesImage’>
See also
- pyepri.displayers.update_display_multisrc_2d(u, fg, is_notebook=False, displayFcn=None, adjust_dynamic=True, time_sleep=0.01)[source]
Update display for a sequence of 2D images.
- Parameters:
u (sequence of ndarray) – The sequence (tuple or list) of two-dimensional images to be displayed.
fg (sequence of <class 'matplotlib.image.AxesImage'>) – The sequence of image instances to be updated.
is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the sequenceu
into another sequence of 2D images (with same length). When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.adjust_dynamic (bool, optional) – Set
adjust_dynamic = True
to maximize the dynamic of the displayed sequence of images during the updating process (the displayed dynamic will be [min, max] where min and max denote the min and max values among all the images inu
), otherwise, setadjust_dynamic = False
to keep the displayed dynamic unchanged.time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
- Return type:
None
See also
- pyepri.displayers.init_display_multisrc_3d(u, newfig=True, figsize=None, time_sleep=0.01, units=None, display_labels=False, displayFcn=None, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', is_notebook=False, indexes=None, src_labels=None)[source]
Initialize display for a sequence of 3D images.
- Parameters:
u (sequence of ndarray) – The sequence (tuple or list) of three-dimensional images to be displayed.
newfig (bool, optional) – Specify whether the display must be done into a new figure or not.
figsize ((float, float), optional) – When given, figsize must be a tuple with length two and such that
figsize[0]
andfigsize[1]
are the width and height in inches of the figure to be displayed. When not given, the default setting is that of matplotlib (see key ‘figure.figsize’ of the matplotlib configuration parameterrcParams
).time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
units (str, optional) – Units associated to the X, Y & Z axes of the different source images (handling of different axes units is not provided).
display_labels (bool, optional) – Set
display_labels = True
to display axes labels (including units when given).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the 3D imageu
into another 3D image. When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.cmap (str, optional) – The registered colormap name used to map scalar data to colors in matplotlib.imshow.
grids (sequence, optional) –
A sequence with same length as
u
, such thatgrids[j]
is a sequence containing three monodimensional arrays (grids[j][0]
,grids[j][1]
,grids[j][2]
) corresponding to the sampling nodes associated to axes 0 (Y-axis), axe 1 (X-axis) and axe 2 (Z-axis) of the j-th source imageu[j]
.When given, the input grids are used to set the extent of the displayed source images (see matplotlib.imshow documentation).
origin (str in {'upper', 'lower'}, optional) – Place the [0, 0] index of the array in the upper left or lower left corner of the Axes. When not given, the default setting is that of matplotlib (see key ‘image.origin’ of the matplotlib configuration parameter
rcParams
).aspect (str in {'equal', 'auto'} or float or None, optional) –
The aspect ratio of the Axes. This parameter is particularly relevant for images since it determines whether data pixels are square (see matplotlib.imshow documentation).
When not given, the default setting is that of matplotlib (see key ‘image.aspect’ of the matplotlib configuration parameter
rcParams
).boundaries (str in {'auto', 'same'}) –
Use
boundaries = 'same'
to give all subplots the same axes boundaries (in particular, this ensures that all source images will be displayed on the screen using the same pixel size).Otherwise, set
boundaries = 'auto'
to use tight extent for each displayed slice image.is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).indexes (sequence, optional) –
When given, indexes must be a sequence with lenght
nsrc
such thatindexes[j] = (id0, id1, id2)
is a sequence of three indexes corresponding to the indexes used along each axis of the j-th source imageu[j]
to extract the slices to be displayed (usingNone
to keep a particular index to its default value is possible).The default setting is
indexes = [[im.shape[0]//2, u.shape[1]//2, u.shape[2]//2] for im in u]
.src_labels (sequence of str, optional) – When given, src_label must be a sequence with same length as
u
such thatsrc_labels[j]
corresponds to the label of the j-th sourceu[j]
(that is, a str to be added to the j-th source suptitle).
- Returns:
fg – A sequence with same lenght as
u
and such thatfg[j]
is as sequence of three <class ‘matplotlib.image.AxesImage’> corresponding to the image instances produced when displaying the three slices ofu[j]
.- Return type:
sequence of sequence of <class ‘matplotlib.image.AxesImage’>
See also
- pyepri.displayers.update_display_multisrc_3d(u, fg, is_notebook=False, displayFcn=None, adjust_dynamic=True, time_sleep=0.01, indexes=None)[source]
Update display for a sequence of 3D images.
- Parameters:
u (sequence of ndarray) – The sequence (tuple or list) of two-dimensional images to be displayed.
fg (sequence of sequence of <class 'matplotlib.image.AxesImage'>) – The sequence of sequences of image instances to be updated (see
update_display_multisrc_3d
output).is_notebook (bool, optional) – Indicate whether the running environment is an interactive notebook (
is_notebook = True
) or not (is_notebook = False
).displayFcn (<class 'function'>, optional) – Function with prototype
im = displayFcn(u)
that changes the sequenceu
into another sequence of 2D images (with same length). When displayFcn is given, the displayed image isim = displayFcn(u)
instead ofu
.adjust_dynamic (bool, optional) – Set
adjust_dynamic = True
to maximize the dynamic of the displayed sequence of images during the updating process (the displayed dynamic will be [min, max] where min and max denote the min and max values among all displayed slices computed fromu
), otherwise, setadjust_dynamic = False
to keep the displayed dynamic unchanged.time_sleep (float, optional) – Duration in seconds of pause or sleep (depending on the running environment) to perform after image drawing.
indexes (sequence, optional) –
When given, indexes must be a sequence with lenght
nsrc
such thatindexes[j] = (id0, id1, id2)
is a sequence of three indexes corresponding to the indexes used along each axis of the j-th source imageu[j]
to extract the slices to be displayed (usingNone
to keep a particular index to its default value is possible).The default setting is
indexes = [[im.shape[0]//2, u.shape[1]//2, u.shape[2]//2] for im in u]
.
- Return type:
None
See also
- pyepri.displayers.create_2d_displayer(nsrc=1, newfig=True, figsize=None, displayFcn=None, time_sleep=0.01, units=None, adjust_dynamic=True, display_labels=False, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', indexes=None, src_labels=None)[source]
Instantiate a single 2D image displayer.
This function instantiate a
pyepri.Displayer
class instance using ndim=3 and passing all the other args & kwargs to thepyepri.displayers.Displayer
default constructor (typehelp(pyepri.displayers)
for more details).
- pyepri.displayers.create_3d_displayer(nsrc=1, newfig=True, figsize=None, displayFcn=None, time_sleep=0.01, units=None, extents=None, adjust_dynamic=True, display_labels=False, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', indexes=None, src_labels=None)[source]
Instantiate a single 3D image displayer.
This function instantiate a
pyepri.Displayer
class instance using ndim=3 and passing all the other args & kwargs to thepyepri.displayers.Displayer
default constructor (typehelp(pyepri.displayers)
for more details).
- pyepri.displayers.create(u, newfig=True, figsize=None, displayFcn=None, time_sleep=0.01, units=None, extents=None, adjust_dynamic=True, display_labels=False, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', indexes=None, src_labels=None)[source]
Instantiate a Displayer object suited to the input parameter.
This function instantiate a
pyepri.Displayer
class instance usingnsrc
andndim
values inferred fromu
and passing all the other args & kwargs to thepyepri.displayers.Displayer
default constructor (typehelp(pyepri.displayers)
for more details).
- pyepri.displayers.get_number(fg)[source]
Retrieve displayed figure number.
- Parameters:
fg (<class 'matplotlib.image.AxesImage'> or sequence of <class 'matplotlib.image.AxesImage'>) – Image instance or sequence of image instances that belond to the same figure.
- Returns:
fgnum – Figure number.
- Return type:
int
- pyepri.displayers._check_inputs_(nsrc=None, ndim=None, displayFcn=None, time_sleep=None, units=None, adjust_dynamic=None, display_labels=None, cmap=None, grids=None, origin=None, aspect=None, boundaries=None, u=__EMPTY_ARRAY__, newfig=None, figsize=None, indexes=None, src_labels=None)[source]
Factorized consistency checks for functions in this
pyepri.displayers
submodule.
- class pyepri.displayers.Displayer(nsrc, ndim, newfig=True, figsize=None, displayFcn=None, time_sleep=0.01, units=None, adjust_dynamic=True, display_labels=False, cmap=None, grids=None, origin='lower', aspect=None, boundaries='auto', force_multisrc=False, indexes=None, src_labels=None)[source]
Class for display and update of different kind of images, in different running environments.
Supported images
single 2D image : the input signal is a two-dimensional array
single 3D image : the input signal is a three-dimensional array
multisources 2D images : the input signal is a sequence of two-dimensional arrays (each array being called a source)
multisources 3D images : the input signal is a sequence of three-dimensional arrays (each array being called a source)
Displaying rules
single 2D image : the image is displayed using matplotlib.imshow
single 3D image : the three central slices (along each axis) of the image are drawn using matplotlib.imshow into a single row of subplots.
multisources 2D images : the source images are drawn using matplotlib.imshow into a single row of subplots.
multisources 3D images : each source image is represented using a row of subplots. Each row contains the three central slices of the considered source image.
In all situations described above, several display customization are proposed (axes labels, axes boundaries, colormap, aspect, …) through the kwargs of the default constructor.
Class attributes
- init_display<class ‘function’>
Function with prototype
fg = init_display(u)
that can be used to draw the input imageu
according to the rules described above. The returnedfg
is the produced image instance (when u is a single 2D image) or a sequence of image instances (when u is a single 3D image or a multisources 2D or 3D image) corresponding to the image instances of each produced subplot.- update_display<class ‘function’>
Function with prototype
None = update_display(u, fg)
that can be used to replace the image displayed infg
(the ouptut of theinit_display
attribute described above) byu
.- get_number<class ‘function’>
Function with prototype
fgnum = get_number(fg)
that return the figure number from the output of theinit_display
attribute described above.- title<class ‘function’>
Function with prototype
None = title(str)
that can be used to update the title (or suptitle when subplots are used) of the current figure.- notebookbool
A bool that specified whether the detected environment is an interactive notebook environments (
notebook = True
) or not (notebook = False
)- pause<class ‘function’>
Function with prototype
None = pause(t=time_sleep)
used to pause (or sleep in interactive python environment) during oft
seconds, the default value oftime_sleep
is defined during thepyepri.displayers.Display
object instanciation.- clear_output<class ‘function’>
Function with prototype
None = clear_output()
used to clear the currently displayed image within an interactive notebook running environment.
- clear_output
- get_number