Skip to content

Commit 19fd3f8

Browse files
Merge pull request #249 from satra/enh/cifti2
MRG: CIFTI2 spec reader and writer Initial read / write capability for CIFTI2. The API may change in the future, before a first release, please be careful.
2 parents 3c28d7e + 9e1de24 commit 19fd3f8

31 files changed

+4096
-436
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "nibabel-data/parrec_oblique"]
1414
path = nibabel-data/parrec_oblique
1515
url = https://github.com/grlee77/parrec_oblique.git
16+
[submodule "nibabel-data/nitest-cifti2"]
17+
path = nibabel-data/nitest-cifti2
18+
url = https://github.com/demianw/nibabel-nitest-cifti2.git

nibabel-data/nitest-cifti2

Submodule nitest-cifti2 added at 26b7cb9

nibabel/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from .nifti2 import Nifti2Header, Nifti2Image, Nifti2Pair
5252
from .minc1 import Minc1Image
5353
from .minc2 import Minc2Image
54+
from .cifti2 import Cifti2Header, Cifti2Image
5455
# Deprecated backwards compatiblity for MINC1
5556
from .deprecated import ModuleProxy as _ModuleProxy
5657
minc = _ModuleProxy('nibabel.minc')

nibabel/arrayproxy.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"""
2828
import warnings
2929

30+
import numpy as np
31+
3032
from .volumeutils import array_from_file, apply_read_scaling
3133
from .fileslice import fileslice
3234
from .keywordonly import kw_only_meth
@@ -111,8 +113,12 @@ def shape(self):
111113
return self._shape
112114

113115
@property
114-
def is_proxy(self):
115-
return True
116+
def dtype(self):
117+
return self._dtype
118+
119+
@property
120+
def offset(self):
121+
return self._offset
116122

117123
@property
118124
def slope(self):
@@ -123,8 +129,8 @@ def inter(self):
123129
return self._inter
124130

125131
@property
126-
def offset(self):
127-
return self._offset
132+
def is_proxy(self):
133+
return True
128134

129135
def get_unscaled(self):
130136
''' Read of data from file
@@ -164,3 +170,10 @@ def is_proxy(obj):
164170
return obj.is_proxy
165171
except AttributeError:
166172
return False
173+
174+
175+
def reshape_dataobj(obj, shape):
176+
""" Use `obj` reshape method if possible, else numpy reshape function
177+
"""
178+
return (obj.reshape(shape) if hasattr(obj, 'reshape')
179+
else np.reshape(obj, shape))

nibabel/cifti2/__init__.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
4+
#
5+
# See COPYING file distributed along with the NiBabel package for the
6+
# copyright and license terms.
7+
#
8+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9+
"""CIfTI format IO
10+
11+
.. currentmodule:: nibabel.cifti2
12+
13+
.. autosummary::
14+
:toctree: ../generated
15+
16+
cifti2
17+
"""
18+
19+
from .parse_cifti2 import Cifti2Extension
20+
from .cifti2 import (Cifti2MetaData, Cifti2Header, Cifti2Image, Cifti2Label,
21+
Cifti2LabelTable, Cifti2VertexIndices,
22+
Cifti2VoxelIndicesIJK, Cifti2BrainModel, Cifti2Matrix,
23+
Cifti2MatrixIndicesMap, Cifti2NamedMap, Cifti2Parcel,
24+
Cifti2Surface,
25+
Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ,
26+
Cifti2Vertices, Cifti2Volume, CIFTI_BRAIN_STRUCTURES,
27+
Cifti2HeaderError, CIFTI_MODEL_TYPES, load, save)

0 commit comments

Comments
 (0)