66# copyright and license terms.
77#
88### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9- ''' Simple interfaces for images '''
9+ ''' Common interface for any image format--volume or surface, binary or xml. '''
1010
1111try :
1212 basestring
@@ -68,11 +68,10 @@ def copy(self):
6868
6969class FileBasedImage (object ):
7070 '''
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.
7473
75- It has
74+ It has:
7675
7776 attributes:
7877
@@ -85,18 +84,6 @@ class FileBasedImage(object):
8584 * header
8685 * dataobj
8786
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-
10087 methods:
10188 * .get_header() (deprecated, use header property instead)
10289 * .to_filename(fname) - writes data to filename(s) derived from
@@ -111,6 +98,13 @@ class FileBasedImage(object):
11198 * instance_to_filename(img, fname) - save ``img`` instance to
11299 filename ``fname``.
113100
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+
114108
115109 There are several ways of writing data.
116110 =======================================
@@ -177,24 +171,6 @@ class FileBasedImage(object):
177171 carry the position at which a write (with ``to_files``) should place the
178172 data. The ``file_map`` contents should therefore be such, that this will
179173 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
198174 '''
199175 files_types = (('image' , None ),)
200176 alternate_exts = () # Modified by @ImageOpener.register_ext_from_image
0 commit comments