Skip to content

Commit 066799b

Browse files
authored
Merge pull request #100 from rmarkello/fetch_mmp
[ENH] Add fetcher for MMP atlas
2 parents 264c77d + f1c01f7 commit 066799b

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

netneurotools/data/osf.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,15 @@
352352
"md5": "d8378f33107ed5d98c27e8070ebb5aa2"
353353
}
354354
},
355+
"atl-mmpall": {
356+
"fslr32k": {
357+
"url": [
358+
"mb37e",
359+
"6047bac259e910009b83114f"
360+
],
361+
"md5": "fd641742685a239d9c3f60e19a280ca2"
362+
}
363+
},
355364
"atl-voneconomo_koskinas": {
356365
"url": [
357366
"mb37e",

netneurotools/datasets/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
'fetch_cammoun2012', 'fetch_pauli2018', 'fetch_fsaverage', 'fetch_conte69',
77
'fetch_connectome', 'available_connectomes', 'fetch_vazquez_rodriguez2019',
88
'fetch_mirchi2018', 'make_correlated_xy', 'fetch_schaefer2018',
9-
'fetch_hcp_standards', 'fetch_voneconomo'
9+
'fetch_hcp_standards', 'fetch_voneconomo', 'fetch_mmpall'
1010
]
1111

1212
from .fetchers import (fetch_cammoun2012, fetch_pauli2018, fetch_fsaverage,
1313
fetch_conte69, fetch_connectome, available_connectomes,
1414
fetch_vazquez_rodriguez2019, fetch_schaefer2018,
15-
fetch_hcp_standards, fetch_voneconomo)
15+
fetch_hcp_standards, fetch_voneconomo, fetch_mmpall)
1616
from .generators import (make_correlated_xy)
1717
from .mirchi import (fetch_mirchi2018)

netneurotools/datasets/fetchers.py

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,77 @@ def fetch_hcp_standards(data_dir=None, url=None, resume=True, verbose=1):
610610
return op.join(data_dir, dataset_name)
611611

612612

613+
def fetch_mmpall(version='fslr32k', data_dir=None, url=None, resume=True,
614+
verbose=1):
615+
"""
616+
Downloads .label.gii files for Glasser et al., 2016 MMPAll atlas
617+
618+
Parameters
619+
----------
620+
version : {'fslr32k'}
621+
Specifies which surface annotation files should be matched to. Default:
622+
'fslr32k'
623+
data_dir : str, optional
624+
Path to use as data directory. If not specified, will check for
625+
environmental variable 'NNT_DATA'; if that is not set, will use
626+
`~/nnt-data` instead. Default: None
627+
url : str, optional
628+
URL from which to download data. Default: None
629+
resume : bool, optional
630+
Whether to attempt to resume partial download, if possible. Default:
631+
True
632+
verbose : int, optional
633+
Modifies verbosity of download, where higher numbers mean more updates.
634+
Default: 1
635+
636+
Returns
637+
-------
638+
filenames : :class:`sklearn.utils.Bunch`
639+
Namedtuple with fields ('lh', 'rh') corresponding to filepaths to
640+
left/right hemisphere parcellation files
641+
642+
References
643+
----------
644+
Glasser, M. F., Coalson, T. S., Robinson, E. C., Hacker, C. D., Harwell,
645+
J., Yacoub, E., ... & Van Essen, D. C. (2016). A multi-modal parcellation
646+
of human cerebral cortex. Nature, 536(7615), 171-178.
647+
648+
Notes
649+
-----
650+
License: https://www.humanconnectome.org/study/hcp-young-adult/document/
651+
wu-minn-hcp-consortium-open-access-data-use-terms
652+
"""
653+
654+
versions = ['fslr32k']
655+
if version not in versions:
656+
raise ValueError('The version of Glasser et al., 2016 parcellation '
657+
'requested "{}" does not exist. Must be one of {}'
658+
.format(version, versions))
659+
660+
dataset_name = 'atl-mmpall'
661+
662+
data_dir = _get_data_dir(data_dir=data_dir)
663+
info = _get_dataset_info(dataset_name)[version]
664+
if url is None:
665+
url = info['url']
666+
opts = {
667+
'uncompress': True,
668+
'md5sum': info['md5'],
669+
'move': '{}.tar.gz'.format(dataset_name)
670+
}
671+
672+
hemispheres = ['L', 'R']
673+
filenames = [
674+
'atl-MMPAll_space-{}_hemi-{}_deterministic.label.gii'
675+
.format(version, hemi) for hemi in hemispheres
676+
]
677+
678+
files = [(op.join(dataset_name, version, f), url, opts) for f in filenames]
679+
data = _fetch_files(data_dir, files=files, resume=resume, verbose=verbose)
680+
681+
return ANNOT(*data)
682+
683+
613684
def fetch_voneconomo(data_dir=None, url=None, resume=True, verbose=1):
614685
"""
615686
Fetches von-Economo Koskinas probabilistic FreeSurfer atlas
@@ -632,8 +703,7 @@ def fetch_voneconomo(data_dir=None, url=None, resume=True, verbose=1):
632703
Returns
633704
-------
634705
filenames : :class:`sklearn.utils.Bunch`
635-
Dictionary-like object with keys of format '{}Parcels{}Networks' where
636-
corresponding values are the left/right hemisphere annotation files
706+
Dictionary-like object with keys ['gcs', 'ctab', 'info']
637707
638708
References
639709
----------

netneurotools/tests/test_datasets.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ def test_fetch_hcp_standards(tmpdir):
148148
assert os.path.isdir(hcp)
149149

150150

151+
def test_fetch_mmpall(tmpdir):
152+
mmp = datasets.fetch_mmpall(data_dir=tmpdir, verbose=0)
153+
assert len(mmp) == 2
154+
assert all(os.path.isfile(hemi) for hemi in mmp)
155+
assert all(hasattr(mmp, attr) for attr in ('lh', 'rh'))
156+
157+
151158
def test_fetch_voneconomo(tmpdir):
152159
vek = datasets.fetch_voneconomo(data_dir=tmpdir, verbose=0)
153160
assert all(hasattr(vek, k) and len(vek[k]) == 2 for k in ['gcs', 'ctab'])

0 commit comments

Comments
 (0)