def METHOD_NAME(ds_segm_it, centr_df, nrows, ncols, isocalc) -> Iterator[FormulaImageItem]:
    for ds_segm_df in ds_segm_it:
        ds_segm_mz_min, _ = isocalc.mass_accuracy_bounds(ds_segm_df.mz.values[0])
        _, ds_segm_mz_max = isocalc.mass_accuracy_bounds(ds_segm_df.mz.values[-1])
        centr_df_slice = centr_df[(centr_df.mz >= ds_segm_mz_min) & (centr_df.mz <= ds_segm_mz_max)]
        centr_mzs = centr_df_slice.mz.values
        centr_ints = centr_df_slice.int.values
        centr_f_inds = centr_df_slice.formula_i.values
        centr_p_inds = centr_df_slice.peak_i.values
        lower, upper = isocalc.mass_accuracy_bounds(centr_mzs)
        lower_inds = np.searchsorted(ds_segm_df.mz.values, lower, 'l')
        upper_inds = np.searchsorted(ds_segm_df.mz.values, upper, 'r')
        # Note: consider going in the opposite direction so that
        # formula_image_metrics can check for the first peak images instead of the last
        for i, (lo_i, up_i) in enumerate(zip(lower_inds, upper_inds)):
            image = mz_image = None
            if up_i - lo_i > 0:
                # Copy ints/mzs so that these slices don't pin the whole dataset segment in memory
                ints = ds_segm_df.int.values[lo_i:up_i].astype('f', copy=True)
                mzs = ds_segm_df.mz.values[lo_i:up_i].astype('f', copy=True)
                inds = ds_segm_df.sp_idx.values[lo_i:up_i]
                row_inds, col_inds = np.divmod(inds, ncols, dtype='i')
                # The row_inds/col_inds can be safely shared between the two coo_matrixes
                image = coo_matrix((ints, (row_inds, col_inds)), shape=(nrows, ncols), copy=False)
                mz_image = coo_matrix((mzs, (row_inds, col_inds)), shape=(nrows, ncols), copy=False)
            yield FormulaImageItem(
                formula_i=centr_f_inds[i],
                peak_i=centr_p_inds[i],
                theo_mz=centr_mzs[i],
                theo_int=centr_ints[i],
                # If this image includes the last element of the dataset segment, it's possible the
                # next dataset segment will include more pixels from this image.
                may_be_split=up_i >= len(ds_segm_df) - 1,
                image=image,
                mz_image=mz_image,
            )