6
6
# copyright and license terms.
7
7
#
8
8
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9
- ''' Simple interfaces for images '''
9
+ ''' Common interface for any image format--volume or surface, binary or xml. '''
10
10
11
11
try :
12
12
basestring
@@ -68,11 +68,10 @@ def copy(self):
68
68
69
69
class FileBasedImage (object ):
70
70
'''
71
- It also has a ``header`` - some standard set of meta-data that is specific to
72
- the image format, and ``extra`` - a dictionary container for any other
73
- metadata.
71
+ This abstract image class defines an interface for loading/saving images
72
+ from disk. It doesn't define any image properties.
74
73
75
- It has
74
+ It has:
76
75
77
76
attributes:
78
77
@@ -85,18 +84,6 @@ class FileBasedImage(object):
85
84
* header
86
85
* dataobj
87
86
88
- You cannot slice an image, and trying to slice an image generates an
89
- informative TypeError.
90
- '''
91
-
92
-
93
- '''
94
- This abstract image class defines an interface for loading/saving images
95
- from disk. It doesn't define any image properties.
96
-
97
- It has
98
-
99
-
100
87
methods:
101
88
* .get_header() (deprecated, use header property instead)
102
89
* .to_filename(fname) - writes data to filename(s) derived from
@@ -111,6 +98,13 @@ class FileBasedImage(object):
111
98
* instance_to_filename(img, fname) - save ``img`` instance to
112
99
filename ``fname``.
113
100
101
+ It also has a ``header`` - some standard set of meta-data that is specific to
102
+ the image format, and ``extra`` - a dictionary container for any other
103
+ metadata.
104
+
105
+ You cannot slice an image, and trying to slice an image generates an
106
+ informative TypeError.
107
+
114
108
115
109
There are several ways of writing data.
116
110
=======================================
@@ -177,24 +171,6 @@ class FileBasedImage(object):
177
171
carry the position at which a write (with ``to_files``) should place the
178
172
data. The ``file_map`` contents should therefore be such, that this will
179
173
work:
180
-
181
- >>> # write an image to files
182
- >>> from io import BytesIO
183
- >>> file_map = nib.AnalyzeImage.make_file_map()
184
- >>> file_map['image'].fileobj = BytesIO()
185
- >>> file_map['header'].fileobj = BytesIO()
186
- >>> img = nib.AnalyzeImage(data, np.eye(4))
187
- >>> img.file_map = file_map
188
- >>> img.to_file_map()
189
- >>> # read it back again from the written files
190
- >>> img2 = nib.AnalyzeImage.from_file_map(file_map)
191
- >>> np.all(img2.get_data() == data)
192
- True
193
- >>> # write, read it again
194
- >>> img2.to_file_map()
195
- >>> img3 = nib.AnalyzeImage.from_file_map(file_map)
196
- >>> np.all(img3.get_data() == data)
197
- True
198
174
'''
199
175
files_types = (('image' , None ),)
200
176
alternate_exts = () # Modified by @ImageOpener.register_ext_from_image
0 commit comments