#NEWLINE# def select_spikes( cluster_ids = None , max_n_spikes_per_cluster = None , spikes_per_cluster = None ) : #NEWLINE# #INDENT# 'Return a selection of spikes belonging to the specified clusters.' #NEWLINE# assert _is_array_like ( cluster_ids ) #NEWLINE# if ( not len ( cluster_ids ) ) : #NEWLINE# #INDENT# return np . array ( [ ] , dtype = np . int64 ) #NEWLINE# #UNINDENT# if ( max_n_spikes_per_cluster in ( None , 0 ) ) : #NEWLINE# #INDENT# selection = { c : spikes_per_cluster ( c ) for c in cluster_ids } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert ( max_n_spikes_per_cluster > 0 ) #NEWLINE# selection = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# n_clusters = len ( cluster_ids ) #NEWLINE# for cluster in cluster_ids : #NEWLINE# #INDENT# n = int ( ( max_n_spikes_per_cluster * exp ( ( ( - 0.1 ) * ( n_clusters - 1 ) ) ) ) ) #NEWLINE# n = max ( 1 , n ) #NEWLINE# spikes = spikes_per_cluster ( cluster ) #NEWLINE# selection [ cluster ] = regular_subset ( spikes , n_spikes_max = n ) #NEWLINE# #UNINDENT# #UNINDENT# return _flatten_per_cluster ( selection )