\HeaderA{networkspikes}{Compute network spikes}{networkspikes}
\aliasA{compute.ns}{networkspikes}{compute.ns}
\aliasA{show.ns}{networkspikes}{show.ns}
\keyword{Network spikes, MEA analysis}{networkspikes}
\begin{Description}\relax
Compute the network spikes in an MEA recording, by averaging over all
the electrodes in the array.
\end{Description}
\begin{Usage}
\begin{verbatim}
s$ns <- compute.ns(s, ns.T=0.003, ns.N=10,sur=100)
show.ns(ns, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{s}] MEA data structure
\item[\code{ns.T}] Bin width (in msec) for counting spikes.
\item[\code{ns.N}] Threshold number of active electrodes required to make
network spike
\item[\code{sur}] How many bins either side of peak to retain when computing
the mean network spike
\item[\code{ns}] A network spike data structure, returned by
\code{\LinkA{compute.ns}{compute.ns}}
\item[\code{...}] Other plot arguments to pass to \code{\LinkA{show.ns}{show.ns}}
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
To see the mean network spikes after they have computed, just look at
the mean object.

If you wish to see the individual network spikes, try show.ns(ns, ...)
where the remaining args are passed to the plot function.
\end{Details}
\begin{Value}
A list with the following elements:
\begin{ldescription}
\item[\code{counts}] vector giving the number of active electrodes in each
bin; this can be very long!
\item[\code{ns.N}] The value of ns.N used.
\item[\code{ns.T}] the value of ns.T used.
\item[\code{mean}] The profile of the mean network spike (this is a time
series object)
\item[\code{measures}] If N network spikes were found, this is a matrix with N
rows, one per network spike.
\item[\code{brief}] A short vector summarizing the network spikes.
\end{ldescription}
\end{Value}
\begin{Author}\relax
\end{Author}
\begin{References}\relax
Eytan and Marom (2006) J Neuroscience.
\end{References}
\begin{SeeAlso}\relax
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data.file <- system.file("examples", "TC89_DIV15_A.nexTimestamps",
                         package = "sjemea")
s <- sanger.read.spikes( data.file, beg=400, end=700)
s$ns <- compute.ns(s, ns.T=0.003, ns.N=10,sur=100)
plot(s$ns)
plot(s$ns, xlim=c(450, 500))

plot(s$ns$mean)                         #show mean NS.
summary(s$ns)
s$ns$brief

\end{ExampleCode}
\end{Examples}

