File tree Expand file tree Collapse file tree 2 files changed +47
-9
lines changed Expand file tree Collapse file tree 2 files changed +47
-9
lines changed Original file line number Diff line number Diff line change 10
10
# Stephan Gerhard, Oktober 2010
11
11
##############
12
12
13
- import os
14
- import codecs
13
+ import warnings
15
14
16
- from . parse_gifti_fast import parse_gifti_file
15
+ import numpy as np
17
16
18
17
18
+ warnings .warn ('Please use nibabel.load/save.' , DeprecationWarning )
19
+
20
+
21
+ @np .deprecate_with_doc ("Use nibabel.load() instead." )
19
22
def read (filename ):
20
23
""" Load a Gifti image from a file
21
24
@@ -29,11 +32,11 @@ def read(filename):
29
32
img : GiftiImage
30
33
Returns a GiftiImage
31
34
"""
32
- if not os .path .isfile (filename ):
33
- raise IOError ("No such file or directory: '%s'" % filename )
34
- return parse_gifti_file (filename )
35
+ from ..loadsave import load
36
+ return load (filename )
35
37
36
38
39
+ @np .deprecate_with_doc ("Use nibabel.save() instead." )
37
40
def write (image , filename ):
38
41
""" Save the current image to a new file
39
42
@@ -79,6 +82,6 @@ def write(image, filename):
79
82
80
83
The Gifti file is stored in endian convention of the current machine.
81
84
"""
82
- # Our giftis are always utf-8 encoded - see GiftiImage.to_xml
83
- with open ( filename , 'wb' ) as f :
84
- f . write ( image . to_xml ())
85
+ from .. loadsave import save
86
+ return save ( image , filename )
87
+
Original file line number Diff line number Diff line change
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
+
10
+ import warnings
11
+
12
+ from nose .tools import (assert_true , assert_false , assert_equal ,
13
+ assert_raises )
14
+ from ...testing import clear_and_catch_warnings
15
+
16
+
17
+ from .test_parse_gifti_fast import (DATA_FILE1 , DATA_FILE2 , DATA_FILE3 ,
18
+ DATA_FILE4 , DATA_FILE5 , DATA_FILE6 )
19
+
20
+
21
+ class TestGiftiIO (object ):
22
+ def setUp (self ):
23
+ with clear_and_catch_warnings () as w :
24
+ warnings .simplefilter ('always' , DeprecationWarning )
25
+ import nibabel .gifti .giftiio
26
+ assert_equal (len (w ), 1 )
27
+
28
+
29
+ def test_read_deprecated ():
30
+ with clear_and_catch_warnings () as w :
31
+ warnings .simplefilter ('always' , DeprecationWarning )
32
+ from nibabel .gifti .giftiio import read
33
+
34
+ img = read (DATA_FILE1 )
35
+ assert_equal (len (w ), 1 )
You can’t perform that action at this time.
0 commit comments