Skip to content

Commit 6d98a80

Browse files
committed
Merge remote-tracking branch 'origin/master' into ibl_tests
2 parents f72849c + 3e4dfb9 commit 6d98a80

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

phylib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def add_default_handler(level='INFO', logger=logger):
6262

6363
def _add_log_file(filename): # pragma: no cover
6464
"""Create a log file with DEBUG level."""
65-
handler = logging.FileHandler(filename)
65+
handler = logging.FileHandler(str(filename))
6666
handler.setLevel(logging.DEBUG)
6767
formatter = _Formatter(fmt=_logger_fmt, datefmt=_logger_date_fmt)
6868
handler.setFormatter(formatter)

phylib/io/model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def compute_features(waveforms):
239239
return features
240240

241241

242-
#-----------------------------------------------------------------------------
242+
#------------------------------------------------------------------------------
243243
# I/O util functions
244244
#------------------------------------------------------------------------------
245245

@@ -683,10 +683,13 @@ def _load_templates(self):
683683
try:
684684
path = self._find_path(
685685
'templates.npy', 'templates.waveforms.npy', 'templates.waveforms.*.npy')
686-
data = self._read_array(path, mmap_mode='r')
686+
data = self._read_array(path, mmap_mode='r+')
687687
data = np.atleast_3d(data)
688688
assert data.ndim == 3
689689
assert data.dtype in (np.float32, np.float64)
690+
# WARNING: this will load the full array in memory, might cause memory problems
691+
empty_templates = np.all(np.all(np.isnan(data), axis=1), axis=1)
692+
data[empty_templates, ...] = 0
690693
n_templates, n_samples, n_channels_loc = data.shape
691694
except IOError:
692695
return
@@ -818,6 +821,7 @@ def _find_best_channels(self, template, amplitude_threshold=None):
818821
# Compute the template amplitude on each channel.
819822
assert template.ndim == 2 # shape: (n_samples, n_channels)
820823
amplitude = template.max(axis=0) - template.min(axis=0)
824+
assert not np.all(np.isnan(amplitude)), "Template is all NaN!"
821825
assert amplitude.ndim == 1 # shape: (n_channels,)
822826
# Find the peak channel.
823827
best_channel = np.argmax(amplitude)

phylib/io/traces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
DEFAULT_CHUNK_DURATION = 600.0 # seconds
3131

3232

33-
EPHYS_RAW_EXTENSIONS = ('.dat', '.bin', '.raw')
33+
EPHYS_RAW_EXTENSIONS = ('.dat', '.bin', '.raw', '.mda')
3434

3535

3636
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)