Skip to content

Commit ad0225e

Browse files
author
Ben Cipollini
committed
Make GIFTI call superclass __init__
1 parent 6733a46 commit ad0225e

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

nibabel/gifti/gifti.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,15 @@ def metadata(self):
386386

387387

388388
class GiftiImage(FileBasedImage, xml.XmlSerializable):
389+
valid_exts = ('.gii',)
389390
files_types = (('image', '.gii'),)
390391
valid_exts = ('.gii',)
391392

392-
def __init__(self, meta=None, labeltable=None, darrays=None,
393-
version="1.0"):
393+
def __init__(self, header=None, extra=None, file_map=None, meta=None,
394+
labeltable=None, darrays=None, version="1.0"):
395+
FileBasedImage.__init__(self, header=header, extra=extra,
396+
file_map=file_map)
397+
394398
if darrays is None:
395399
darrays = []
396400
if meta is None:

nibabel/tests/test_files_interface.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515
from .. import Nifti1Image, Nifti1Pair, MGHImage, all_image_classes
1616
from ..externals.six import BytesIO
1717
from ..fileholders import FileHolderError
18+
from ..spatialimages import SpatialImage
1819

1920
from nose.tools import (assert_true, assert_false, assert_equal, assert_raises)
2021

2122
from numpy.testing import assert_array_equal, assert_array_almost_equal
2223

2324

24-
def test_files_images():
25+
def test_files_spatialimages():
2526
# test files creation in image classes
2627
arr = np.zeros((2,3,4))
2728
aff = np.eye(4)
28-
for klass in all_image_classes:
29+
klasses = [klass for klass in all_image_classes
30+
if klass.rw and issubclass(klass, SpatialImage)]
31+
for klass in klasses:
2932
file_map = klass.make_file_map()
3033
for key, value in file_map.items():
3134
assert_equal(value.filename, None)
@@ -81,11 +84,12 @@ def test_files_interface():
8184
assert_array_equal(img2.get_data(), img.get_data())
8285

8386

84-
def test_round_trip():
87+
def test_round_trip_spatialimages():
8588
# write an image to files
8689
data = np.arange(24, dtype='i4').reshape((2, 3, 4))
8790
aff = np.eye(4)
88-
klasses = filter(lambda klass: klass.rw, all_image_classes)
91+
klasses = [klass for klass in all_image_classes
92+
if klass.rw and issubclass(klass, SpatialImage)]
8993
for klass in klasses:
9094
file_map = klass.make_file_map()
9195
for key in file_map:

nibabel/tests/test_image_load_save.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from ..tmpdirs import InTemporaryDirectory
2828
from ..volumeutils import native_code, swapped_code
2929
from ..optpkg import optional_package
30+
from ..spatialimages import SpatialImage
3031

3132
from numpy.testing import assert_array_equal, assert_array_almost_equal
3233
from nose.tools import assert_true, assert_equal
@@ -45,17 +46,19 @@ def round_trip(img):
4546
return img2
4647

4748

48-
def test_conversion():
49+
def test_conversion_spatialimages():
4950
shape = (2, 4, 6)
5051
affine = np.diag([1, 2, 3, 1])
52+
klasses = [klass for klass in all_image_classes
53+
if klass.rw and issubclass(klass, SpatialImage)]
5154
for npt in np.float32, np.int16:
5255
data = np.arange(np.prod(shape), dtype=npt).reshape(shape)
53-
for r_class in all_image_classes:
56+
for r_class in klasses:
5457
if not r_class.makeable:
5558
continue
5659
img = r_class(data, affine)
5760
img.set_data_dtype(npt)
58-
for w_class in all_image_classes:
61+
for w_class in klasses:
5962
if not w_class.makeable:
6063
continue
6164
img2 = w_class.from_image(img)

0 commit comments

Comments
 (0)