{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Tutorial 4: Layouts and Views\n\nThis tutorial covers the layout and view options provided by ``surfplot``.\n\nFor variety, let's import the left and right Conte69 midthickness surface\ndirectly using :func:`~brainspace.datasets.load_conte69`. Then, we'll make a \nblank surface plot using the default layout and view, which is a 2x2 'grid' of \nlateral and medial views that is identical to the default setup in Connectome \nWorkbench.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from brainspace.datasets import load_conte69\nfrom surfplot import Plot\n\nlh, rh = load_conte69()\np = Plot(lh, rh)\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Layout\n\nThe layout can be adjusted with the `layout` parameter, and has 3 options: \n'grid' (default, shown above), 'row', or 'column'. The `size` and `zoom` \nparameters will have to be adjusted based on the layout and number of views. \n\nAbove we see that 'grid' gives us a views-by-hemisphere grid, where the left\nhemisphere is the left column and the right hemisphere is the right column. \nMeanwhile, the 'row' layout gives a single horizontal row of brains: \n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(800, 200), zoom=1.2, layout='row')\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The 'column' layout gives a single vertical column of brains.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(200, 600), zoom=1.6, layout='column')\nfig = p.build()\nfig.show()\n# sphinx_gallery_thumbnail_number = 3"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "As well, it's also possible to plot just one hemisphere. If the layout is \nset as default ('grid'), then a single hemisphere is plotted as row:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, size=(400, 200), zoom=1.2)\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Views\n\n``surfplot`` makes it easy to configure the view(s) you wish to use. One or\nmore views can be specified through the `views` parameter. As we've seen \nbefore, the default is to include lateral and medial views. It is also \npossible to show just one view:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(400, 200), zoom=1.2, views='lateral')\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "It is also possible to show more than just lateral and medial views, such\nas 'posterior'. Note that views are plotted in order in which they appear\nin the list:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(500, 400), zoom=1.4,  views=['lateral', 'posterior'])\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "All possible views are shown here (the right hemisphere for brevity):\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "all_views = ['lateral', 'medial', 'dorsal', 'ventral', 'anterior', 'posterior']\np = Plot(surf_rh=rh, size=(900, 200), zoom=.8, layout='row', views=all_views)\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Views can also be mirrored when both hemipsheres are plotted and `layout` is \neither 'row' or 'column'. Specifically, the right hemisphere view order is\nreversed. For example, plotting default lateral and medial views and setting \n`mirror_views=True` will situate the medial views in the middle for a \nsymmetrical figure: \n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(800, 200), zoom=1.2, layout='row', mirror_views=True)\nfig = p.build()\nfig.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Finally, it is possible to flip the left and right hemisphere. This is \nuseful when plotting just the 'anterior' or 'ventral' for both hemispheres.\nFor example: \n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "p = Plot(lh, rh, size=(200, 200), zoom=3, views='anterior', flip=True)\nfig = p.build()\nfig.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}