def test_hasattribute_exceptions_for_optional_deps(): '''test whether HasAttributes raises exceptions for optional features''' required_dep = base.register("Data", DummyDataProvider()) optional_dep = base.register('OptionalData', DummyDataWithZeroDivision()) comp = Dummy() data = comp.get_optional_data() assert True
def test_cluster_component_smart_update(): feature_comp = base.register("FeatureSource", DummyFeatureExtractor()) cluster_comp = components.ClusterAnalyzer("k_means", 2) labs = cluster_comp.labels # this is a workaround to call _cluster() # cluster_comp should NOT recluster when updated, if the number of # spikes didn't change cluster_comp.delete_cells(1) # modify lablels labels_orig = cluster_comp.labels.copy() feature_comp.add_feature('new_feature') feature_comp.update() labels_new_feat = cluster_comp.labels.copy() # cluster_comp should recluster when updated, if the number of # spikes DID change feature_comp.add_spikes(10) feature_comp.update() labels_new_spikes = cluster_comp.labels.copy() test1 = (labels_orig == labels_new_feat).all() test2 = len(labels_new_spikes) != len(labels_new_feat) ok_(test1 and test2)
# spike detection/extraction properties contact = 3 detection_type = "max" thresh = "auto" filter_freq = (800.0, 100.0) sp_win = [-0.6, 0.8] path = filter(None, os.environ['DATAPATH'].split(os.sep)) + [hdf5filename] hdf5file = os.path.join(os.sep, *path) io = components.PyTablesSource(hdf5file, dataset) io_filter = components.FilterStack() base.register("RawSource", io) base.register("EventsOutput", io) base.register("SignalSource", io_filter) base.register("SpikeMarkerSource", components.SpikeDetector(contact=contact, thresh=thresh, type=detection_type, sp_win=sp_win, resample=1, align=True)) base.register("SpikeSource", components.SpikeExtractor(sp_win=sp_win)) base.register("FeatureSource", components.FeatureExtractor()) base.register("LabelSource", components.ClusterAnalyzer("gmm", 4)) browser = components.SpikeBrowser() feature_plot = components.PlotFeaturesTimeline()
from spike_sort.io import neo_filters #################################### # Adjust these fields for your needs sp_win = [-0.6, 0.8] url = 'https://portal.g-node.org/neo/axon/File_axon_1.abf' path = 'file_axon.abf' import urllib urllib.urlretrieve(url, path) io = neo_filters.NeoSource(path) base.register("SignalSource", io) base.register( "SpikeMarkerSource", components.SpikeDetector(contact=0, thresh='auto', type='max', sp_win=sp_win, resample=1, align=True)) base.register("SpikeSource", components.SpikeExtractor(sp_win=sp_win)) browser = components.SpikeBrowser() browser.show()
def test_missing_optional_dependency(): required_dep = base.register("Data", DummyDataProvider()) comp = Dummy() ok_(comp.opt_con is None)
def test_register_new_feature_by_register(): dep_comp = DummyDataProvider() added_comp = base.register("Data", dep_comp) comp = Dummy() ok_(comp.get_data() == 'some data') assert dep_comp is added_comp
# spike detection/extraction properties contact = 3 detection_type = "max" thresh = "auto" filter_freq = (800.0, 100.0) sp_win = [-0.6, 0.8] path = filter(None, os.environ['DATAPATH'].split(os.sep)) + [hdf5filename] hdf5file = os.path.join(os.sep, *path) io = components.PyTablesSource(hdf5file, dataset) io_filter = components.FilterStack() base.register("RawSource", io) base.register("EventsOutput", io) base.register("SignalSource", io_filter) base.register( "SpikeMarkerSource", components.SpikeDetector(contact=contact, thresh=thresh, type=detection_type, sp_win=sp_win, resample=1, align=True)) base.register("SpikeSource", components.SpikeExtractor(sp_win=sp_win)) base.register("FeatureSource", components.FeatureExtractor()) base.register("LabelSource", components.ClusterAnalyzer("gmm", 4)) browser = components.SpikeBrowser()
from spike_beans import components, base from spike_sort.io import neo_filters #################################### # Adjust these fields for your needs sp_win = [-0.6, 0.8] url = 'https://portal.g-node.org/neo/axon/File_axon_1.abf' path = 'file_axon.abf' import urllib urllib.urlretrieve(url, path) io = neo_filters.NeoSource(path) base.register("SignalSource", io) base.register("SpikeMarkerSource", components.SpikeDetector(contact=0, thresh='auto', type='max', sp_win=sp_win, resample=1, align=True)) base.register("SpikeSource", components.SpikeExtractor(sp_win=sp_win)) browser = components.SpikeBrowser() browser.show()