View

A simple viewer.

The idea is for this to be really simple to use. It will do a lot of guessing if you don’t provide it with details. For example, if a 3D dataset is provided as the image and you don’t say which axes are in-plane, it will guess that the largest two axis are in-plane. If the 3rd dimension is small, then it will choose to view the images as a montage, if it is large it will play it as a movie. Of course there are many options if you know what you’re doing (and I do, since I wrote it…).

Fourier transforms, logarithmic scale, coil combination, averaging, and converting from raw data are all supported out of the box.

mr_utils.view.view.mat_keys(filename, ignore_dbl_underscored=True, no_print=False)[source]

Give the keys found in a .mat.

Parameters:
  • filename (str) – .mat filename.
  • ignore_dbl_underscored (bool, optional) – Remove keys beginng with two underscores.
  • no_print (bool, optional) – Don’t print out they keys.
Returns:

keys – Keys present in dictionary of read in .mat file.

Return type:

list

mr_utils.view.view.view(image, load_opts=None, is_raw=None, is_line=None, prep=None, fft=False, fft_axes=None, fftshift=None, avg_axis=None, coil_combine_axis=None, coil_combine_method='walsh', coil_combine_opts=None, is_imspace=False, mag=None, phase=False, log=False, imshow_opts={'cmap': 'gray'}, montage_axis=None, montage_opts={'padding_width': 2}, movie_axis=None, movie_interval=50, movie_repeat=True, save_npy=False, debug_level=10, test_run=False)[source]

Image viewer to quickly inspect data.

Parameters:
  • image (str or array_like) – Name of the file including the file extension or numpy array.
  • load_opts (dict, optional) – Options to pass to data loader.
  • is_raw (bool, optional) – Inform if data is raw. Will attempt to guess from extension.
  • is_line (bool, optional) – Whether or not this is a line plot (as opposed to image).
  • prep (callable, optional) – Lambda function to process the data before it’s displayed.
  • fft (bool, optional) – Whether or not to perform n-dimensional FFT of data.
  • fft_axes (tuple, optional) – Axis to perform FFT over, determines dimension of n-dim FFT.
  • fftshift (bool, optional) – Whether or not to perform fftshift. Defaults to True if fft.
  • avg_axis (int, optional) – Take average over given set of axes.
  • coil_combine_axis (int, optional) – Which axis to perform coil combination over.
  • coil_combine_method ({'walsh', 'inati', 'pca'}, optional) – Method to use to combine coils.
  • coil_combine_opts (dict, optional) – Options to pass to the coil combine method.
  • is_imspace (bool, optional) – Whether or not the data is in image space. For coil combine.
  • mag (bool, optional) – View magnitude image. Defaults to True if data is complex.
  • phase (bool, optional) – View phase image.
  • log (bool, optional) – View log of magnitude data. Defaults to False.
  • imshow_opts (dict, optional) – Options to pass to imshow. Defaults to { ‘cmap’=’gray’ }.
  • montage_axis (int, optional) – Which axis is the number of images to be shown.
  • montage_opts (dict, optional) – Additional options to pass to the skimage.util.montage.
  • movie_axis (int, optional) – Which axis is the number of frames of the movie.
  • movie_interval (int, optional) – Interval to give to animation frames.
  • movie_repeat (bool, optional) – Whether or not to put movie on endless loop.
  • save_npy (bool, optional) – Whether or not to save the output as npy file.
  • debug_level (logging_level, optional) – Level of verbosity. See logging module.
  • test_run (bool, optional) – Doesn’t show figure, returns debug object. Mostly for testing.
Returns:

  • data (array_like) – Image data shown in plot.
  • dict, optional – All local variables when test_run=True.

Raises:
  • Exception – When file type is not in [‘dat’, ‘npy’, ‘mat’, ‘h5’].
  • ValueError – When coil combine requested, but fft_axes not set.
  • AssertionError – When Walsh coil combine requested but len(fft_axes) =/= 2.
  • ValueError – When there are too many dimension to display.