File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -314,12 +314,12 @@ def set_zooms(self, zooms):
314
314
def get_data_shape (self ):
315
315
''' Get shape of data
316
316
'''
317
- dims = self ._header_data ['dims' ][:]
317
+ shape = tuple ( self ._header_data ['dims' ])
318
318
# If last dimension (nframes) is 1, remove it because
319
319
# we want to maintain 3D and it's redundant
320
- if int ( dims [ - 1 ]) == 1 :
321
- dims = dims [: - 1 ]
322
- return tuple ( int ( d ) for d in dims )
320
+ if shape [ 3 ] == 1 :
321
+ shape = shape [: 3 ]
322
+ return shape
323
323
324
324
def set_data_shape (self , shape ):
325
325
''' Set shape of data
@@ -329,15 +329,10 @@ def set_data_shape(self, shape):
329
329
shape : sequence
330
330
sequence of integers specifying data array shape
331
331
'''
332
- dims = self ._header_data ['dims' ]
333
- # If len(dims) is 3, add a dimension. MGH header always
334
- # needs 4 dimensions.
335
- if len (shape ) == 3 :
336
- shape = list (shape )
337
- shape .append (1 )
338
- shape = tuple (shape )
339
- dims [:] = shape
340
- self ._header_data ['delta' ][:] = 1.0
332
+ shape = tuple (shape )
333
+ if len (shape ) > 4 :
334
+ raise ValueError ("Shape may be at most 4 dimensional" )
335
+ self ._header_data ['dims' ] = shape + (1 ,) * (4 - len (shape ))
341
336
342
337
def get_data_bytespervox (self ):
343
338
''' Get the number of bytes per voxel of the data
You can’t perform that action at this time.
0 commit comments