Skip to content
Snippets Groups Projects
Select Git revision
  • c65a43016c3c3acf4256839f45ee4883d0a0cc05
  • master default
  • v0.1
3 results

elephant.tex.backup

Blame
  • user avatar
    Kim authored
    c65a4301
    History
    elephant.tex.backup 14.80 KiB
    \chapter{Elephant functions}
    \label{cha:ele}
    
    List of Elephant functions.
    
    \begin{itemize}
     \item Statistics:
      \begin{itemize}
       \item ISI - Inter Spike Intervals
       \item Mean Firing Rate
       \item CV - Coefficient of Variation (also: LV,CV2)
       \item Instantaneous Firing Rate
       \item Time Histogram
       \item Complexity PDF
      \end{itemize}
      
     \item ASSET - Analysis of Sequence of Synchronous Events in massively parallel spikeTrains
     
     \item SPADE - spatio-temporal Spike PAttern Detection and Evaluation
     
     \item (\textit{UE - Unitary Events})
    
    \end{itemize}
    
    \begin{itshape}
    NOTE: 
    \begin{itemize}
     \item ASSET:\\
    line 376/377: signal.view(pq.Quantities)[elements\_to\_keep] \\
    line 631: mask[\textasciitilde(mask >= -np.inf)] = False
     \item Statistics, IFR:\\
     line 754: sskernel['optw] with 'bootstrap = TRUE'...not needed?
     \item SPADE: FIM instead of fast_fca:\\
     line 558ff, fpgrowth with FIM: keyword argument min/max (now) zmin/zmax
    \end{itemize}
    
    
    \end{itshape}
    
    \section{Required modules and imports}
    \label{sec:mod}
    
    \begin{itemize}
     \item Neo Framework\\
     imported within elephant
     \item Numpy\\
     imported within elephant
     \item Quantities\\
     \textit{ >> import quantities as pq}
     \item Elephant\\
     \begin{itshape}
      >> import elephant.spike\_train\_generation as stg\\
      >> import elephant.asset as asset\\
      >> import elephant.statistics as stat\\
      >> import elephant.spade as spade
     \end{itshape}
    
    \end{itemize}
    
    \section{Required input parameters}
    \label{sec:inp}
    
    \begin{itemize}
     
     %%% GLOBAL
     \item Global parameters
     \begin{itemize}
      \item List of <neo.SpikeTrain> objects\\ 
      -> list of neurons
      \item Firing rate\\ 
      -> Quantities datatype\\
      \textit{>> rate = 15 * pq.Hz}
      \item Length of the Signal/SpikeTrain\\
      -> Quantities datatype\\
      \textit{>> T = 1 * pq.s}
      \item Binsize or sampling period\\
      -> Quantities datatype\\
      \textit{binsize = 5 * pq.ms}
     \end{itemize}
     
     %%% Modules
     \item Additional parameters per module:
     \begin{itemize}
      % Statistics
      \item Statistics:
      \begin{itemize}
       \item Kernel for Instantaneous Firing Rate
      \end{itemize}
      % ASSET
      \item ASSET:
      \begin{itemize}
       \item neo.SpikeTrain objects need additional t\_stop attribute if signal length > 1s (standard is 1s).
       \item Build the intersection matrix \textit{'imat'} and probability matrix \textit{'pmat'}:\\
        - Number of surrogates for the bootstrapping method\\
        - Window size for spike train dithering
       \item Joint probability matrix \textit{'jmat'}, using a suitable filter:\\
        - Filter shape (length, width)\\
        - Number of largest neighbors
       \item Create from \textit{'pmat'} and \textit{'jmat'} a masked version of \textit{'imat'}:\\
        - alpha1\\
        - alpha2
       \item Cluster significant elements of \textit{'imat'} into diagonal structures:\\
        - epsilon\\
        - minimum size\\
        - stretch
      \end{itemize}
      
      % SPADE
      \item SPADE:
      \begin{itemize}
       \item Window length
       \item Some optional parameters
      \end{itemize}
    
     \end{itemize}
    
    \end{itemize}
    
    \begin{itshape}
    NOTE: convert input (numpy array) from simulation to Neo.SpikeTrain and get the needed global parameters
    \end{itshape}
    
    \section{Profiling}
    \label{sec:prof}
    
    % \textit{TODO: \\
    %  - list of test results (runtime)\\
    %  - rough complexity estimation (Landau Notation?) }
    
     
    \subsection{Statistics}
    \label{subsec:stat}
    
    
    \begin{figure}[tbhp]
      \centering
      \includegraphics[width=\linewidth]{graphics/runtime_stat_nn.png}
      \caption[]{Statistics runtime with Signal length of 1 second, rate of 20 Hz and binsize of 5 ms.
      \textbf{Runtime $<$ Signal length, except for IFR}.}
      \label{fig:stat_nn}
    \end{figure}
    
    \begin{figure}[tbhp]
      \centering
      \includegraphics[width=\linewidth]{graphics/runtime_stat_slen.png}
      \caption[]{Statistics runtime with 10 neurons, rate of 20 Hz and binsize of 5 ms.}
      \label{fig:stat_slen}
    \end{figure}
    
    
    Number of Neurons: 1000\\
    Length of Signal: 1000ms
    \begin{verbatim}
    
     %  :      name       : (count) : total time spend
    ==================================================
     0  :      start      :    1    : 0.0
     4  :      DATA       :  1000   : 0.877937078476
     0  :      ISIs       :  1000   : 0.0740790367126
     2  :       MFR       :  1000   : 0.33157491684
     0  :    IFR_start    :  1000   : 0.00199174880981
     3  : IFR_sskernel_density :  1000   : 0.682367086411
    25  : IFR_sskernel_optw :  1000   : 5.00267696381
    14  :    IFR_rescale  :  1000   : 2.86129784584
    11  :     IFR_slice   :  1000   : 2.28599452972
    14  :      IFR_fft    :  1000   : 2.75114107132
    17  :     IFR_rest    :  1000   : 3.52695941925
     0  :     IFR_end     :  1000   : 0.00867342948914
     0  :       CV        :  1000   : 0.06112408638
     4  :      HIST       :    1    : 0.858650922775
     0  :      FANO       :    1    : 0.000443935394287
     4  :      cPDF       :    1    : 0.858818054199
     0  :       end       :    1    : 0.00200796127319
    Total time : 20.1857380867
    
    \end{verbatim}
    
    
    % Number of Neurons: 1000\\
    % Length of Signal: 2000ms
    % \begin{verbatim}
    % 
    %  %  :      name       : (count) : total time spend
    % ==================================================
    %  0  :      start      :    1    : 0.0
    %  4  :      DATA       :  1000   : 0.883128166199
    %  0  :      ISIs       :  1000   : 0.0742020606995
    %  1  :       MFR       :  1000   : 0.335043907166
    %  0  :    IFR_start    :  1000   : 0.0019428730011
    %  3  : IFR_sskernel_density :  1000   : 0.691978693008
    % 26  : IFR_sskernel_optw :  1000   : 5.90263366699
    % 12  :    IFR_rescale  :  1000   : 2.87390136719
    % 18  :     IFR_slice   :  1000   : 4.24568390846
    % 12  :      IFR_fft    :  1000   : 2.77198982239
    % 15  :     IFR_rest    :  1000   : 3.54691672325
    %  0  :     IFR_end     :  1000   : 0.00878882408142
    %  0  :       CV        :  1000   : 0.0607461929321
    %  4  :      HIST       :    1    : 0.868949890137
    %  0  :      FANO       :    1    : 0.000442028045654
    %  4  :      cPDF       :    1    : 0.868922948837
    %  0  :       end       :    1    : 0.00205397605896
    % Total time : 23.1373250484
    % 
    % \end{verbatim}
    % 
    % Number of Neurons: 1000\\
    % Length of Signal: 3000ms
    % \begin{verbatim}
    % 
    %  %  :      name       : (count) : total time spend
    % ==================================================
    %  0  :      start      :    1    : 0.0
    %  4  :      DATA       :  1000   : 0.896424055099
    %  0  :      ISIs       :  1000   : 0.0755770206451
    %  1  :       MFR       :  1000   : 0.334756851196
    %  0  :    IFR_start    :  1000   : 0.00195527076721
    %  3  : IFR_sskernel_density :  1000   : 0.689239501953
    % 24  : IFR_sskernel_optw :  1000   : 6.05566334724
    % 11  :    IFR_rescale  :  1000   : 2.85995459557
    % 25  :     IFR_slice   :  1000   : 6.18957233429
    % 11  :      IFR_fft    :  1000   : 2.76875591278
    % 14  :     IFR_rest    :  1000   : 3.52816939354
    %  0  :     IFR_end     :  1000   : 0.00865769386292
    %  0  :       CV        :  1000   : 0.0605289936066
    %  3  :      HIST       :    1    : 0.877053022385
    %  0  :      FANO       :    1    : 0.000458002090454
    %  3  :      cPDF       :    1    : 0.876579046249
    %  0  :       end       :    1    : 0.00224089622498
    % Total time : 25.2255859375
    % 
    % \end{verbatim}
    
    
    
    \textbf{Summary:}\\
    
    Once per neuron:
    \begin{itemize}
     \item DATA: Data will be taken from simulation. No runtime needed for SpikeTrain creation...
     \item MFR (mean firing rate): 2\% of total Statistics runtime. \\
     Neurons: O(n)\\
     Signal length: O(1)
     \item IFR (instantaneous firing rate): 85\% of total Statistics runtime. \\
     Neurons: O(n)\\ 
     Signal length: O(n)
     \item CV,ISIs: almost no runtime. \\
     Neurons: O(n)\\
     Signal length: O(1)
    \end{itemize}
    
    Once for all neurons:
    \begin{itemize}
     \item HIST: \textasciitilde O(n)
     \item FANO: almost no runtime.
     \item cPDF: \textasciitilde O(n)
    \end{itemize}
    
    
    
    \subsection{ASSET}
    \label{subsec:asset}
    
    \begin{figure}[tbhp]
      \centering
      \includegraphics[width=\linewidth]{graphics/runtime_asset_slen.png}
      \caption[]{ASSET runtime with Signal length of 1 second and binsize of 5 ms.}
      \label{fig:asset_neurons}
    \end{figure}
    
    \textbf{Runtime $>>$ Signal length}\\ %, \textasciitilde $O(n)$}\\
    
    \renewcommand{\arraystretch}{1.5}
    \begin{table}[h!]
     \begin{tabular}{|c|c||c|c|}
     \hline
      & Signal length: 1s & & Num. neurons: 10 \\
      \hline
      \#Neurons & Runtime [s] & Sig.len [s] & Runtime [s] \\
      \hline
      5 & 189 &  &  \\
      10 & 209  & 1 & 209 \\
      100 & 244  & 2 & 719 \\
      1000 & 303 & 3 & 1542 \\
      \hline
     \end{tabular}
    
    \end{table}
    \renewcommand{\arraystretch}{1}
    
    
    Number of Neurons: 5\\
    Length of Signal: 1000ms
    \begin{verbatim}
     %  :      name       : (count) : total time spend
    ==================================================
     0  :      start      :    1    : 0.0
     0  :  generate data  :    1    : 0.005774974823
     0  :  intersec mat   :    1    : 0.0325310230255
     0  :   prob mat mc   :    1    : 0.363873958588
     0  : jmat_pmat_neighb :    1    : 0.0803229808807
     0  : jmat_jsf_uni_init :    1    : 0.00139403343201
    16  : jmat_jsf_uni_diff : 1395360 : 30.1089406013
     7  : jmat_jsf_uni_reshape :  31878  : 12.6044211388
     7  : jmat_jsf_uni_sum :  31878  : 14.2393944263
    56  : jmat_jsf_uni_log :  31878  : 105.956119537
     8  : jmat_jsf_uni_exp :  31878  : 14.9054570198
     7  : jmat_jsf_uni_step : 1395360 : 12.4127993584
     0  :  jmat_jsf_uni   :    1    : 5.96046447754e-06
     0  :      jmat       :    1    : 0.000458002090454
     0  :      mask       :    1    : 0.000148057937622
     0  :      cmat       :    1    : 0.0209028720856
     0  :   extract_sse   :    1    : 6.31809234619e-05
     0  :       end       :    1    : 5.79357147217e-05
    Total time : 190.732665062
    \end{verbatim}
    
    
    \textbf{Summary:}\\
    
    Once for all neurons:
    \begin{itemize}
     \item 100\% of runtime for Joint Probability Matrix (jmat)
     \item Almost no runtime for:
     \begin{itemize}
      \item Intersection Matrix (imat)
      \item Probability Matrix, MonteCarlo (pmat)
      \item Mask (from pmat and jmat)
      \item Cluster Matrix
      \item Extraxt SSE (synchronous spike events)
     \end{itemize}
    
    \end{itemize}
    
    
    
    \subsection{SPADE}
    \label{subsec:spade}
    
    \textbf{Few Neurons: Runtime $<$ Signal length, \textasciitilde $O(n)$}\\
    \textbf{Increasing Neurons: Runtime $>$ Signal length, \textasciitilde $O(n^2)$}\\
    \textbf{Increasing Firing Rate: Runtime $>$ Signal length (>90\% from fast\_fca, \textasciitilde $O(n^2)$}\\
    
    \renewcommand{\arraystretch}{1.5}
    \begin{table}[h!]
     \begin{tabular}{|c|c||c|c|}
     \hline
      & Runtime for: 10 Neurons & & Runtime for: 10 s \\
      \hline
      [s] & data mining / p-value spectrum & \#N & data mining / p-value spectrum \\
      \hline
      1 & 0.03 / 0.4 & 10 & 0.09 / 1.1 \\
      10 & 0.09 / 1.1 & 20 & 0.18 / 3.1 \\
      20 & 0.17 / 2.1 & 30 & 0.3 / 12 \\
      30 & 0.24 / 3.8 & 40 & 0.48 / 150 \\
      \hline
     \end{tabular}
    
    \end{table}
    \renewcommand{\arraystretch}{1}
    
    \newpage
    
    10 Neurons, 10 seconds, 10 Hz
    \begin{verbatim}
     %  :      name       : (count) : total time spend
    ==================================================
     0  :     import      :    1    : 0.0
     0  :    data-gen     :    1    : 0.0178639888763
     0  :   data mining   :    1    : 0.000244140625
     2  : pvalue: surr_init :   10    : 0.110061883926
     6  : pvalue: con_mining_binning :   11    : 0.257157325745
    29  : pvalue: con_mining_context :   11    : 1.34415078163
     0  : pvalue: con_mining_max_spike :   11    : 0.00502347946167
     0  : pvalue: con_mining_max_occ :   11    : 0.00521540641785
    62  : pvalue: con_mining_fast_fca :   11    : 2.81482839584
     0  :  pvalue: step   :   10    : 0.00246357917786
     0  :      spade end      :    1    : 0.000770807266235
    Total time : 4.55782604218
    \end{verbatim}
    
    
    10 Neurons, 10 seconds, 20 Hz
    \begin{verbatim}
     %  :      name       : (count) : total time spend
    ==================================================
     0  :    data-gen     :    1    : 0.023374080658
     1  : pvalue: con_mining_binning :   11    : 0.258544206619
     3  : pvalue: con_mining_context :   11    : 0.566279649734
     0  : pvalue: con_mining_max_spike :   11    : 0.00187826156616
     0  : pvalue: con_mining_max_occ :   11    : 0.00199890136719
     1  :     fast_fca_lattice_init :   11    : 0.24431180954
     3  :     fast_fca_lattice__compUpNeigh_init :  4616   : 0.638545274734
    32  :     fast_fca_lattice__compUpNeigh_intent_update : 4813666 : 6.31500482559
     0  :     fast_fca_lattice__compUpNeigh_else1 :   850   : 0.0161757469177
     0  :     fast_fca_lattice__compUpNeigh_else2 :  7213   : 0.0132088661194
    25  :     fast_fca_lattice__compUpNeigh_if1 : 4812816 : 4.93453645706
    24  :     fast_fca_lattice__compUpNeigh_if2 : 4806453 : 4.67416810989
     2  :     fast_fca_lattice__compUpNeigh_for2 :  7213   : 0.329411268234
     1  :     fast_fca_lattice_compUpNeigh :  4616   : 0.167640447617
     6  :     fast_fca_lattice_end :   11    : 1.15846991539
     0  : pvalue: con_mining_fast_fca :   11    : 0.0549900531769
     0  :   data mining   :    1    : 0.000248908996582
     1  : pvalue: surr_init :   10    : 0.112371206284
     0  :  pvalue: step   :   10    : 0.00310611724854
     0  : pvalue spectrum :    1    : 3.69548797607e-05
     0  :    spade end    :    1    : 0.000790119171143
    Total time : 19.5150949955
    \end{verbatim}
    
    
    
     
    
    \subsection{Unitary Events (UE)}
    \label{subsec:ue}
    
    Parameters:
    \begin{itemize}
     \item spiketrains (number of trials, number of neurons, timestamps)
     \item binsize
     \item winsize (size of window)
     \item winstep (window step)
     \item pattern hash
    \end{itemize}
    Test for runtime: \textbf{(TODO: finfish compelxity test)}
    \begin{itemize}
     \item number of trials \textbf{\textasciitilde $O(?)$}
     \item number of neurons \textbf{\textasciitilde $O(?)$}
     \item timestamps (firing rate,signal length) \textbf{\textasciitilde $O(?)$}
     \item winsize, winstep \textbf{\textasciitilde $O(?)$}
     \item hash?
    \end{itemize}
    
    
    \textbf{Example1:}\\
    number of trials = 36\\
    number of neurons: 2\\
    firing rate = 10 Hz, signal length = 3s\\
    winsize = 100ms, winstep = 10ms
    \begin{verbatim}
     %  :      name       : (count) : total time spend
    ==================================================
    
     0  :      start      :    1    : 0.0
    12  :    data_init    :    1    : 0.250292062759
     0  :      init       :    1    : 0.00165700912476
     9  : binnedSpikeTrain_bool :    1    : 0.182360887527
     0  :  init_indices   :    1    : 2.09808349609e-05
    79  : _for_num_trials :  10476  : 1.64006233215
     0  :   for_win_pos   :   291   : 0.000309705734253
     0  :     UE_end      :    1    : 6.38961791992e-05
     0  :       end       :    1    : 0.000160217285156
    Total time : 2.0749270916
    \end{verbatim}
    
    
    \textbf{Example2:}\\
    number of trials = 36\\
    number of neurons: 64\\
    firing rate = 10 Hz, signal length = 3s\\
    winsize = 100ms, winstep = 10ms
    \begin{verbatim}
     %  :      name       : (count) : total time spend
    ==================================================
     0  :      start      :    1    : 0.0
    52  :    data_init    :    1    : 6.45083498955
     0  :      init       :    1    : 0.00162696838379
    31  : binnedSpikeTrain_bool :    1    : 3.87675404549
     0  :  init_indices   :    1    : 2.8133392334e-05
    17  : _for_num_trials :  10476  : 2.19099497795
     0  :   for_win_pos   :   291   : 0.000298976898193
     0  :     UE_end      :    1    : 0.000151872634888
     0  :       end       :    1    : 0.00414204597473
    Total time : 12.5248320103
    \end{verbatim}