code: def centroids(self, window_size=5):
          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)