Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions neuromaps/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""Functions for fetching datasets."""

__all__ = [
'fetch_all_atlases', 'fetch_atlas', 'fetch_civet', 'fetch_fsaverage',
'fetch_fslr', 'fetch_mni152', 'fetch_regfusion', 'get_atlas_dir',
'DENSITIES', 'ALIAS', 'available_annotations', 'available_tags',
'fetch_annotation'
'fetch_all_atlases', 'fetch_atlas', 'fetch_bigbrain', 'fetch_civet',
'fetch_fsaverage', 'fetch_fslr', 'fetch_mni152', 'fetch_regfusion',
'get_atlas_dir', 'DENSITIES', 'ALIAS', 'available_annotations',
'available_tags', 'fetch_annotation'
]

# TODO: remove after nilearn v0.9 release
import warnings
warnings.filterwarnings('ignore', message='Fetchers from the nilearn.datasets',
category=FutureWarning)

from .atlases import (fetch_all_atlases, fetch_atlas, fetch_civet, # noqa
from .atlases import (fetch_all_atlases, fetch_atlas, fetch_bigbrain, fetch_civet, # noqa
fetch_fsaverage, fetch_fslr, fetch_mni152,
fetch_regfusion, get_atlas_dir, DENSITIES, ALIAS)
from .annotations import (available_annotations, available_tags, # noqa
Expand Down
27 changes: 26 additions & 1 deletion neuromaps/datasets/atlases.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
SURFACE = namedtuple('Surface', ('L', 'R'))
ALIAS = dict(
fslr='fsLR', fsavg='fsaverage', mni152='MNI152', mni='MNI152',
FSLR='fsLR', CIVET='civet'
FSLR='fsLR', CIVET='civet', bigbrain='BigBrain'
)
DENSITIES = dict(
civet=['41k', '164k'],
fsaverage=['3k', '10k', '41k', '164k'],
fsLR=['4k', '8k', '32k', '164k'],
MNI152=['1mm', '2mm', '3mm'],
BigBrain=['164k']
)


Expand Down Expand Up @@ -197,6 +198,30 @@ def fetch_fslr(density='32k', url=None, data_dir=None, verbose=1): # noqa: D103
""".format(**_atlas_docs, densities="', '".join(DENSITIES['fsLR']))


def fetch_bigbrain(density='164k', url=None, data_dir=None, verbose=1):
keys = ['white', 'pial']
return _fetch_atlas(
'BigBrain', density, keys, url=url, data_dir=data_dir, verbose=verbose
)


fetch_bigbrain.__doc__ = """
Fetch BigBrain surface atlas.

Parameters
----------
density : {{'{densities}'}}, optional
Density of BigBrain atlas to fetch. Default: '164k'
{url}
{data_dir}
{verbose}

Returns
-------
{surfatlas}
""".format(**_atlas_docs, densities="', '".join(DENSITIES['BigBrain']))


def fetch_mni152(density='1mm', url=None, data_dir=None, verbose=1): # noqa: D103
keys = ['2009cAsym_T1w', '2009cAsym_T2w', '2009cAsym_PD',
'2009cAsym_brainmask', '2009cAsym_CSF', '2009cAsym_GM',
Expand Down
9 changes: 9 additions & 0 deletions neuromaps/datasets/data/osf.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"BigBrain": {
"164k": {
"url": [
"4mw3a",
"65c2aa433280d809e3a3aead"
],
"md5": "af5e44a36f3d6d0e58d43f0822998c49"
}
},
"civet": {
"41k": {
"url": [
Expand Down
115 changes: 115 additions & 0 deletions neuromaps/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,118 @@ def fsaverage_to_fsaverage(data, target_density='41k', hemi=None,
srcparams = dict(space='fsaverage', den=density, trg='')
trgparams = dict(space='fsaverage', den=target_density, trg='')
return _surf_to_surf(data, srcparams, trgparams, method, hemi)


def bigbrain_to_fslr(data, target_density='164k', hemi=None, method='linear'):
"""
Resample `data` on the BigBrain surface to the fsLR surface.

Parameters
----------
data : str or os.PathLike or nib.GiftiImage or tuple
Input BigBrain data to be resampled
target_density : {'4k', '8k', '32k', '164k'}, optional
Desired density of output surface. Default: '164k'
hemi : {'L', 'R'}, optional
If `data` is not a tuple this specifies the hemisphere the data are
representing. Default: None
method : {'nearest', 'linear'}, optional
Method for resampling. Specify 'nearest' if `data` are label images.
Default: 'linear'

Returns
-------
resampled : tuple-of-nib.GiftiImage
Input `data` resampled to new density
"""
density, = _estimate_density((data,), hemi=hemi)
srcparams = dict(space='BigBrain', den=density, trg='_space-fsLR')
trgparams = dict(space='fsLR', den=target_density, trg='')
return _surf_to_surf(data, srcparams, trgparams, method, hemi)


def bigbrain_to_fsaverage(data, target_density='164k', hemi=None,
method='linear'):
"""
Resample `data` on the BigBrain surface to the fsaverage surface.

Parameters
----------
data : str or os.PathLike or nib.GiftiImage or tuple
Input BigBrain data to be resampled
target_density : {'3k', '10k', '41k', '164k'}, optional
Desired density of output surface. Default: '164k'
hemi : {'L', 'R'}, optional
If `data` is not a tuple this specifies the hemisphere the data are
representing. Default: None
method : {'nearest', 'linear'}, optional
Method for resampling. Specify 'nearest' if `data` are label images.
Default: 'linear'

Returns
-------
resampled : tuple-of-nib.GiftiImage
Input `data` resampled to new density
"""
density, = _estimate_density((data,), hemi=hemi)
srcparams = dict(space='BigBrain', den=density, trg='_space-fsaverage')
trgparams = dict(space='fsaverage', den=target_density, trg='')
return _surf_to_surf(data, srcparams, trgparams, method, hemi)


def fsaverage_to_bigbrain(data, target_density='164k', hemi=None,
method='linear'):
"""
Resample `data` on fsLR surface to new density.

Parameters
----------
data : str or os.PathLike or nib.GiftiImage or tuple
Input BigBrain data to be resampled
target_density : {'164k'}, optional
Desired density of output surface. Default: '164k'
hemi : {'L', 'R'}, optional
If `data` is not a tuple this specifies the hemisphere the data are
representing. Default: None
method : {'nearest', 'linear'}, optional
Method for resampling. Specify 'nearest' if `data` are label images.
Default: 'linear'

Returns
-------
resampled : tuple-of-nib.GiftiImage
Input `data` resampled to new density
"""
density, = _estimate_density((data,), hemi=hemi)
srcparams = dict(space='fsaverage', den=density, trg='')
trgparams = dict(space='BigBrain', den=target_density,
trg='_space-fsaverage')
return _surf_to_surf(data, srcparams, trgparams, method, hemi)


def fslr_to_bigbrain(data, target_density='164k', hemi=None, method='linear'):
"""
Resample `data` on fsLR surface to new density.

Parameters
----------
data : str or os.PathLike or nib.GiftiImage or tuple
Input BigBrain data to be resampled
target_density : {'164k'}, optional
Desired density of output surface. Default: '164k'
hemi : {'L', 'R'}, optional
If `data` is not a tuple this specifies the hemisphere the data are
representing. Default: None
method : {'nearest', 'linear'}, optional
Method for resampling. Specify 'nearest' if `data` are label images.
Default: 'linear'

Returns
-------
resampled : tuple-of-nib.GiftiImage
Input `data` resampled to new density
"""
density, = _estimate_density((data,), hemi=hemi)
srcparams = dict(space='fsLR', den=density, trg='')
trgparams = dict(space='BigBrain', den=target_density, trg='_space-fsLR')
return _surf_to_surf(data, srcparams, trgparams, method, hemi)