@@ -109,7 +109,7 @@ def fk(x, si=.002, dx=1, vbounds=None, btype='highpass', ntr_pad=0, ntr_tap=None
109109 return xf / gain
110110
111111
112- def car (x , collection = None , lagc = 300 , butter_kwargs = None ):
112+ def car (x , collection = None , lagc = 300 , butter_kwargs = None , ** kwargs ):
113113 """
114114 Applies common average referencing with optional automatic gain control
115115 :param x: the input array to be filtered. dimension, the filtering is considering
@@ -223,7 +223,7 @@ def interpolate_bad_channels(data, channel_labels=None, h=None, p=1.3, kriging_d
223223 return data
224224
225225
226- def destripe (x , fs , neuropixel_version = 1 , butter_kwargs = None , k_kwargs = None , channel_labels = None ):
226+ def destripe (x , fs , neuropixel_version = 1 , butter_kwargs = None , k_kwargs = None , channel_labels = None , k_filter = True ):
227227 """Super Car (super slow also...) - far from being set in stone but a good workflow example
228228 :param x: demultiplexed array (nc, ns)
229229 :param fs: sampling frequency
@@ -241,18 +241,18 @@ def destripe(x, fs, neuropixel_version=1, butter_kwargs=None, k_kwargs=None, cha
241241 :param butter_kwargs: (optional, None) butterworth params, see the code for the defaults dict
242242 :param k_kwargs: (optional, None) K-filter params, see the code for the defaults dict
243243 can also be set to 'car', in which case the median accross channels will be subtracted
244+ :param k_filter (True): applies k-filter by default, otherwise, apply CAR.
244245 :return: x, filtered array
245246 """
246247 if butter_kwargs is None :
247248 butter_kwargs = {'N' : 3 , 'Wn' : 300 / fs * 2 , 'btype' : 'highpass' }
248249 if k_kwargs is None :
249250 k_kwargs = {'ntr_pad' : 60 , 'ntr_tap' : 0 , 'lagc' : 3000 ,
250251 'butter_kwargs' : {'N' : 3 , 'Wn' : 0.01 , 'btype' : 'highpass' }}
251- spatial_fcn = lambda dat : kfilt (dat , ** k_kwargs ) # noqa
252- elif isinstance (k_kwargs , dict ):
252+ if k_filter :
253253 spatial_fcn = lambda dat : kfilt (dat , ** k_kwargs ) # noqa
254254 else :
255- spatial_fcn = lambda dat : car (dat , lagc = int ( 0.1 * fs ) ) # noqa
255+ spatial_fcn = lambda dat : car (dat , ** k_kwargs ) # noqa
256256 h = neuropixel .trace_header (version = neuropixel_version )
257257 if channel_labels is True :
258258 channel_labels , _ = detect_bad_channels (x , fs )
0 commit comments