.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/shortclips/00_setup_colab.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_shortclips_00_setup_colab.py: ================== Setup Google Colab ================== In this script, we setup a Google Colab environment. This script will only work when run from `Google Colab `_). You can skip it if you run the tutorials on your machine. .. GENERATED FROM PYTHON SOURCE LINES 10-10 .. code-block:: Python :dedent: 1 .. GENERATED FROM PYTHON SOURCE LINES 12-20 Change runtime to use a GPU --------------------------- This tutorial is much faster when a GPU is available to run the computations. In Google Colab you can request access to a GPU by changing the runtime type. To do so, click the following menu options in Google Colab: (Menu) "Runtime" -> "Change runtime type" -> "Hardware accelerator" -> "GPU". .. GENERATED FROM PYTHON SOURCE LINES 22-26 Download the data and install all required dependencies ------------------------------------------------------- Uncomment and run the following cell to download the required packages. .. GENERATED FROM PYTHON SOURCE LINES 26-34 .. code-block:: Python #!git config --global user.email "you@example.com" && git config --global user.name "Your Name" #!wget -O- http://neuro.debian.net/lists/jammy.us-ca.libre | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list #!apt-key adv --recv-keys --keyserver hkps://keyserver.ubuntu.com 0xA5D32F012649A5A9 > /dev/null #!apt-get -qq update > /dev/null #!apt-get install -qq inkscape git-annex-standalone > /dev/null #!pip install -q voxelwise_tutorials .. GENERATED FROM PYTHON SOURCE LINES 35-36 For the record, here is what each command does: .. GENERATED FROM PYTHON SOURCE LINES 36-44 .. code-block:: Python # - Set up an email and username to use git, git-annex, and datalad (required to download the data) # - Add NeuroDebian to the package sources # - Update the gpg keys to use NeuroDebian # - Update the list of available packages # - Install Inkscape to use more features from Pycortex, and install git-annex to download the data # - Install the tutorial helper package, and all the required dependencies .. GENERATED FROM PYTHON SOURCE LINES 45-55 .. code-block:: Python try: import google.colab # noqa in_colab = True except ImportError: in_colab = False if not in_colab: raise RuntimeError("This script is only meant to be run from Google " "Colab. You can skip it if you run the tutorials " "on your machine.") .. GENERATED FROM PYTHON SOURCE LINES 56-57 Now run the following cell to download the data for the tutorials. .. GENERATED FROM PYTHON SOURCE LINES 57-77 .. code-block:: Python from voxelwise_tutorials.io import download_datalad DATAFILES = [ "features/motion_energy.hdf", "features/wordnet.hdf", "mappers/S01_mappers.hdf", "responses/S01_responses.hdf", ] source = "https://gin.g-node.org/gallantlab/shortclips" destination = "/content/shortclips" for datafile in DATAFILES: local_filename = download_datalad( datafile, destination=destination, source=source ) .. GENERATED FROM PYTHON SOURCE LINES 78-80 Now run the following cell to set up the environment variables for the tutorials and pycortex. .. GENERATED FROM PYTHON SOURCE LINES 80-87 .. code-block:: Python import os os.environ['VOXELWISE_TUTORIALS_DATA'] = "/content" import sklearn sklearn.set_config(assume_finite=True) .. GENERATED FROM PYTHON SOURCE LINES 88-89 Your Google Colab environment is now set up for the voxelwise tutorials. .. _sphx_glr_download__auto_examples_shortclips_00_setup_colab.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00_setup_colab.ipynb <00_setup_colab.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00_setup_colab.py <00_setup_colab.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_