mdt.visualization.maps package¶
Submodules¶
mdt.visualization.maps.base module¶
-
class
mdt.visualization.maps.base.
Clipping
(vmin=0, vmax=0, use_min=False, use_max=False)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for the map clipping information
-
apply
(data)[source]¶ Apply the clipping to the given 2d array and return the new array.
Parameters: data (ndarray) – the data to clip
-
get_updated
(**kwargs)[source]¶ Get a new Clipping object with updated arguments.
Parameters: **kwargs (dict) – the new keyword values, when given these take precedence over the current ones. Returns: a new scale with updated values. Return type: Clipping
-
visible_changes
(old_clipping)[source]¶ Checks if there are any visible changes between this clipping and the other.
This method can implement knowledge that allows the visualization routine to check if it would need to update the plot or not.
It expects that the clipping you wish to use is the one on which this method is called.
Parameters: old_clipping (Clipping) – the previous clipping Returns: if the differences between this clipping and the other would result in visible differences. Return type: bool
-
-
class
mdt.visualization.maps.base.
ColorbarSettings
(visible=None, nmr_ticks=None, location=None, power_limits=None, round_precision=None)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for all colorbar related settings.
Parameters: - visible (boolean) – if the colorbar is to be shown
- nmr_ticks (int) – the number of ticks
- location (str) – the location of the colorbar, one of ‘right’, ‘left’, ‘top’ or ‘bottom’
- power_limits (tuple) – size thresholds for scientific notation. The default is (-3, 4) which uses scientific notation for numbers less than 1e-3 or greater than 1e4.
- round_precision (int) – how much digits (precision) after the decimal point.
-
get_preferred
(attr, other_settings=None)[source]¶ Get the preferred value for the requested attribute.
Other settings is a list of other colorbar settings object that are asked for the preferred value (in turn), if the value of this object is None.
As a fallback, this will always use the default colorbar settings
ColorbarSettings.get_default()
as a final default.Parameters: - attr (str) – the attribute requested
- other_settings (list of ColorbarSettings) – other settings to try.
Returns: the value of the requested object
Return type: object
-
class
mdt.visualization.maps.base.
ConvertibleConfig
[source]¶ Bases:
object
Base class for convertible configuration containers.
Objects implementing this interface return a conversion specification that describes how the implementing class can be converted to and from a simple dictionary containing only primitives and simple data structures.
-
classmethod
get_conversion_info
()[source]¶ Get the conversion specification information for this class.
Returns: the conversion specification Return type: mdt.visualization.dict_conversion.ConversionSpecification
-
classmethod
-
class
mdt.visualization.maps.base.
DataInfo
[source]¶ Bases:
object
Information about the maps we are viewing.
-
get_bounding_box
(dimension, slice_index, volume_index, rotate, map_names=None)[source]¶ Get the bounding box of the images.
Parameters: - dimension (int) – the dimension to search in
- slice_index (int) – the slice index in that dimension
- volume_index (int) – the current volume index
- rotate (int) – the angle by which to rotate the image before getting the bounding box
- map_names (list of str) – if given we will only scan the given list of maps
Returns: - two points designating the upper left corner and the lower right corner of the
bounding box.
Return type: tuple of
Point2d
-
get_file_path
(map_name)[source]¶ Get the file name of the given map
Returns: None if the map could not be found on dir, else a string with the file path.
-
get_file_paths
()[source]¶ Get the file paths to each of the maps.
If one of the maps does not have a file path, None is returned.
Returns: mapping map names to the file paths for each of the maps in this information container. Return type: dict
-
get_index_first_non_zero_slice
(dimension, map_names=None)[source]¶ Get the index of the first non zero slice in the maps.
Parameters: - dimension (int) – the dimension to search in
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the slice index with the first non zero values.
Return type: int
-
get_map_data
(map_name)[source]¶ Get the data for the indicated map.
Parameters: map_name (str) – the name of the map we want the data of Returns: the data of the given map Return type: ndarray
-
get_map_names
()[source]¶ Get a list of the names of all the maps in this data info object.
Returns: the list of map names Return type: list
-
get_max_dimension
(map_names=None)[source]¶ Get the minimum of the maximum dimension index over the maps
Parameters: map_names (list of str) – if given we will only scan the given list of maps Returns: either, 0, 1, 2 as the maximum dimension index in the maps. Return type: int
-
get_max_slice_index
(dimension, map_names=None)[source]¶ Get the maximum slice index in the given map on the given dimension.
Parameters: - dimension (int) – the dimension we want the slice index of (maximum 3)
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the minimum of the maximum slice indices over the given maps in the given dimension.
Return type: int
-
get_max_volume_index
(map_names=None)[source]¶ Get the maximum volume index in the given maps.
In contrast to the max dimension and max slice index functions, this gives the maximum over all the images. This since handling different volumes is implemented in the viewer.
Parameters: map_names (list of str) – if given we will only scan the given list of maps Returns: the maximum volume index in the given list of maps. Starts from 0. Return type: int
-
get_max_x_index
(dimension, rotate=0, map_names=None)[source]¶ Get the maximum x index supported over the images.
In essence this gets the lowest x index found.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the rotation factor by which we rotate the slices within the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the maximum x-index found.
Return type: int
-
get_max_y_index
(dimension, rotate=0, map_names=None)[source]¶ Get the maximum y index supported over the images.
In essence this gets the lowest y index found.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the rotation factor by which we rotate the slices within the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the maximum y-index found.
Return type: int
-
get_single_map_info
(map_name)[source]¶ Get an information object for a single map.
Parameters: map_name (str) – the name of the map we want information about Returns: information object about that map Return type: SingleMapInfo
-
slice_has_data
(dimension, slice_index, map_names=None)[source]¶ Check if at least one of the maps has non zero numbers on the given slice.
Parameters: - dimension (int) – the dimension to search in
- slice_index (int) – the index of the slice in the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: true if at least on of the maps has data in the given slice
Return type: bool
-
-
class
mdt.visualization.maps.base.
Font
(family='sans-serif', size=14)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Information about the font to use
Parameters: - family – the name of the font to use
- size – the size of the font (> 0).
-
classmethod
font_names
()[source]¶ Get the name of supported fonts
Returns: the name of the supported fonts and font families. Return type: list of str
-
get_updated
(**kwargs)[source]¶ Get a new Font object with updated arguments.
Parameters: **kwargs (dict) – the new keyword values, when given these take precedence over the current ones. Returns: a new Font with updated values. Return type: Font
-
name
¶
-
class
mdt.visualization.maps.base.
MapPlotConfig
(dimension=2, slice_index=0, volume_index=0, rotate=90, colormap='hot', colormap_masked_color=None, maps_to_show=None, font=None, grid_layout=None, show_axis=False, show_titles=True, zoom=None, map_plot_options=None, interpolation='bilinear', flipud=None, title=None, title_spacing=None, mask_name=None, colorbar_settings=None, annotations=None)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for all plot related settings.
Parameters: - dimension (int) – the dimension we are viewing
- slice_index (int) – the slice in the dimension we are viewing
- volume_index (int) – in the case of multiple volumes (4th dimension) which index we are in.
- rotate (int) – the rotation factor, multiple of 90. By default we rotate 90 degrees to show most in-vivo datasets in a natural way.
- colormap (str) – the name of the colormap to use
- colormap_masked_color (str) – the color for masked, NaN and infinity values.
- maps_to_show (list of str) – the names of the maps to show
- font (int) – the font settings
- grid_layout (GridLayout) – the layout of the grid
- show_axis (bool) – if we show the axis or not
- show_titles (boolean) – the global setting for enabling/disabling the plot titles
- zoom (Zoom) – the zoom setting for all the plots
- map_plot_options (dict of SingleMapConfig) – per map the map specific plot options
- interpolation (str) – one of the available interpolations
- flipud (boolean) – if True we flip the image upside down
- title (str) – the title to this plot
- title_spacing (float) – the spacing between the top of the plots and the title
- mask_name (str) – the name of the mask to apply to the maps prior to display
- annotations (list of VoxelAnnotation) – the voxel annotations
- colorbar_settings (ColorbarSettings) – all colorbar related settings
-
create_valid
(data_info)[source]¶ Creates a new configuration object with valid values.
Parameters: data_info (mdt.visualization.maps.base.DataInfo) – the data information Returns: a valid map plot configuration Return type: MapPlotConfig
-
to_dict
(non_default_only=False)[source]¶ Export this configuration to a dictionary
Parameters: non_default_only (boolean) – if True, we will only export those options that are not set to their default. Returns: dict representation of the data Return type: dict
-
to_yaml
(non_default_only=False)[source]¶ Convert this configuration to a YAML string.
Parameters: non_default_only (boolean) – if True, we will only export those options that are not set to their default. Returns: a YAML representation of this configuration. Return type: str
-
validate
(data_info)[source]¶ Check if this configuration is valid given the provided data.
Parameters: data_info (mdt.visualization.maps.base.DataInfo) – the data information Raises: Exception
– can raise multiple sorts of exceptions if this config is not valid given the data.
-
visible_changes
(old_config)[source]¶ Checks if there are any visible changes between this configuration and the other.
This method can implement knowledge that allows the visualization routine to check if it would need to update the plot or not.
It expects that the configuration you wish to display is the one on which this method is called.
Parameters: old_config (MapPlotConfig) – the previous configuration Returns: if the differences between this configuration and the other would result in visible differences. Return type: bool
-
class
mdt.visualization.maps.base.
Point2d
(x, y)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for a single point
-
class
mdt.visualization.maps.base.
Scale
(vmin=0, vmax=0, use_min=False, use_max=False)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container the map scaling information
-
get_updated
(**kwargs)[source]¶ Get a new Scale object with updated arguments.
Parameters: **kwargs (dict) – the new keyword values, when given these take precedence over the current ones. Returns: a new scale with updated values. Return type: Scale
-
visible_changes
(old_scale)[source]¶ Checks if there are any visible changes between this scale and the other.
This method can implement knowledge that allows the visualization routine to check if it would need to update the plot or not.
It expects that the scale you wish to use is the one on which this method is called.
Parameters: old_scale (Scale) – the previous scale Returns: if the differences between this scale and the other would result in visible differences. Return type: bool
-
-
class
mdt.visualization.maps.base.
SimpleConvertibleConfig
[source]¶ Bases:
object
Offers an simplified implementation of convertible configs.
In addition to slightly simplifying the creation of the conversion specification, it also implements object equality checking (__eq__ and__ne__) as this is commonly used in the configuration objects, and it offers a default representation (__repr__) implementation based on the conversion specification.
-
class
mdt.visualization.maps.base.
SimpleDataInfo
(maps)[source]¶ Bases:
mdt.visualization.maps.base.DataInfo
A container for basic information about the volume maps we are viewing.
Parameters: maps (dict) – the dictionary with the maps to view, these maps can either be arrays with values, nibabel proxy images or SingleMapInfo objects. -
classmethod
from_paths
(paths)[source]¶ Load all the nifti files from the given paths.
For paths that are directories we load all the elements inside that directory (but without recursion).
Parameters: of str (list) – the list of paths to load (directories and files) Returns: the simple data info Return type: SimpleDataInfo
-
get_bounding_box
(dimension, slice_index, volume_index, rotate, map_names=None)[source]¶ Get the bounding box of the images.
Parameters: - dimension (int) – the dimension to search in
- slice_index (int) – the slice index in that dimension
- volume_index (int) – the current volume index
- rotate (int) – the angle by which to rotate the image before getting the bounding box
- map_names (list of str) – if given we will only scan the given list of maps
Returns: - two point designating first the upper left corner and second the lower right corner of the
bounding box.
Return type: tuple of Point
-
get_file_path
(map_name)[source]¶ Get the file name of the given map
Returns: None if the map could not be found on dir, else a string with the file path.
-
get_file_paths
()[source]¶ Get the file paths to each of the maps.
If one of the maps does not have a file path, None is returned.
Returns: mapping map names to the file paths for each of the maps in this information container. Return type: dict
-
get_index_first_non_zero_slice
(dimension, map_names=None)[source]¶ Get the index of the first non zero slice in the maps.
Parameters: - dimension (int) – the dimension to search in
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the slice index with the first non zero values.
Return type: int
-
get_map_data
(map_name)[source]¶ Get the data for the indicated map.
Parameters: map_name (str) – the name of the map we want the data of Returns: the data of the given map Return type: ndarray
-
get_map_names
()[source]¶ Get a list of the names of all the maps in this data info object.
Returns: the list of map names Return type: list
-
get_max_dimension
(map_names=None)[source]¶ Get the minimum of the maximum dimension index over the maps
Parameters: map_names (list of str) – if given we will only scan the given list of maps Returns: either, 0, 1, 2 as the maximum dimension index in the maps. Return type: int
-
get_max_slice_index
(dimension, map_names=None)[source]¶ Get the maximum slice index in the given map on the given dimension.
Parameters: - dimension (int) – the dimension we want the slice index of (maximum 3)
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the minimum of the maximum slice indices over the given maps in the given dimension.
Return type: int
-
get_max_volume_index
(map_names=None)[source]¶ Get the maximum volume index in the given maps.
In contrast to the max dimension and max slice index functions, this gives the maximum over all the images. This since handling different volumes is implemented in the viewer.
Parameters: map_names (list of str) – if given we will only scan the given list of maps Returns: the maximum volume index in the given list of maps. Starts from 0. Return type: int
-
get_max_x_index
(dimension, rotate=0, map_names=None)[source]¶ Get the maximum x index supported over the images.
In essence this gets the lowest x index found.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the rotation factor by which we rotate the slices within the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the maximum x-index found.
Return type: int
-
get_max_y_index
(dimension, rotate=0, map_names=None)[source]¶ Get the maximum y index supported over the images.
In essence this gets the lowest y index found.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the rotation factor by which we rotate the slices within the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: the maximum y-index found.
Return type: int
-
get_single_map_info
(map_name)[source]¶ Get an information object for a single map.
Parameters: map_name (str) – the name of the map we want information about Returns: information object about that map Return type: SingleMapInfo
-
get_updated
(updates=None, removals=None)[source]¶ Get a new simple data info object that includes the given new maps.
In the case of double map names the old maps are overwritten.
Parameters: - updates (dict) – the dictionary with the maps to view, these maps can either be arrays with values, nibabel proxy images or SingleMapInfo objects.
- removals (list) – a list of maps to remove
Returns: a new updated data info object
Return type:
-
slice_has_data
(dimension, slice_index, map_names=None)[source]¶ Check if at least one of the maps has non zero numbers on the given slice.
Parameters: - dimension (int) – the dimension to search in
- slice_index (int) – the index of the slice in the given dimension
- map_names (list of str) – if given we will only scan the given list of maps
Returns: true if at least on of the maps has data in the given slice
Return type: bool
-
classmethod
-
class
mdt.visualization.maps.base.
SingleMapConfig
(title=None, scale=None, clipping=None, colormap=None, colormap_masked_color=None, colorbar_label=None, show_title=None, title_spacing=None, mask_name=None, interpret_as_colormap=False, colormap_weight_map=None, colormap_order=None, colorbar_settings=None)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Creates the configuration for a single map plot.
Parameters: - title (str) – the title of this plot, can contain latex using the matplotlib latex syntax
- scale (Scale) – the scaling for the values in this map
- clipping (Clipping) – the clipping to apply to the values prior to plotting
- colormap (str) – the matplotlib colormap to use
- colormap_masked_color (str) – the color for masked, NaN and infinity values.
- colorbar_label (str) – the label for the colorbar
- show_title (boolean) – if we want to show the title or not
- title_spacing (float) – the spacing between the top of the plots and the title
- mask_name (str) – the name of the mask used to mask the data prior to visualization
- interpret_as_colormap (boolean) – if this is set to True and the referring map is a 4d volume with a vector of length 3 on the last dimension, then we can interpret this map as a colormap. This means that the elements of the last dimensions are used as (R, G, B) scalar values.
- colormap_weight_map (str) – the name of another map to use as a scaling factor for this map. This is only
used when
interpret_as_colormap
is set to True. This scales this map with the specified weight map. - colormap_order (str) – only used if
interpret_as_colormap
is used. This defines the order of the RGB components of the data. Valid strings are permutations of the letters RGB. - colorbar_settings (ColorbarSettings) – all colorbar related settings
-
to_dict
(non_default_only=False)[source]¶ Export this configuration to a dictionary
Parameters: non_default_only (boolean) – if True, we will only export those options that are not set to their default. Returns: dict representation of the data Return type: dict
-
to_yaml
(non_default_only=False)[source]¶ Convert this configuration to a YAML string.
Parameters: non_default_only (boolean) – if True, we will only export those options that are not set to their default. Returns: a YAML representation of this configuration. Return type: str
-
visible_changes
(old_config)[source]¶ Checks if there are any visible changes between this configuration and the other.
This method can implement knowledge that allows the visualization routine to check if it would need to update the plot or not.
It expects that the configuration you wish to display is the one on which this method is called.
Parameters: old_config (SingleMapConfig) – the previous configuration Returns: if the differences between this configuration and the other would result in visible differences. Return type: bool
-
class
mdt.visualization.maps.base.
SingleMapInfo
(data, file_path=None)[source]¶ Bases:
object
Holds information about a single map.
Parameters: - data (ndarray or
nibabel.spatialimages.SpatialImage
) – the value of the map or the proxy to it - file_path (str) – optionally, the file path with the location of this map.
If not set we try to retreive it from the data if the data is of subclass
mdt.lib.nifti.NiftiInfoDecorated
.
-
data
¶
-
file_path
¶
-
get_bounding_box
(dimension, slice_index, volume_index, rotate)[source]¶ Get the bounding box of this map when displayed using the given indicing.
This only works if the edges of the images are exactly zero, that is, it only works with masked datasets.
Parameters: - dimension (int) – the dimension to search in
- slice_index (int) – the slice index in that dimension
- volume_index (int) – the current volume index
- rotate (int) – the angle by which to rotate the image before getting the bounding box
Returns: - two point designating first the upper left corner and second the lower right corner of the
bounding box.
Return type: tuple of Point
-
get_index_first_non_zero_slice
(dimension)[source]¶ Get the index of the first non zero slice in this map.
Parameters: dimension (int) – the dimension to search in Returns: the slice index with the first non zero values. Return type: int
-
get_max_x_index
(dimension, rotate=0)[source]¶ Get the maximum x index.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the value by which to rotate the slices in the given dimension
Returns: the maximum x index
Return type: int
-
get_max_y_index
(dimension, rotate=0)[source]¶ Get the maximum y index.
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the value by which to rotate the slices in the given dimension
Returns: the maximum y index
Return type: int
-
get_size_in_dimension
(dimension, rotate=0)[source]¶ Get the shape of the 2d view on the data in the given dimension.
This basically returns a pair of (max_x, max_y).
Parameters: - dimension (int) – the dimension to search in
- rotate (int) – the value by which to rotate the slices in the given dimension
Returns: (max_x, max_y)
Return type: tuple
-
has_nan
()[source]¶ Check if this data has any NaNs in it.
Returns: True if there are NaN’s anywhere in the data, false otherwise. Return type: boolean
-
max
(mask=None)[source]¶ Get the maximum value in this data.
If a mask is provided we get the maximum value within the given mask.
Parameters: mask (ndarray) – the mask, we only include elements for which the mask > 0 Returns: the maximum value Return type: float
-
max_dimension
()[source]¶ Get the maximum dimension index in this map.
The maximum value returned by this method is 2 and the minimum is 0.
Returns: in the range 0, 1, 2 Return type: int
-
max_slice_index
(dimension)[source]¶ Get the maximum slice index on the given dimension.
Parameters: dimension (int) – the dimension we want the slice index of (maximum 3) Returns: the maximum slice index in the given dimension. Return type: int
-
max_volume_index
()[source]¶ Get the maximum volume index in this map.
The minimum is 0.
Returns: the maximum volume index. Return type: int
-
min
(mask=None)[source]¶ Get the minimum value in this data.
If a mask is provided we get the minimum value within the given mask.
Parameters: mask (ndarray) – the mask, we only include elements for which the mask > 0 Returns: the minimum value Return type: float
-
min_max
(mask=None)[source]¶ Get the minimum and maximum value in this data.
If a mask is provided we get the min and max value within the given mask.
Infinities and NaN’s are ignored by this algorithm.
Parameters: mask (ndarray) – the mask, we only include elements for which the mask > 0 Returns: (min, max) the minimum and maximum values Return type: tuple
-
shape
¶
-
slice_has_data
(dimension, slice_index)[source]¶ Check if this map has non zero values in the given slice index.
Parameters: - dimension (int) – the dimension we want the slice index of (maximum 3)
- slice_index (int) – the slice index to look in
Returns: the maximum slice index in the given dimension.
Return type: int
- data (ndarray or
-
class
mdt.visualization.maps.base.
VoxelAnnotation
(voxel_index, font_size=None, text_template=None, marker_size=1, text_location='upper left', text_distance=0.05, arrow_width=1)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for all voxel highlighting settings.
Parameters: - voxel_index (tuple) – a tuple with the voxel index location
- font_size (int) – the size of the annotation text
- text_template (str) – the text template, can use the placeholders
{voxel_index}
and{value}
. - marker_size (float) – the rectangular size of the voxel marker
- text_location (str) – the location of the text. Valid items are:
upper left
,top left
,upper right
,top right
,bottom right
,lower right
,bottom left
,lower left
,north
,south
,east
,west
,top
,bottom
,left
,right
. - text_distance (float) – the distance of the textbox to the marker in relative coordinates (0, 1).
- arrow_width (float) – the width of the arrow
-
valid_text_locations
= ['upper left', 'top left', 'upper right', 'top right', 'bottom right', 'lower right', 'bottom left', 'lower left', 'north', 'south', 'east', 'west', 'top', 'bottom', 'left', 'right']¶
-
class
mdt.visualization.maps.base.
Zoom
(p0, p1)[source]¶ Bases:
mdt.visualization.maps.base.SimpleConvertibleConfig
Container for zooming a map between the two given points.
Parameters: -
apply
(data)[source]¶ Apply the zoom to the given 2d array and return the new array.
Parameters: data (ndarray) – the data to zoom in on
-
get_rotated
(rotation, x_dimension, y_dimension)[source]¶ Return a new Zoom instance rotated with the given factor.
This rotates the zoom box in the same way as the image is rotated.
Parameters: - rotation (int) – the rotation by which to rotate in steps of 90 degrees
- x_dimension (int) – the dimension of the image in the x coordinate
- y_dimension (int) – the dimension of the image in the y coordinate
Returns: the rotated instance
Return type:
-
mdt.visualization.maps.matplotlib_renderer module¶
-
class
mdt.visualization.maps.matplotlib_renderer.
AxisData
(axis, map_name, map_info, plot_config)[source]¶ Bases:
object
Contains a reference to a drawn matpotlib axis and to the accompanying data.
Parameters: - axis (Axis) – the matpotlib axis
- map_name (str) – the name/key of this map
- map_info (mdt.visualization.maps.base.SingleMapInfo) – the map information
- plot_config (mdt.visualization.maps.base.MapPlotConfig) – the map plot configuration
-
class
mdt.visualization.maps.matplotlib_renderer.
MapsVisualizer
(data_info, figure)[source]¶ Bases:
object
-
render
(plot_config)[source]¶ Render all the maps to the figure. This is for use in GUI embedded situations.
Returns: the list with the drawn axes and the accompanying data Return type: list of AxisData
-
show
(plot_config, block=True, maximize=False, window_title=None)[source]¶ Show the data contained in this visualizer using the specifics in this function call.
Parameters: - plot_config (mdt.visualization.maps.base.MapPlotConfig) – the plot configuration
- block (boolean) – If we want to block after calling the plots or not. Set this to False if you do not want the routine to block after drawing. In doing so you manually need to block.
- maximize (boolean) – if we want to display the window maximized or not
- window_title (str) – the title of the window. If None, the default title is used
-
-
class
mdt.visualization.maps.matplotlib_renderer.
Renderer
(data_info, figure, plot_config)[source]¶ Bases:
object
Create a new renderer for the given volumes on the given figure using the given configuration.
This renders the images with flipped upside down with the origin at the bottom left. The upside down flip is necessary to allow counter-clockwise rotation.
Parameters: - data_info (DataInfo) – the information about the maps to show
- figure (Figure) – the matplotlib figure to draw on
- plot_config (mdt.visualization.maps.base.MapPlotConfig) – the plot configuration
mdt.visualization.maps.utils module¶
-
mdt.visualization.maps.utils.
find_all_nifti_files
(paths)[source]¶ Find the paths to the nifti files in the given paths.
For directories we add all the nifti files from that directory, for file we try to resolve them to nifti files.
Parameters: paths (list of str) – the list of file paths Returns: the list of all nifti files (no more directories) Return type: list of str
-
mdt.visualization.maps.utils.
get_shortest_unique_names
(paths)[source]¶ Get the shortest unique map name between two or more nifti file paths.
This function is useful when loading multiple maps like for example
./foo.nii
and./foo.nii.gz
or../directory0/foo.nii
and../directory1/foo.nii
. In all cases the map name (foo) is similar, but we want to be able to show them distinctly. This function tries to find the shortest unique map names for each of the maps.Example output: * [
./foo.nii
] ->foo
* [./foo.nii
,./foo.nii.gz
] -> [foo.nii
,foo.nii.gz
] * [../directory0/foo.nii
,../directory1/foo.nii
] -> [directory0/foo
,directory1/foo
]Parameters: paths (list of str) – the paths to the different nifti files Returns: the map names for the given set of paths (in the same order) Return type: tuple