def pull_reference(integrate_mtz):
    """Generate reference data set from integrate.hkl, check out the calculated
    x, y and z centroids as well as the Miller indices as coordinates in some
    high dimensional space. Only consider measurements with meaningful
    centroids..."""
    from iotbx import mtz
    m = mtz.object(integrate_mtz)
    hkl = m.extract_original_index_miller_indices()
    b0 = m.batches()[0]
    for c in m.columns():
        if c.label() == 'I':
            i_lp = c.extract_valid_values()
        elif c.label() == 'SIGI':
            sigi = c.extract_valid_values()
        elif c.label() == 'XDET':
            xdet = c.extract_valid_values()
        elif c.label() == 'YDET':
            ydet = c.extract_valid_values()
        elif c.label() == 'ROT':
            rot = c.extract_valid_values()
        elif c.label() == 'LP':
            lp = c.extract_valid_values()
    xyz = []
    dx = b0.detlm()[1]
    dz = b0.phiend() - b0.phistt()
    z0 = b0.phistt()
    for x, y, r in zip(xdet, ydet, rot):
        _x = y
        _y = x
        _z = (r - z0) / dz
        xyz.append((_x, _y, _z))
    i = i_lp / lp
    print('Reference: %d observations' % len(hkl))
    return hkl, i, sigi, xyz
