Skip to content

Commit

Permalink
[NEW 🐝] fsaverage surface
Browse files Browse the repository at this point in the history
  • Loading branch information
saratheriver committed Oct 6, 2022
1 parent a975659 commit ab1b995
Show file tree
Hide file tree
Showing 15 changed files with 936 additions and 4 deletions.
3 changes: 2 additions & 1 deletion enigmatoolbox/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .base import (load_conte69, load_sc, load_fc,
from .base import (load_conte69, load_sc, load_fc, load_fsa,
load_fsa5, load_subcortical, structural_covariance,
fetch_ahba, risk_genes, load_example_data,
load_summary_stats, load_fc_as_one, load_sc_as_one,
nfaces, getaffine, load_mask, write_cifti)

__all__ = ['load_conte69',
'load_fsa',
'load_fsa5',
'load_subcortical',
'load_sc',
Expand Down
39 changes: 39 additions & 0 deletions enigmatoolbox/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,45 @@ def load_fsa5(as_sphere=False, with_normals=True, join=False, with_sctx=False):
return surfs[0], surfs[1]


def load_fsa(as_sphere=False, with_normals=True, join=False):
"""Load fsaverage surfaces (author: @saratheriver)
Parameters
----------
as_sphere : bool, optional
Return spheres instead of cortical surfaces. Default is False.
with_normals : bool, optional
Whether to compute surface normals. Default is True.
join : bool, optional
If False, return one surface for left and right hemispheres. Otherwise,
return a single surface as a combination of both left and right
surfaces. Default is False.
Returns
-------
surf : tuple of BSPolyData or BSPolyData
Surfaces for left and right hemispheres. If ``join == True``, one surface with both hemispheres.
"""
root_pth = os.path.dirname(__file__)
if as_sphere is True:
fname = 'fsa_sphere_{}.gii'
elif as_sphere is not True:
fname = 'fsa_{}.gii'

ipth = os.path.join(root_pth, 'surfaces', fname)
surfs = [None] * 2
for i, side in enumerate(['lh', 'rh']):
surfs[i] = read_surface(ipth.format(side))
if with_normals:
nf = wrap_vtk(vtkPolyDataNormals, splitting=False,
featureAngle=0.1)
surfs[i] = serial_connect(surfs[i], nf)

if join:
return combine_surfaces(*surfs)
return surfs[0], surfs[1]


def load_subcortical(with_normals=False, join=False):
"""Load subcortical surfaces (author: @saratheriver)
Expand Down
155 changes: 155 additions & 0 deletions enigmatoolbox/datasets/surfaces/fsa_lh.gii

Large diffs are not rendered by default.

155 changes: 155 additions & 0 deletions enigmatoolbox/datasets/surfaces/fsa_rh.gii

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions enigmatoolbox/datasets/surfaces/fsa_sphere_lh.gii

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions enigmatoolbox/datasets/surfaces/fsa_sphere_rh.gii

Large diffs are not rendered by default.

Binary file modified enigmatoolbox/plotting/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 4 additions & 2 deletions enigmatoolbox/plotting/surface_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .colormaps import colormaps
from . import defaults_plotting as dp
from .utils import _broadcast, _expand_arg, _grep_args, _gen_grid, _get_ranges
from ..datasets import load_fsa5, load_conte69, load_subcortical
from ..datasets import load_fsa, load_fsa5, load_conte69, load_subcortical
from ..utils.parcellation import subcorticalvertices
from ..mesh.mesh_io import read_surface
from ..vtk_interface.decorators import wrap_input
Expand Down Expand Up @@ -436,7 +436,7 @@ def plot_cortical(array_name=None, surface_name='fsa5', color_bar=False,
the left and right hemispheres. If list, plot one row per array.
Default is None.
surface_name : str, optional
Name of surface {'fsa5', 'conte69}. Default is 'fsa5'.
Name of surface {'fsa', 'fsa5', 'conte69}. Default is 'fsa5'.
color_bar : bool, optional
Plot color bar for each array (row). Default is False.
color_range : {'sym'}, tuple or sequence.
Expand Down Expand Up @@ -489,6 +489,8 @@ def plot_cortical(array_name=None, surface_name='fsa5', color_bar=False,

if surface_name == "fsa5":
surf_lh, surf_rh = load_fsa5()
elif surface_name == "fsa":
surf_lh, surf_rh = load_fsa()
elif surface_name == "conte69":
surf_lh, surf_rh = load_conte69()

Expand Down
4 changes: 3 additions & 1 deletion matlab/scripts/surface_viewer/plot_cortical.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
% data (double array) - vector of data, size = [1 x v]
%
% Name/value pairs:
% surface_name (string, optional) - Name of surface {'fsa5', 'conte69}.
% surface_name (string, optional) - Name of surface {'fsa', 'fsa5', 'conte69}.
% Default is 'fsa5'.
% label_text (string, optional) - Label text for colorbar. Default is empty.
% background (string, double array, optional) - Background color.
Expand Down Expand Up @@ -39,6 +39,8 @@
% load surfaces
if strcmp(in.surface_name, 'fsa5')
surf = SurfStatAvSurf({'fsa5_lh', 'fsa5_rh'});
elseif strcmp(in.surface_name, 'fsa')
surf = SurfStatAvSurf({'fsa_lh', 'fsa_rh'});
elseif strcmp(in.surface_name, 'conte69')
surf = SurfStatAvSurf({'conte69_lh', 'conte69_rh'});
elseif strcmp(in.surface_name, 'ss')
Expand Down
155 changes: 155 additions & 0 deletions matlab/shared/surfaces/fsa_lh.gii

Large diffs are not rendered by default.

155 changes: 155 additions & 0 deletions matlab/shared/surfaces/fsa_rh.gii

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions matlab/shared/surfaces/fsa_sphere_lh.gii

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions matlab/shared/surfaces/fsa_sphere_rh.gii

Large diffs are not rendered by default.

0 comments on commit ab1b995

Please sign in to comment.