Skip to content

Commit ab6f30b

Browse files
committed
RF: read block_size only for mlist entry
1 parent ee40bbb commit ab6f30b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

nibabel/ecat.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def read_mlist(fileobj, endianness):
360360
* n_rows - number of mlist rows in this block (between ?0 and 31) (called
361361
`nused` in CTI code).
362362
"""
363-
dt = np.dtype(np.int32) # should this be uint32 given mlist dtype?
363+
dt = np.dtype(np.int32)
364364
if not endianness is native_code:
365365
dt = dt.newbyteorder(endianness)
366366
mlists = []
@@ -369,7 +369,7 @@ def read_mlist(fileobj, endianness):
369369
while True:
370370
# Read block containing mlist entries
371371
fileobj.seek((mlist_block_no - 1) * BLOCK_SIZE) # fix 1-based indexing
372-
dat = fileobj.read(128 * 32) # isn't this too long? Should be 512?
372+
dat = fileobj.read(BLOCK_SIZE)
373373
rows = np.ndarray(shape=(32, 4), dtype=dt, buffer=dat)
374374
# First row special, points to next mlist entries if present
375375
n_unused, mlist_block_no, _, n_rows = rows[0]
@@ -381,8 +381,6 @@ def read_mlist(fileobj, endianness):
381381
mlist_index += n_rows
382382
if mlist_block_no <= 2: # should block_no in (1, 2) be an error?
383383
break
384-
# Code in ``get_frame_order`` seems to imply ids can be < 0; is that
385-
# true? Should the dtype be uint32 or int32?
386384
return np.row_stack(mlists)
387385

388386

0 commit comments

Comments
 (0)