<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def processData(self, times, response, test_num, trace_num, rep_num):
 """Calulate spike times from raw response data"""

        # invert polarity affects spike counting
        response = response * self._polarity

        if rep_num == 0:
            # reset
            self.spike_counts = []
            self.spike_latencies = []
            self.spike_rates = []

        fs = 1./(times[1] - times[0])

        # process response; calculate spike times
        spike_times = spikestats.spike_times(response, self._threshold, fs)
        self.spike_counts.append(len(spike_times))
        if len(spike_times) > 0:
            self.spike_latencies.append(spike_times[0])
        else:
            self.spike_latencies.append(np.nan)
        self.spike_rates.append(spikestats.firing_rate(spike_times, times))

        binsz = self._bins[1] - self._bins[0]
        response_bins = spikestats.bin_spikes(spike_times, binsz)
        # self.putnotify('spikes_found', (response_bins, rep_num))
        self.appendData(response_bins, rep_num)