Skip to content

Commit 83f23cc

Browse files
authored
Merge pull request #37 from kushbanga/enh/channel_check
Verify number of channels before loading data
2 parents 2b577f6 + 18266b1 commit 83f23cc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

phylib/io/traces.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def _memmap_flat(path, dtype=None, n_channels=None, offset=0, mode='r+'):
158158
assert n_channels > 0
159159
fsize = path.stat().st_size
160160
item_size = np.dtype(dtype).itemsize
161+
assert (fsize - offset) % (item_size * n_channels) == 0,\
162+
'Inconsistent number of channels between the params file and the binary dat file'
161163
n_samples = (fsize - offset) // (item_size * n_channels)
162164
shape = (n_samples, n_channels)
163165
return np.memmap(path, dtype=dtype, offset=offset, shape=shape, mode=mode)

0 commit comments

Comments
 (0)