def METHOD_NAME(p: ImzMLParser, sp_idxs: Iterable[int]):
    peaks_dfs = []
    spectra = []
    for i in sp_idxs:
        mzs, ints = p.getspectrum(i)
        x, y, z = p.coordinates[i]
        mask = ints > 0
        mzs = mzs[mask].astype(np.float64)
        ints = ints[mask].astype(np.float32)
        peaks_dfs.append(pd.DataFrame({'sp': i, 'mz': mzs, 'ints': ints}))
        spectra.append((i, x, y, z, np.min(mzs), np.max(mzs), np.sum(ints)))
    peaks_df = pd.concat(peaks_dfs)
    spectra_df = pd.DataFrame(
        spectra, columns=['sp', 'x', 'y', 'z', 'mz_lo', 'mz_hi', 'tic']
    ).set_index('sp')
    return peaks_df, spectra_df