Mosaic plotΒΆ

The function mosaic plots all of the slices in a volume in a matplotlib figure. Good for quick visualization or testing of volumes.

  • plot mosaic
  • plot mosaic
  • plot mosaic


/home/travis/build/gallantlab/pycortex/examples/utils/ DeprecationWarning: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
  volume_arr = cortex.db.get_xfm('S1', 'fullhead').reference.get_data().T

# sphinx_gallery_thumbnail_number = 3

import cortex
import matplotlib.pyplot as plt

# load reference functional image for test purposes
volume_arr = cortex.db.get_xfm('S1', 'fullhead').reference.get_data().T
# volume_arr is a (31,100,100) ndarray

# with no args mosaic slices this volume in the first dimension

# slices along a different dimension can be plotted using the dim param
# here coronal
cortex.mosaic(volume_arr, dim=1)

# kwargs are passed through to imshow
cortex.mosaic(volume_arr,, vmin=0, vmax=1500)

# mosaic always returns the mosaic image along with info about its shape
# here show=False so we don't generate another plot
mosaic_arr, (nwide, ntall) = cortex.mosaic(volume_arr, show=False)
# mosaic_arr is 607 x 607, with nwide = 6, ntall = 6

Total running time of the script: ( 0 minutes 0.331 seconds)

Gallery generated by Sphinx-Gallery