53
53
KEEP_FILE_OPEN_DEFAULT = False
54
54
55
55
56
- class ArrayProxy ( object ) :
56
+ class ArrayProxy :
57
57
""" Class to act as proxy for the array that can be read from a file
58
58
59
59
The array proxy allows us to freeze the passed fileobj and header such that
@@ -83,10 +83,9 @@ class ArrayProxy(object):
83
83
See :mod:`nibabel.minc1`, :mod:`nibabel.ecat` and :mod:`nibabel.parrec` for
84
84
examples.
85
85
"""
86
- # Assume Fortran array memory layout
87
86
order = 'F'
88
87
89
- def __init__ (self , file_like , spec , * , mmap = True , keep_file_open = None ):
88
+ def __init__ (self , file_like , spec , * , mmap = True , order = None , keep_file_open = None ):
90
89
"""Initialize array proxy instance
91
90
92
91
Parameters
@@ -116,6 +115,10 @@ def __init__(self, file_like, spec, *, mmap=True, keep_file_open=None):
116
115
True gives the same behavior as ``mmap='c'``. If `file_like`
117
116
cannot be memory-mapped, ignore `mmap` value and read array from
118
117
file.
118
+ order : {'F', 'C'}, optional, keyword only
119
+ `order` controls the order of the data array layout. Fortran-style,
120
+ column-major order may be indicated with 'F', and C-style, row-major
121
+ order may be indicated with 'C'. The default order is 'F'.
119
122
keep_file_open : { None, True, False }, optional, keyword only
120
123
`keep_file_open` controls whether a new file handle is created
121
124
every time the image is accessed, or a single file handle is
@@ -128,6 +131,8 @@ def __init__(self, file_like, spec, *, mmap=True, keep_file_open=None):
128
131
"""
129
132
if mmap not in (True , False , 'c' , 'r' ):
130
133
raise ValueError ("mmap should be one of {True, False, 'c', 'r'}" )
134
+ if order not in (None , 'C' , 'F' ):
135
+ raise ValueError ("order should be one of {'C', 'F'}" )
131
136
self .file_like = file_like
132
137
if hasattr (spec , 'get_data_shape' ):
133
138
slope , inter = spec .get_slope_inter ()
@@ -147,6 +152,8 @@ def __init__(self, file_like, spec, *, mmap=True, keep_file_open=None):
147
152
# Permit any specifier that can be interpreted as a numpy dtype
148
153
self ._dtype = np .dtype (self ._dtype )
149
154
self ._mmap = mmap
155
+ if order is not None :
156
+ self .order = order
150
157
# Flags to keep track of whether a single ImageOpener is created, and
151
158
# whether a single underlying file handle is created.
152
159
self ._keep_file_open , self ._persist_opener = \
0 commit comments