def test_featureprojview(): keys = ( 'features,features_background,masks,clusters,clusters_selected,' 'spiketimes,' 'cluster_colors,fetdim,nchannels,nextrafet,duration,freq').split(',') data = get_data() kwargs = {k: data[k] for k in keys} kwargs['operators'] = [ lambda self: assert_fun(self.view.get_projection(0) == (0, 0)), lambda self: assert_fun(self.view.get_projection(1) == (0, 1)), lambda self: self.view.select_channel(0, 5), lambda self: self.view.select_feature(0, 1), lambda self: self.view.select_channel(1, 32), lambda self: self.view.select_feature(1, 2), lambda self: assert_fun(self.view.get_projection(0) == (5, 1)), lambda self: assert_fun(self.view.get_projection(1) == (32, 2)), lambda self: self.view.toggle_mask(), lambda self: self.view.set_wizard_pair((2, 1), (3, 2)), lambda self: self.view.set_wizard_pair(None, (3, 2)), lambda self: self.view.set_wizard_pair((3, 2), None), lambda self: self.view.set_wizard_pair(None, None), lambda self: self.view.set_projection(0, 2, -1), lambda self: self.view.set_projection(1, 2, -1), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(FeatureProjectionView, **kwargs)
def test_viewdata_correlogramsview_1(): with Experiment('myexperiment', dir=DIRPATH) as exp: chgrp = exp.channel_groups[0] correlograms = create_correlograms([0, 1], 50) data = get_correlogramsview_data(exp, clusters=[0, 1], correlograms=correlograms, ) show_view(CorrelogramsView, **data)
def test_similaritymatrixview(): data = get_data() kwargs = {} kwargs['similarity_matrix'] = create_similarity_matrix(nclusters) kwargs['cluster_colors_full'] = data['cluster_colors_full'] kwargs['operators'] = [ lambda self: self.view.show_selection(5, 6), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(SimilarityMatrixView, **kwargs)
def test_channelview(): # keys = ('channel_names','channel_colors','channel_groups','channel_group_colors','channel_group_names') # data = get_data() # kwargs = {k: data[k] for k in keys} nchannels = 32 nchannelgroups = 4 kwargs = {} channel_names = create_channel_names(nchannels) channel_group_names = create_channel_group_names(nchannelgroups) channel_colors = create_channel_colors(nchannels) channel_groups = create_channel_groups(nchannels) channel_names = create_channel_names(nchannels) group_colors = create_channel_group_colors(nchannelgroups) group_names = create_channel_group_names(nchannelgroups) kwargs["channel_colors"] = channel_colors kwargs["channel_groups"] = channel_groups kwargs["channel_names"] = channel_names kwargs["group_colors"] = group_colors kwargs["group_names"] = group_names kwargs["operators"] = [lambda self: (self.close() if USERPREF["test_auto_close"] != False else None)] # Show the view. window = show_view(ChannelView, **kwargs)
def test_traceview(): trace = create_trace(int(freq * 60), nchannels) ignored_channels = np.arange(5) kwargs = {} kwargs['trace'] = trace kwargs['freq'] = freq kwargs['ignored_channels'] = ignored_channels kwargs['operators'] = [ lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(TraceView, **kwargs)
def test_channelview(): # keys = ('channel_names','channel_colors','channel_groups','channel_group_colors','channel_group_names') # data = get_data() # kwargs = {k: data[k] for k in keys} nchannels = 32 nchannelgroups = 4 kwargs = {} channel_names = create_channel_names(nchannels) channel_group_names = create_channel_group_names(nchannelgroups) channel_colors = create_channel_colors(nchannels) channel_groups = create_channel_groups(nchannels) channel_names = create_channel_names(nchannels) group_colors = create_channel_group_colors(nchannelgroups) group_names = create_channel_group_names(nchannelgroups) kwargs['channel_colors'] = channel_colors kwargs['channel_groups'] = channel_groups kwargs['channel_names'] = channel_names kwargs['group_colors'] = group_colors kwargs['group_names'] = group_names kwargs['operators'] = [ lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. window = show_view(ChannelView, **kwargs)
def test_clusterview(): keys = ('cluster_groups,group_colors,group_names,' 'cluster_sizes').split(',') data = get_data() kwargs = {k: data[k] for k in keys} kwargs['cluster_colors'] = data['cluster_colors_full'] # kwargs['background'] = {5: 1, 7: 2} clusters = get_indices(data['cluster_sizes']) quality = pd.Series(np.random.rand(len(clusters)), index=clusters) kwargs['cluster_quality'] = quality kwargs['operators'] = [ lambda self: self.view.set_quality(quality), lambda self: self.view.set_background({ 5: 1, 7: 2 }), lambda self: self.view.set_background({6: 3}), lambda self: self.view.set_background({}), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. window = show_view(ClusterView, **kwargs)
def test_clusterview(): keys = ('cluster_groups,group_colors,group_names,' 'cluster_sizes').split(',') data = get_data() kwargs = {k: data[k] for k in keys} kwargs['cluster_colors'] = data['cluster_colors_full'] # kwargs['background'] = {5: 1, 7: 2} clusters = get_indices(data['cluster_sizes']) quality = pd.Series(np.random.rand(len(clusters)), index=clusters) kwargs['cluster_quality'] = quality kwargs['operators'] = [ lambda self: self.view.set_quality(quality), lambda self: self.view.set_background({5: 1, 7: 2}), lambda self: self.view.set_background({6: 3}), lambda self: self.view.set_background({}), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. window = show_view(ClusterView, **kwargs)
def test_waveformview(): keys = ('waveforms,clusters,cluster_colors,clusters_selected,masks,' 'geometrical_positions').split(',') data = get_data() kwargs = {k: data[k] for k in keys} operators = [ lambda self: self.view.toggle_mask(), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(WaveformView, operators=operators, **kwargs)
def test_traceview(): trace = create_trace(int(freq * 60), nchannels) ignored_channels = np.arange(5) kwargs = {} kwargs['trace'] = trace kwargs['freq'] = freq kwargs['spiketimes'] = np.array([1, 30, 100]) kwargs['ignored_channels'] = ignored_channels kwargs['operators'] = [ lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(TraceView, **kwargs)
def test_waveformview(): keys = ('waveforms,clusters,cluster_colors,clusters_selected,masks,' 'geometrical_positions' ).split(',') data = get_data() kwargs = {k: data[k] for k in keys} operators = [ lambda self: self.view.toggle_mask(), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(WaveformView, operators=operators, **kwargs)
def test_correlogramsview(): keys = ('clusters_selected,cluster_colors').split(',') data = get_data() kwargs = {k: data[k] for k in keys} kwargs['correlograms'] = create_correlograms(kwargs['clusters_selected'], ncorrbins) kwargs['baselines'] = create_baselines(kwargs['clusters_selected']) kwargs['ncorrbins'] = ncorrbins kwargs['corrbin'] = corrbin kwargs['operators'] = [ lambda self: self.view.change_normalization('uniform'), lambda self: self.view.change_normalization('row'), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(CorrelogramsView, **kwargs)
def test_projectionview(): kwargs = {} kwargs['operators'] = [ lambda self: assert_fun(self.view.get_projection(0) == (0, 0)), lambda self: assert_fun(self.view.get_projection(1) == (0, 1)), lambda self: self.view.select_channel(0, 5), lambda self: self.view.select_feature(0, 1), lambda self: self.view.select_channel(1, 32), lambda self: self.view.select_feature(1, 2), lambda self: assert_fun(self.view.get_projection(0) == (5, 1)), lambda self: assert_fun(self.view.get_projection(1) == (32, 2)), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] kwargs['fetdim'] = 3 kwargs['nchannels'] = 32 kwargs['nextrafet'] = 3 # Show the view. show_view(ProjectionView, **kwargs)
def test_logview(): kwargs = {} kwargs['operators'] = [ lambda self: sys.stdout.write("Hello world!"), lambda self: assert_fun(self.view.get_text() == "Hello world!"), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. window = show_view(LogView, **kwargs)
def test_ipythonview(): if not IPYTHON: return kwargs = {} kwargs['operators'] = [ lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. window = show_view(IPythonView, **kwargs)
def test_featureview(): keys = ('features,features_background,masks,clusters,clusters_selected,' 'spiketimes,' 'cluster_colors,fetdim,nchannels,nextrafet,duration,freq').split(',') data = get_data() kwargs = {k: data[k] for k in keys} kwargs['operators'] = [ lambda self: self.view.toggle_mask(), lambda self: self.view.set_wizard_pair((2, 1), (3, 2)), lambda self: self.view.set_wizard_pair(None, (3, 2)), lambda self: self.view.set_wizard_pair((3, 2), None), lambda self: self.view.set_wizard_pair(None, None), lambda self: (self.close() if USERPREF['test_auto_close'] != False else None), ] # Show the view. show_view(FeatureView, **kwargs)
def test_viewdata_similaritymatrixview_1(): with Experiment('myexperiment', dir=DIRPATH) as exp: chgrp = exp.channel_groups[0] matrix = create_similarity_matrix(2) data = get_similaritymatrixview_data(exp, matrix=matrix) show_view(SimilarityMatrixView, **data)
def test_viewdata_clusterview_1(): with Experiment('myexperiment', dir=DIRPATH) as exp: chgrp = exp.channel_groups[0] data = get_clusterview_data(exp) show_view(ClusterView, **data)
def test_viewdata_featureview_1(): with Experiment('myexperiment', dir=DIRPATH) as exp: chgrp = exp.channel_groups[0] data = get_featureview_data(exp, clusters=[0], nspikes_bg=1000) show_view(FeatureView, **data)
def test_viewdata_waveformview_1(): with Experiment('myexperiment', dir=DIRPATH) as exp: chgrp = exp.channel_groups[0] data = get_waveformview_data(exp, clusters=[0, 1]) show_view(WaveformView, **data)
"""Unit tests for the viewdata module.""" # ----------------------------------------------------------------------------- # Imports # ----------------------------------------------------------------------------- import os import sys import time import tempfile import numpy as np from spikedetekt2.dataio import * from klustaviewa.views.viewdata import * from klustaviewa.views.tests.utils import show_view from klustaviewa.views import WaveformView, FeatureView with Experiment('n6mab041109_60sec_n6mab031109_MKKdistfloat_25_regular100_1', dir='data') as exp: chgrp = exp.channel_groups[0] data = get_waveformview_data(exp, clusters=[0]) show_view(WaveformView, **data)