Skip to content

Commit 85b04f9

Browse files
committed
Allow compressed Gifti images
Allow .gz and .bz2 compressed Gifti images. Closes gh-1071
1 parent 4ecf756 commit 85b04f9

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

nibabel/gifti/gifti.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ class GiftiImage(xml.XmlSerializable, SerializableImage):
565565
"""
566566
valid_exts = ('.gii',)
567567
files_types = (('image', '.gii'),)
568+
_compressed_suffixes = ('.gz', '.bz2')
568569

569570
# The parser will in due course be a GiftiImageParser, but we can't set
570571
# that now, because it would result in a circular import. We set it after
558 Bytes
Binary file not shown.
488 Bytes
Binary file not shown.

nibabel/gifti/tests/test_parse_gifti_fast.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,11 @@ def test_external_file_failure_cases():
462462
parser = GiftiImageParser()
463463
with pytest.raises(GiftiParseError):
464464
img = parser.parse(xmldata)
465+
466+
467+
def test_load_compressed():
468+
for ext in ('', '.gz', '.bz2'):
469+
fn = pjoin(IO_DATA_PATH, 'external.gii' + ext)
470+
img7 = load(fn)
471+
assert_array_almost_equal(img7.darrays[0].data, DATA_FILE7_darr1)
472+
assert_array_almost_equal(img7.darrays[1].data, DATA_FILE7_darr2)

0 commit comments

Comments
 (0)