### Install IPython Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Installs IPython, a prerequisite for running the pycortex demo. ```bash pip install ipython ``` -------------------------------- ### Start Freesurfer Environment Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Shell command to source the Freesurfer setup script, initializing the environment for Freesurfer commands. Requires the path to the Freesurfer installation. ```bash source_directory_name_here/SetUpFreeSurfer.sh ``` -------------------------------- ### Install Development PyCortex from GitHub Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Installs the development version of pycortex directly from its GitHub repository using pip. ```bash pip install -U git+https://github.com/gallantlab/pycortex.git ``` -------------------------------- ### Install Stable PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Installs the latest stable release of pycortex and its required dependencies (setuptools, wheel, numpy, cython) using pip. ```bash pip install -U setuptools wheel numpy cython pip install -U pycortex ``` -------------------------------- ### Run PyCortex Demo Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Executes the pycortex demo by importing the library and generating a random volume using IPython. ```python import cortex cortex.webshow(cortex.Volume.random("S1", "fullhead")) ``` -------------------------------- ### Compile and Install OpenCTM on Ubuntu Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Sequence of commands to compile and then perform a system-wide installation of OpenCTM on Ubuntu. ```bash make -f Makefile.linux sudo make -f Makefile.linux install ``` -------------------------------- ### Compile and Install OpenCTM on Mac OS X Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Sequence of commands to compile and then perform a system-wide installation of OpenCTM on Mac OS X. ```bash make -f Makefile.macosx sudo make -f Makefile.macosx install ``` -------------------------------- ### Install IPython Source: https://github.com/gallantlab/pycortex/blob/main/README.md Installs the IPython interactive shell, which is recommended for using Pycortex. ```bash pip install ipython ``` -------------------------------- ### Install Pycortex Development Version Source: https://github.com/gallantlab/pycortex/blob/main/README.md Installs the development version of pycortex directly from GitHub using pip. This command fetches the latest code and installs it without building isolation. ```bash # Install development version of pycortex from github pip install -U git+https://github.com/gallantlab/pycortex.git --no-build-isolation ``` -------------------------------- ### Install Pycortex Stable Release Source: https://github.com/gallantlab/pycortex/blob/main/README.md Installs the stable release version of pycortex and its required dependencies using pip. This includes setuptools, wheel, numpy, and cython. ```bash # First, install some required dependencies (if not already installed) pip install -U setuptools wheel numpy cython # Install the latest release of pycortex from pip pip install -U pycortex ``` -------------------------------- ### Build Pycortex Documentation Locally Source: https://github.com/gallantlab/pycortex/blob/main/README.md Installs Sphinx Gallery and Numpydoc for documentation generation, then navigates to the docs folder and builds the HTML documentation site using make html. ```bash # Install required dependencies for the documentation pip install sphinx_gallery numpydoc # Move into the docs folder (assuming already in pycortex directory) cd docs # Build a local version of the documentation site make html ``` -------------------------------- ### Check PyCortex User Configuration File Location Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Retrieves and prints the location of the user-specific configuration file for pycortex. ```python import cortex cortex.options.usercfg ``` -------------------------------- ### Check PyCortex Filestore Location Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Retrieves and prints the default filestore location for pycortex after installation. ```python import cortex cortex.database.default_filestore ``` -------------------------------- ### Configure PyCortex Filestore Location Source: https://github.com/gallantlab/pycortex/blob/main/docs/install.rst Updates the pycortex user configuration file to specify an alternate location for the database filestore. ```ini [basic] filestore=/abs/path/to/filestore ``` -------------------------------- ### Load Data from HDF File (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Provides an example of loading a Dataset object from a previously saved HDF file. ```Python ds = cortex.load("test_data.hdf") ``` -------------------------------- ### PyCortex Subject Database Structure Example Source: https://github.com/gallantlab/pycortex/blob/main/docs/database.rst Illustrates the directory structure of a pycortex subject database entry, showing the organization of anatomical data, cache files, overlays, ROIs, surfaces, and transforms. ```shell filestore/db └── S1 ├── anatomicals │   └── raw.nii.gz ├── cache │   ├── flatmask_1024.npz │   ├── flatpixel_fullhead_1024_nearest_l32.npz │   ├── flatverts_1024.npz │   └── fullhead_linenn.npz ├── overlays.svg ├── rois.svg ├── surface-info │   ├── distortion[dist_type=areal].npz │   └── distortion[dist_type=metric].npz ├── surfaces │   ├── flat_lh.gii │   ├── flat_rh.gii │   ├── inflated_lh.gii │   ├── inflated_rh.gii │   ├── pia_lh.gii │   ├── pia_rh.gii │   ├── wm_lh.gii │   └── wm_rh.gii ├── transforms │   ├── fullhead │   │   ├── matrices.xfm │   │   └── reference.nii.gz │   └── retinotopy │   ├── matrices.xfm │   └── reference.nii.gz └── views ``` -------------------------------- ### Compile OpenCTM on Windows (MinGW32) Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to compile the OpenCTM package on Windows using MinGW32 by specifying the appropriate Makefile. ```bash mingw32-make -f Makefile.mingw ``` -------------------------------- ### Compile OpenCTM on OpenSolaris Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to compile the OpenCTM package on OpenSolaris using gmake and specifying the appropriate Makefile. ```bash gmake -f Makefile.linux ``` -------------------------------- ### Compile OpenCTM on Linux Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to compile the OpenCTM package on Linux by specifying the appropriate Makefile. ```bash make -f Makefile.linux ``` -------------------------------- ### Import NIfTI/MGZ Data into Freesurfer Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Freesurfer command to import NIfTI (.nii) or MGZ (.mgz) files for a new subject. It requires the file path and a subject name. ```bash recon-all -i /name/name/name/name.nii -s ``` -------------------------------- ### Run FreeSurfer Autorecon2 Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst This command initiates the FreeSurfer autorecon2 process, which is crucial for creating white and gray matter surfaces. The process can take several hours to complete. ```Shell recon-all -autorecon2 -s ``` -------------------------------- ### Compile OpenCTM on Windows (MS Visual Studio) Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to compile the OpenCTM package on Windows using MS Visual Studio (Express 2008) by specifying the appropriate Makefile. ```bash nmake /f Makefile.msvc ``` -------------------------------- ### Unpack Data with tar Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Command to unpack a .tar file into multiple dcm files for processing. This is the initial step for handling raw neuroimaging data. ```bash tar xvf filename.tar ``` -------------------------------- ### Volume Arithmetic (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Shows that Volume objects support standard numpy operations, using addition as an example. ```Python vol = cortex.Volume.empty(subject, xfmname) + 1 ``` -------------------------------- ### Compile OpenCTM on Mac OS X Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to compile the OpenCTM package on Mac OS X by specifying the appropriate Makefile. ```bash make -f Makefile.macosx ``` -------------------------------- ### Build OpenCTM Shared Library on Windows (MS Visual Studio) Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/COMPILING.txt Command to specifically build only the OpenCTM shared library on Windows with MS Visual Studio, using the 'openctm' build target. ```bash nmake /f Makefile.msvc openctm ``` -------------------------------- ### Run Freesurfer Autorecon1 Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Freesurfer command to perform initial anatomical processing, including motion correction, skull stripping, and Talairach transform computation. This step takes approximately 30-40 minutes. ```bash recon-all -autorecon1 -s ``` -------------------------------- ### Import DICOM Data into Freesurfer Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Freesurfer command to import DICOM files for a new subject. It requires the path to the first DICOM file and a subject name for directory creation. ```bash recon-all -i ./NameofFirstDicomFile.dcm -s ``` -------------------------------- ### Load Nifti and Quickshow (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Demonstrates loading data from a Nifti file aligned to a transform in the database and displaying it using cortex.quickshow. ```Python dv = cortex.Volume("path/to/nifti_file.nii.gz", "S1", "fullhead") cortex.quickshow(dv) ``` -------------------------------- ### Create and Show Dataset (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Demonstrates creating a Dataset object implicitly using a tuple syntax and displaying it using cortex.webshow. This is a quick way to visualize data. ```Python import cortex cortex.webshow((np.random.randn(31, 100, 100), "S1", "fullhead")) ``` -------------------------------- ### Initialize MRI Viewer and Graph Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/wngraph.html Sets up the MRI viewer and graph, loads CTM data, and configures a callback for voxel selection. It also integrates a custom graph plugin into the viewer. ```JavaScript var viewer, sock, gr; gr = setupGraph(); gr.setrgbdata(colordata); var wngraph = $("#wngraph-plugin").detach(); wngraph.css("visibility", "visible"); viewer = new MRIview(); viewer.load("{{ctmfile}}", function() { gr.viewer = viewer; viewer.picker.callback = function(idx) { console.log(idx); gr.showvoxel(idx); } }); viewer.addData(classify({{data}})); viewer.addPlugin(wngraph, true); ``` -------------------------------- ### JavaScript Initialization for PyCortex Viewer Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/wngraph-minimal.html Initializes the PyCortex 3D viewer, including setting up the graph object, loading the CTM model, and configuring user interaction callbacks. It handles URL parameter parsing to potentially display specific voxels or vertices and sets up initial camera states and animations. The code also includes event listeners for window resizing. ```javascript var viewer, sock, gr; gr = setupGraph(); gr.voxdir = '{{voxdir}}'; gr.subject = '{{subjectid}}'; gr.catmapdir = '{{catmapdir}}'; gr.setrgbdata(colordata); var wngraph = $("#wngraph-plugin").detach(); wngraph.css("visibility", "visible"); viewer = new MRIview(); viewer.load("{{ctmfile}}", function() { gr.viewer = viewer; viewer.picker.callback = gr.showvoxel.bind(gr); if (JSON.stringify($.getUrlVars()) == '["vox","vert"]') { var vox = $.getUrlVar("vox"); var vert = $.getUrlVar("vert"); viewer.picker.addMarker(vert, false); viewer.setMix(1.0); var vpos = viewer.getVert(vert).pos; viewer.setState("target", [vpos.y,vpos.x,vpos.z]); setTimeout(function() {gr.showvoxel(vox,vert);}, 1000); } else { setTimeout(function() { viewer.setMix(0.667); viewer.animate([{idx:3, state:"azimuth", value:310}, {idx:3, state:"altitude", value:120}, {idx:3, state:"mix", value:0.0}]); }, 1000); } }); viewer.addData(classify({{data}})); viewer.addPlugin(wngraph, true); window.addEventListener("resize", function() {$('#pluginbox').height($('window').height());}, false); ``` -------------------------------- ### Create Dataset Manually (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Shows how to manually create a Dataset object by passing a Volume object initialized with random data. ```Python ds = cortex.Dataset(name=(np.random.randn(31, 100, 100), "S1", "fullhead")) ``` -------------------------------- ### JavaScript Initialization and Event Handling Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This JavaScript code handles the initialization of the PyCortex interface. It populates a colormap name dictionary and sets up event listeners for UI elements like closing an introductory message and toggling a URL input field. ```JavaScript var cmapnames = {} $(document).ready(function() { $("#colormap option").each(function(idx) { cmapnames[$(this).text()] = idx; }); $("#introclose").click(function() { $("div#intro").toggle() }); $("#viewlink").click(function() { $("#linkurl").toggle().focus() }); }) ``` -------------------------------- ### Initialize PyCortex Viewer and Data Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/explo_demo.html Initializes the PyCortex viewer, sets up view options, loads subject data, and adds datasets. It includes event listeners for stimulus display and viewer loading, with error handling to reload the page. ```javascript try { viewopts = { voxlines: {{voxlines}}, voxline_width: {{voxline_width}}, default_2Dcmap: "RdBu_covar", }; subjects = {{subjects}}; for (var name in subjects) { subjects[name] = new mriview.Surface(subjects[name]); } figure = new jsplot.W2Figure(); viewer = figure.add(mriview.Viewer, "main", true); var drawer = viewer.drawView.bind(viewer); viewer.drawView = function(scene, idx) { try { drawer(scene, idx); } catch(e) { document.location.reload(true); } } var setData = viewer.setData.bind(viewer); viewer.setData = function(name) { try { setData(name); } catch (e) { document.location.reload(true); } } viewer.addEventListener("stimulus", function(evt) { var video = evt.object.movie; setTimeout(function() { if (video.networkState == video.NETWORK_NO_SOURCE) { document.location.reload(true); } }, 2000); }) dataviews = dataset.fromJSON({{data}}); viewer.addData(dataviews); $("#display_cover").on("click", demo.advance.bind(demo)); if (leapcontrol.connected) { demo.setLeap(); } viewer.loaded.done(function() { setTimeout(viewer.playpause.bind(viewer), 1000); }); } catch (e) { document.location.reload(true); } ``` -------------------------------- ### JavaScript Initialization Block Placeholder Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This is a placeholder comment indicating where JavaScript initialization code might be placed within a templating system, to be executed when the page is ready. ```JavaScript {% block jsinit %} {% end %} ``` -------------------------------- ### Initialize PyCortex Viewer Source: https://github.com/gallantlab/pycortex/blob/main/examples/webgl/my_template.html Initializes the PyCortex viewer, loads subjects and datasets, and sets up the main viewer component. It relies on external libraries like jsplot and mriview. ```javascript var viewer, subjects, datasets, figure, sock, viewopts; $(document).ready(function() { if (!validator.webgl) { $(".loadmsg").hide(); $("#ctmload").html("

Sorry, it seems you have no WebGL support. :(

If you are using Chrome, try ignoring the GPU blacklist.

").show(); } else if (!validator.vtex(3, 5)) { $(".loadmsg").hide(); $("#ctmload").html("

Sorry, your computer does not have the minimum number of texture units :(

Try upgrading your drivers and/or your browser

").show(); } else { viewopts = {{viewopts}}; subjects = {{subjects}}; for (var name in subjects) { subjects[name] = new mriview.Surface(subjects[name]); } figure = new jsplot.W2Figure(); viewer = figure.add(mriview.Viewer, "main", true); dataviews = dataset.fromJSON({{data}}); viewer.addData(dataviews); } }); ``` -------------------------------- ### OpenCTM Python Bindings and Demo Source: https://github.com/gallantlab/pycortex/blob/main/OpenCTM-1.0.3/README.txt OpenCTM includes Python bindings and a demo program, allowing users to interact with the OpenCTM format using Python. This enables scripting and automation of mesh compression tasks. ```Python # Demo Python program for OpenCTM # (Specific code not provided in the input text) ``` -------------------------------- ### Manual Brain Alignment GUI Source: https://github.com/gallantlab/pycortex/blob/main/docs/align.rst Starts the manual alignment GUI for fine-tuning the alignment of functional data to the brain surface mesh. This is typically used for the final adjustments after automatic alignment. ```python import cortex cortex.align.manual('S1', 'example-transform') ``` -------------------------------- ### Run Pycortex Demo with IPython Source: https://github.com/gallantlab/pycortex/blob/main/README.md Demonstrates how to use Pycortex within an IPython session. It imports the cortex library and uses it to display a random volume. ```ipython $ ipython In [1]: import cortex In [2]: cortex.webshow(cortex.Volume.random("S1", "fullhead")) ``` -------------------------------- ### Get PyCortex Default Filestore Path Source: https://github.com/gallantlab/pycortex/blob/main/docs/database.rst Retrieves the default location of the PyCortex filestore, which holds all data required for plotting on a cortical sheet. This path can be customized in the 'options.cfg' file. ```Python import cortex print(cortex.database.default_filestore) ``` -------------------------------- ### Browse PyCortex Database with IPython Tab Completion Source: https://github.com/gallantlab/pycortex/blob/main/docs/database.rst Demonstrates how to use IPython's tab completion to explore subjects, surfaces, and their properties within the PyCortex database. This method allows for interactive discovery of available data. ```Python import cortex cortex.db. # Press TAB to see subjects cortex.db.S1. # Press TAB to see surfaces and transforms for S1 cortex.db.S1.surfaces. # Press TAB to see surface types cortex.db.S1.surfaces.inflated.get() cortex.db.S1.surfaces.fiducial.show() ``` -------------------------------- ### JavaScript Event Listeners and Mobile Detection Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This snippet sets up event listeners for keyboard input (H for help, I for intro toggle) and mouse clicks on '#linkurl'. It also includes logic to detect mobile devices and display an error message if WebGL is not supported or if the device is mobile, directing users to alternative resources. ```JavaScript $("#linkurl").click(function(e) { e.stopPropagation(); }); window.addEventListener("keydown", function(e) { if (e.keyCode == 72) $("#helpmenu").css("opacity", $("#helpmenu").css("opacity") == 1 ? 0 : 1); if (e.keyCode == 73) $("div#intro").toggle(); }); if (mobile()) { $("#helpmenu").hide(); $("div#intro").hide(); $(".loadmsg").hide(); $("body").html("

Unfortunately, Android and iOS devices do not support WebGL. Please ask Apple and Google for WebGL support in their browsers!

For more information about the science, visit Berkeley News Center

").show(); } else if (!webgl()) { $(".loadmsg").hide(); $("#ctmload").html("

Sorry, it seems you have no WebGL support. :(

If you are using Chrome, try ignoring the GPU blacklist.

").show(); } else if (!vtex(4, 9)) { $(".loadmsg").hide(); $("#ctmload").html("

Sorry, your computer does not have the minimum number of texture units :(

Try upgrading your drivers and/or your browser"); } else { {% block onload %} {% end %} } ``` -------------------------------- ### Create Volume and Vertex Objects (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Details the call signatures for creating Volume and Vertex data view objects, including optional mask and keyword arguments. ```Python vol = cortex.Volume(nparray, subject, xfmname, mask=None, **kwargs) vert = cortex.Vertex(nparray, subject, **kwargs) ``` -------------------------------- ### Fix White Matter Surface with PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst Python command using the PyCortex library to fix the white matter surface segmentation for a given subject. This is typically done after Freesurfer's autorecon1 step. ```python import cortex cortex.segment.fix_wm(‘Subject’) ``` -------------------------------- ### Create Empty Volume (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Shows how to create an empty Volume object for a given subject and transformation name. ```Python vol = cortex.Volume.empty(subject, xfmname) ``` -------------------------------- ### Fix White Matter Surface in PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation_guide.rst This Python command within the PyCortex library is used to correct significant errors in the white matter surface segmentation generated by FreeSurfer's autorecon2. It helps refine the accuracy of the white matter identification. ```Python import cortex cortex.segment.fix_wm("subject") ``` -------------------------------- ### Pycortex JavaScript Plugin Architecture Source: https://github.com/gallantlab/pycortex/blob/main/docs/userguide/webgl.rst Pycortex features a JavaScript plugin architecture for developing new interactive visualizations. An example includes visualizing semantic feature mapping across the cortical surface, where clicking a point picks the closest voxel and displays its semantic category tuning. ```JavaScript // Example: Plugin structure for semantic feature visualization class SemanticFeaturePlugin { constructor(viewer) { this.viewer = viewer; } onClick(point) { const voxel = this.viewer.getVoxelAtPoint(point); if (voxel) { const tuningData = this.viewer.getTuningData(voxel); this.displayTuning(tuningData); } } displayTuning(data) { // Code to display semantic category tuning console.log('Displaying tuning data:', data); } } // Register the plugin // pycortex.registerPlugin('semanticFeature', SemanticFeaturePlugin); ``` -------------------------------- ### pycortex.freesurfer Functions Source: https://github.com/gallantlab/pycortex/blob/main/docs/api_reference_flat.rst Provides a suite of functions for interacting with FreeSurfer data, including getting file paths, running automatic reconstruction, flattening surfaces, importing subjects and flat data, displaying surfaces, and parsing various surface and curvature files. It also includes functions for writing and reading data in dot format, decimating surfaces, and applying SpringLayout. ```Python import cortex.freesurfer cortex.freesurfer.get_paths() cortex.freesurfer.autorecon() cortex.freesurfer.flatten() cortex.freesurfer.import_subj() cortex.freesurfer.import_flat() cortex.freesurfer.show_surf() cortex.freesurfer.make_fiducial() cortex.freesurfer.parse_surf() cortex.freesurfer.parse_curv() cortex.freesurfer.parse_patch() cortex.freesurfer.get_surf() cortex.freesurfer.get_curv() cortex.freesurfer.write_dot() cortex.freesurfer.read_dot() cortex.freesurfer.write_decimated() cortex.freesurfer.SpringLayout() cortex.freesurfer.stretch_mwall() ``` -------------------------------- ### Generate and Save Data View (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Illustrates generating a Volume data view with specified colormap and range, assigning it to a Dataset, and saving the Dataset to an HDF file. ```Python dv = cortex.Volume(np.random.randn(31, 100, 100), "S1", "fullhead", cmap="RdBu_r", vmin=-3, vmax=3) ds = cortex.Dataset(name=dv) ds.save("test_data.hdf") ``` -------------------------------- ### Initialize Subject with PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/segmentation.rst This function initializes a subject for segmentation within the pycortex library. It is a key step in preparing anatomical data for surface generation. ```python import cortex cortex.segment.init_subject() ``` -------------------------------- ### Create VolumeRGB and VertexRGB Objects in PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Demonstrates the creation of VolumeRGB and VertexRGB objects using numpy arrays or Volume objects for color channels. It outlines requirements for subject and xfmname parameters based on input data types and explains automatic data normalization and quantization. ```Python import cortex # Using numpy arrays rgb_volume = cortex.VolumeRGB(red_array, green_array, blue_array, subject='subject_id', alpha=alpha_array) rgb_vertex = cortex.VertexRGB(red_array, green_array, blue_array, alpha=alpha_array) # Using Volume objects red_vol = cortex.Volume.random(subject='subject_id', xfmname='fullhead') green_vol = cortex.Volume.random(subject='subject_id', xfmname='fullhead') blue_vol = cortex.Volume.random(subject='subject_id', xfmname='fullhead') rgb_volume_obj = cortex.VolumeRGB(red_vol, green_vol, blue_vol, subject=None, xfmname=None) rgb_vertex_obj = cortex.VertexRGB(red_vol, green_vol, blue_vol, alpha=None) ``` -------------------------------- ### Create Random Volume (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Demonstrates creating a Volume object filled with random data for a specified subject and transformation name. ```Python rand = cortex.Volume.random(subject, xfmname, **kwargs) ``` -------------------------------- ### CSS for Graph Visualization Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/wngraph.html Provides CSS styles for the graph visualization elements, including positioning, dimensions, and font properties for different parts of the graph display. ```CSS #wngraph { position: relative; width: 100%; height: 70%; padding-left: 5px; min-height: 615px; } #wngraph-plugin { background-color:black; left:10px; width:100%; height:100%; text-align:left; /*min-height: 700px;*/ } #wngraph-definition { position:relative; margin-left:10px; text-align:left; color:white; font-size:12pt; font-family:"Times New Roman",Georgia,Serif; } #wngraph-def-synset { font-weight:bold; font-size:16pt; } #wngraph-title { float:right; color:white; font-size:20pt; padding:10px; margin-top:20px; } ``` -------------------------------- ### Create Volume with Mask (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Explains how to create a Volume object with masked data, providing the mask explicitly via the 'mask' keyword argument. ```Python data = np.random.randn(32, 100, 100) mask = np.random.rand(32, 100, 100) > .5 # Assuming mask does not exist in database, provide it directly # vol = cortex.Volume(data, subject, xfmname, mask=mask) ``` -------------------------------- ### Google Analytics Tracking (JavaScript) Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This snippet implements Google Analytics tracking for the website. It initializes the analytics object and tracks page views. It's a standard practice for website analytics. ```JavaScript var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-22310405-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); ``` -------------------------------- ### UI Styling and Layout (CSS) Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This section contains CSS rules for styling various elements of the PyCortex web interface. It covers elements like bars, menus, buttons, input fields, and layout containers, aiming for a specific visual appearance with rounded corners, transparency, and hover effects. ```CSS #bar { background-color:white; background-image:none; color:black; border:0px solid white; width:4px; } #bar:hover, #bar:active { border:0px solid white; background-image:none; background-color:#ddd; } ul#datasets li .handle { display:none; } fieldset > legend { font-weight: bold; } #helpmenu { position:absolute; background:rgba(0, 0, 0, 0.6); transition:opacity 0.25s; -moz-transition:opacity 0.25s; -webkit-transition:opacity 0.25s; padding:0.5em; margin:2em; margin-top:-20em; width:15em; z-index:100; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; color:white; font-family:arial; border:2px solid #ffffff; } #intro { position:absolute; color:white; width:60%; height:60%; left:20%; top:20%; border-radius:10px; padding:20px; padding-left:14px; padding-left:10px; z-index:100; text-shadow:none; background-color:rgba(0, 0, 0, 0.9); -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; border:2px solid #ffffff; } #intro a, a:visited { color:#86BF84; } #introclose { float:left; background-color:black; margin-top:-22px; margin-left:-12px; border: 2px solid white; border-radius: 10px 0px 10px 0px; cursor:pointer; } #introclose:hover { background-color:rgba(48,48,48,1.0); } #introtext { overflow-y: scroll; overflow-x: hidden; text-align:left; width:100%; height:100%; font-size:16pt; } .infobar { background-color: rgba(0,0,0,0.8); border-bottom: 2px solid white; } .infobar:hover, .infobar:active { background-color: rgba(0,0,0,0.8); } #topbar { margin:-190px 0 -10px 0; height:200px; width:auto; border-radius: 0 0 0 0 / 0 0 0 0; color:white; min-width:1000px; } #topbar:hover, #topbar:active { margin:0px 0 -200px 0; } #topgrab { color:white; margin-left: auto; margin-right: auto; text-align: center; position: absolute; top:100%; margin-top:-15px; width:100%; } #display_options fieldset { border:1px solid #fff; border-radius: 5px 5px 5px 5px / 5px 5px 5px 5px; } ul#datasets { color:black; width:300px; } #bottombar { margin-top:-100px; z-index:10; position:relative; } #bottombar table { padding:4px; width:100%; } #bottombar table td { padding-bottom: 10px; } #bottombar table td:first-child { width:auto; min-width:auto; } #bottombar:hover, #bottombar:active { margin-top:-100px; } div#pluginbox { height:100%; min-height:100%; position:relative; } button { background-color:rgba(0,0,0,0.6); -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; border:3px solid #ffffff; display:inline-block; color:#ffffff; font-family:arial; font-size:15px; font-weight:bold; padding:6px 24px; text-decoration:none; } button:hover { background-color:rgba(80,80,80,0.6); position:relative; } #dataname { text-shadow:none; background-color:rgba(0,0,0,0.6); -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; border:2px solid #ffffff; } #viewlink { text-shadow:none; background-color:rgba(0,0,0,0.6); -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; border:3px solid #ffffff; z-index:10; position:absolute; float:left; color:white; font-size:16px; padding:5px; padding-right:8px; margin:20px; margin-top:95px; font-weight:bold; font-style:italic; cursor:pointer; display:none; } #viewlink:hover { background-color:rgba(80,80,80,0.6); } input#linkurl { border: 1px solid white; padding:2px; width: 90%; margin: 2px; display:none; } #mobile_err { max-width:320px; margin: auto; text-shadow:0px 2px 8px black, 0px 1px 8px black; color:white; text-align:center; } ``` -------------------------------- ### Create Random Vertex (Python) Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Illustrates creating a Vertex object with random data for a given subject. ```Python verts = cortex.Vertex.random(subject, **kwargs) ``` -------------------------------- ### Save Dataset with PyCortex Source: https://github.com/gallantlab/pycortex/blob/main/docs/dataset.rst Shows how to create a Dataset object with random data and save it to an HDF5 file using the pack=True option for data packing and deduplication. The structure of the saved HDF5 file is also detailed. ```Python import cortex import numpy as np # Create a Dataset object data_array = np.random.randn(31, 100, 100) dataset = cortex.Dataset(rand=(data_array, "S1", "fullhead")) # Save the dataset, packing data dataset.save("/tmp/dataset.hdf", pack=True) ``` -------------------------------- ### HTML Structure for PyCortex Interface Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/template.html This HTML snippet defines the basic structure of the PyCortex web interface. It includes placeholders for loading messages, data options, help menus, value displays, color legends, the main brain canvas, colormaps, and movie playback. ```html

Loading brain...
0.0000
0.0000
{% for name, img in colormaps %}
{% end %}
Loading...
``` -------------------------------- ### Python Interface Placeholder Source: https://github.com/gallantlab/pycortex/blob/main/cortex/webgl/simple.html This is a placeholder comment indicating where Python interface-specific logic might be included within a templating system. It suggests conditional rendering based on a 'python_interface' variable. ```Python {% if python_interface %} {% end %} ```