Metric-space analysis of spike trains: theory, algorithms and application