77#
88### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99"""Common interface for any image format--volume or surface, binary or xml."""
10+ from __future__ import annotations
1011
1112import io
1213from copy import deepcopy
14+ from typing import Type
1315from urllib import request
1416
1517from .fileholders import FileHolder
@@ -74,7 +76,6 @@ class FileBasedImage:
7476
7577 properties:
7678
77- * shape
7879 * header
7980
8081 methods:
@@ -118,25 +119,6 @@ class FileBasedImage:
118119
119120 img.to_file_map()
120121
121- You can get the data out again with::
122-
123- img.get_fdata()
124-
125- Less commonly, for some image types that support it, you might want to
126- fetch out the unscaled array via the object containing the data::
127-
128- unscaled_data = img.dataoobj.get_unscaled()
129-
130- Analyze-type images (including nifti) support this, but others may not
131- (MINC, for example).
132-
133- Sometimes you might to avoid any loss of precision by making the
134- data type the same as the input::
135-
136- hdr = img.header
137- hdr.set_data_dtype(data.dtype)
138- img.to_filename(fname)
139-
140122 **Files interface**
141123
142124 The image has an attribute ``file_map``. This is a mapping, that has keys
@@ -158,20 +140,20 @@ class FileBasedImage:
158140 contain enough information so that an existing image instance can save
159141 itself back to the files pointed to in ``file_map``. When a file holder
160142 holds active file-like objects, then these may be affected by the
161- initial file read; in this case, the contains file-like objects need to
143+ initial file read; in this case, the file-like objects need to
162144 carry the position at which a write (with ``to_file_map``) should place the
163145 data. The ``file_map`` contents should therefore be such, that this will
164146 work.
165147 """
166148
167- header_class = FileBasedHeader
168- _meta_sniff_len = 0
169- files_types = (('image' , None ),)
170- valid_exts = ()
171- _compressed_suffixes = ()
149+ header_class : Type [ FileBasedHeader ] = FileBasedHeader
150+ _meta_sniff_len : int = 0
151+ files_types : tuple [ tuple [ str , str | None ], ...] = (('image' , None ),)
152+ valid_exts : tuple [ str , ...] = ()
153+ _compressed_suffixes : tuple [ str , ...] = ()
172154
173- makeable = True # Used in test code
174- rw = True # Used in test code
155+ makeable : bool = True # Used in test code
156+ rw : bool = True # Used in test code
175157
176158 def __init__ (self , header = None , extra = None , file_map = None ):
177159 """Initialize image
0 commit comments