Skip to content

Commit 8e02a5c

Browse files
authored
Merge pull request #75 from rmarkello/enh/surface_centroid
[ENH] Surface centroid calculation
2 parents 5472a03 + 70b24df commit 8e02a5c

File tree

6 files changed

+248
-83
lines changed

6 files changed

+248
-83
lines changed

docs/api.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Functions to download atlases and templates
151151
fetch_conte69
152152
fetch_fsaverage
153153
fetch_pauli2018
154+
fetch_schaefer2018
155+
fetch_hcp_standards
154156

155157
Functions to download real-world datasets
156158

@@ -160,6 +162,7 @@ Functions to download real-world datasets
160162

161163
fetch_connectome
162164
fetch_mirchi2018
165+
fetch_vazquez_rodriguez2019
163166

164167
Functions to generate (pseudo-random) datasets
165168

@@ -169,6 +172,28 @@ Functions to generate (pseudo-random) datasets
169172

170173
make_correlated_xy
171174

175+
.. _ref_freesurfer:
176+
177+
:mod:`netneurotools.freesurfer` - FreeSurfer compatibility functions
178+
--------------------------------------------------------------------
179+
180+
.. automodule:: netneurotools.freesurfer
181+
:no-members:
182+
:no-inherited-members:
183+
184+
.. currentmodule:: netneurotools.freesurfer
185+
186+
.. autosummary::
187+
:template: function.rst
188+
:toctree: generated/
189+
190+
apply_prob_atlas
191+
find_parcel_centroids
192+
parcels_to_vertices
193+
vertices_to_parcels
194+
spin_data
195+
spin_parcels
196+
172197
.. _ref_utils:
173198

174199
:mod:`netneurotools.utils` - Miscellaneous, grab bag utilities

netneurotools/datasets/fetchers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Functions for fetching datasets from the internet
44
"""
55

6+
from collections import namedtuple
67
import itertools
78
import json
89
import os.path as op
@@ -15,6 +16,8 @@
1516
from .utils import _get_data_dir, _get_dataset_info
1617
from ..utils import check_fs_subjid
1718

19+
ANNOT = namedtuple('Surface', ('lh', 'rh'))
20+
1821

1922
def fetch_cammoun2012(version='MNI152NLin2009aSym', data_dir=None, url=None,
2023
resume=True, verbose=1):
@@ -134,7 +137,7 @@ def fetch_cammoun2012(version='MNI152NLin2009aSym', data_dir=None, url=None,
134137
if version == 'MNI152NLin2009aSym':
135138
keys += ['info']
136139
elif version in ('fslr32k', 'fsaverage', 'fsaverage5', 'fsaverage6'):
137-
data = [data[i:i + 2] for i in range(0, len(data), 2)]
140+
data = [ANNOT(*data[i:i + 2]) for i in range(0, len(data), 2)]
138141
else:
139142
data = [data[::2][i:i + 2] for i in range(0, len(data) // 2, 2)]
140143
# deal with the fact that last scale is split into three files :sigh:
@@ -209,7 +212,7 @@ def fetch_conte69(data_dir=None, url=None, resume=True, verbose=1):
209212
data[-1] = json.load(src)
210213

211214
# bundle hemispheres together
212-
data = [data[:-1][i:i + 2] for i in range(0, 6, 2)] + [data[-1]]
215+
data = [ANNOT(*data[:-1][i:i + 2]) for i in range(0, 6, 2)] + [data[-1]]
213216

214217
return Bunch(**dict(zip(keys + ['info'], data)))
215218

@@ -336,7 +339,7 @@ def fetch_fsaverage(version='fsaverage', data_dir=None, url=None, resume=True,
336339
files=[(op.join(dataset_name, f), url, opts)
337340
for f in filenames])
338341

339-
data = [data[i:i + 2] for i in range(0, len(keys) * 2, 2)]
342+
data = [ANNOT(*data[i:i + 2]) for i in range(0, len(keys) * 2, 2)]
340343

341344
return Bunch(**dict(zip(keys, data)))
342345

@@ -561,7 +564,7 @@ def fetch_schaefer2018(version='fsaverage', data_dir=None, url=None,
561564
data = _fetch_files(data_dir, files=files, resume=resume, verbose=verbose)
562565

563566
if suffix == 'annot':
564-
data = [data[i:i + 2] for i in range(0, len(keys) * 2, 2)]
567+
data = [ANNOT(*data[i:i + 2]) for i in range(0, len(keys) * 2, 2)]
565568

566569
return Bunch(**dict(zip(keys, data)))
567570

0 commit comments

Comments
 (0)