Skip to content

Commit b28485e

Browse files
committed
Merge branch 'develop' into postdlc_local
2 parents 78b790a + 2a0d0c7 commit b28485e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

brainbox/io/spikeglx.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,13 @@ def stream(pid, t0, nsecs=1, one=None, cache_folder=None, remove_cached=False, t
116116
:param one: An instance of ONE
117117
:param cache_folder:
118118
:param typ: 'ap' or 'lf'
119-
:return: sr, dsets, t0
119+
:return: sr, t0
120120
"""
121-
CHUNK_DURATION_SECS = 1 # the mtscomp chunk duration. Right now it's a constant
122121
if nsecs > 10:
123-
ValueError(f'Streamer works only with 10 or less seconds, set nsecs to lesss than {nsecs}')
122+
ValueError(f'Streamer works only with 10 or less seconds, set nsecs to less than {nsecs}')
124123
assert one
125124
assert typ in ['lf', 'ap']
126-
t0 = np.floor(t0 / CHUNK_DURATION_SECS) * CHUNK_DURATION_SECS
125+
127126
if cache_folder is None:
128127
samples_folder = Path(one.alyx._par.CACHE_DIR).joinpath('cache', typ)
129128

@@ -134,8 +133,13 @@ def stream(pid, t0, nsecs=1, one=None, cache_folder=None, remove_cached=False, t
134133
ch_file = one._download_datasets(ch_rec)[0]
135134
one._download_datasets(meta_rec)[0]
136135

137-
first_chunk = int(t0 / CHUNK_DURATION_SECS)
138-
last_chunk = int((t0 + nsecs) / CHUNK_DURATION_SECS) - 1
136+
import json
137+
with open(ch_file) as fid:
138+
chinfo = json.load(fid)
139+
tbounds = np.array(chinfo['chunk_bounds']) / chinfo['sample_rate']
140+
first_chunk = np.maximum(0, np.searchsorted(tbounds, t0 + 0.01) - 1)
141+
last_chunk = np.maximum(0, np.searchsorted(tbounds, t0 + + 0.01 + nsecs) - 2)
142+
t0 = tbounds[first_chunk]
139143

140144
samples_folder.mkdir(exist_ok=True, parents=True)
141145
sr = spikeglx.download_raw_partial(

ibllib/dsp/voltage.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,19 @@ def destripe(x, fs, neuropixel_version=1, butter_kwargs=None, k_kwargs=None, cha
280280
return x
281281

282282

283-
def destripe_lfp(x, fs):
283+
def destripe_lfp(x, fs, channel_labels=None, **kwargs):
284284
"""
285285
Wrapper around the destipe function with some default parameters to destripe the LFP band
286+
See help destripe function for documentation
286287
:param x:
287288
:param fs:
288289
:return:
289290
"""
290-
butter_kwargs = {'N': 3, 'Wn': 2 / fs * 2, 'btype': 'highpass'}
291-
k_kwargs = {'ntr_pad': 60, 'ntr_tap': 0, 'lagc': None,
292-
'butter_kwargs': {'N': 3, 'Wn': 0.001, 'btype': 'highpass'}}
293-
# butterworth, for display only
294-
channel_labels, channel_features = detect_bad_channels(x, fs=fs, psd_hf_threshold=1.4)
295-
return destripe(x, fs, butter_kwargs=butter_kwargs, channel_labels=channel_labels, k_kwargs=k_kwargs)
291+
kwargs['butter_kwargs'] = {'N': 3, 'Wn': 2 / fs * 2, 'btype': 'highpass'}
292+
kwargs['k_filter'] = False
293+
if channel_labels is True:
294+
kwargs['channel_labels'], _ = detect_bad_channels(x, fs=fs, psd_hf_threshold=1.4)
295+
return destripe(x, fs, **kwargs)
296296

297297

298298
def decompress_destripe_cbin(sr_file, output_file=None, h=None, wrot=None, append=False, nc_out=None, butter_kwargs=None,

0 commit comments

Comments
 (0)