<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def centroids(self, window_size=5):
 """ Detects peaks in raw data. :param mzs: sorted array of m/z values :param intensities: array of corresponding intensities :param window_size: size of m/z averaging window :returns: isotope pattern containing the centroids :rtype: CentroidedSpectrum """

        self.sortByMass()
        mzs = _cffi_buffer(self.masses, 'd')
        intensities = _cffi_buffer(self.intensities, 'f')
        n = self.size
        p = ims.spectrum_new_from_raw(n, mzs.ptr, intensities.ptr, int(window_size))
        return _new_spectrum(CentroidedSpectrum, p)