cmind.utils.image_utils¶
Image Utilities A series of utilities for working with images (.gif, .png, etc)
Functions
ImageMagick_append_label (input_image, ...[, ...]) |
Append a label to the top, bottom, right or left of an image |
ImageMagick_build_colorbar (output_img[, ...]) |
Append a label to the top, bottom, right or left of an image |
ImageMagick_crop_border (input_image[, ...]) |
Trim borders from an image |
ImageMagick_get_size (image_file) |
Returns size of an image as [width,height] |
ImageMagick_resize (input_image, pct[, ...]) |
Resize an image |
cmind_dual_func_overlay (bg_image, ...[, ...]) |
utility to overlay both positive and negative activations on a single |
designmat_plot (dm[, col_width_pixels, ...]) |
|
mpl_white_on_black (f) |
convert matplotlib figure to white text on black bacground |
random_color_str ([cmin, cmax]) |
return a randomized RGB hex color string “#{RRGGBB}” for use in a graphviz .dot file. |
set_backgroundcolor (ax, color) |
Sets the background color of the current axes (and legend). |
set_foregroundcolor (ax, color) |
For the specified axes, sets the color of the frame, major ticks, |
slicer_3plane_fig (input_volume[, istr, ...]) |
Use FSL’s slicer to generate a center slice in each image plane |
slicer_mid_sag_fig (input_volume[, istr, ...]) |
Use FSL’s slicer to generate a mid-sagittal image |
slicer_tile_slices (input_volume[, ...]) |
Use FSL’s slicer to create a mosaic of axial images |
-
cmind.utils.image_utils.
slicer_3plane_fig
(input_volume, istr='', output_image=None, verbose=False, logger=None)[source]¶ Use FSL’s slicer to generate a center slice in each image plane
Parameters: input_volume : str
filename of input volume
istr : str, optional
optional string containing additional command line arguments
output_image : str, optional
override default filename for output image with this one
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
Returns: output_image : str
filename of the generated image
-
cmind.utils.image_utils.
slicer_mid_sag_fig
(input_volume, istr='', output_image=None, verbose=False, logger=None)[source]¶ Use FSL’s slicer to generate a mid-sagittal image
Parameters: input_volume : str
filename of input volume
istr : str, optional
optional string containing additional command line arguments
output_image : str, optional
override default filename for output image with this one
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
Returns: output_image : str
filename of the generated image
-
cmind.utils.image_utils.
slicer_tile_slices
(input_volume, optional_args='', slice_skip=1, width=800, output_image=None, verbose=False, logger=None)[source]¶ Use FSL’s slicer to create a mosaic of axial images
Parameters: input_volume : str
filename of input volume
optional_args : str, optional
optional string containing additional command line arguments
slice_skip : int, optional
slice skip factor
width : int, optional
width of the mosaic in pixels
output_image : str, optional
override default filename for output image with this one
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
Returns: output_image : str
filename of the generated image
-
cmind.utils.image_utils.
ImageMagick_get_size
(image_file)[source]¶ Returns size of an image as [width,height]
Parameters: image_file : str
image file to query
Returns: size_list : list
[width, height] as floats
-
cmind.utils.image_utils.
ImageMagick_build_colorbar
(output_img, cbar_input_img=None, cbar_label=['low', 'high'], rotate_cbar_img=0, vertical_cbar=False, cbar_input_resize_pct=200, bg_color='black', text_color='white', pointsize=None, verbose=False, logger=None)[source]¶ Append a label to the top, bottom, right or left of an image
Parameters: output_img : str
output filename for the colorbar image
cbar_input_img : str
filename of the colorbar image (without labels)
cbar_label : str, optional
2-element list corresponding to the labels for the (low,high) ends of the colorbar
rotate_cbar_img : float, optional
if > 0, the colorbar image will be rotated by this amount
vertical_cbar : bool, optional
if true, the colorbar labels will be stacks above/below the colorbar instead of left/right
cbar_input_resize_pct : int, optional
percentage by which to resize cbar_input_img
bg_color : str, optional
color of the label background
text_color : str, optional
color of the label text
pointsize : int, optional
pointsize of the label text. If unspecified, will match size of the colorbar
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
-
cmind.utils.image_utils.
ImageMagick_crop_border
(input_image, output_image=None, verbose=False, logger=None)[source]¶ Trim borders from an image
Parameters: input_image : str
filename for the input image
output_image : str, optional
filename for the output image
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
-
cmind.utils.image_utils.
ImageMagick_append_label
(input_image, title_string, output_image=None, position='top', bg_color='black', text_color='white', pointsize=90, colorspace='sRGB', verbose=False, logger=None)[source]¶ Append a label to the top, bottom, right or left of an image
Parameters: input_image : str
filename for the input image
label_string : str
text for the label
output_image : str, optional
filename for the output image
bg_color : str, optional
color of the label background
text_color : str, optional
color of the label text
position : str, {‘top’,’bottom’,’left’,’right’}
controls the position or the label. If ‘left’ or ‘right’ label text will run vertically.
pointsize : int, optional
pointsize of the label text
colorspace : str, optional
modify colorspace of image. default = sRGB
verbose : bool, optional
print additional output (to terminal and log)
logger : logging.Logger or str, optional
logging.Logger object (or string of a filename to log to)
-
cmind.utils.image_utils.
random_color_str
(cmin=0, cmax=14737632)[source]¶ return a randomized RGB hex color string “#{RRGGBB}” for use in a graphviz .dot file.
Parameters: cmin : int, optional
minimum allowed RGB color: must be in range [0x00000 0xffffff] (R, G, B can each range from 0x00 to 0xff corresponding to the integer range [0 255])
cmax : int, optional
maximum allowed color: must be in range [0x00000 0xffffff]
Returns: color_code : str
color code string for use in graphviz .dot files