def get_extraction_region(hdu, segment, mode='spectrum'):
    """Get y_start,y_end for given extraction

    """
    if mode == 'spectrum':
        height = hdu[1].header['SP_HGT_%s' % segment]
        location = hdu[1].header['SP_LOC_%s' % segment]
    elif mode == 'background1':
        height = hdu[1].header['B_HGT1_%s' % segment]
        location = hdu[1].header['B_BKG1_%s' % segment]
    elif mode == 'background2':
        height = hdu[1].header['B_HGT2_%s' % segment]
        location = hdu[1].header['B_BKG2_%s' % segment]
    y_start = location - height // 2
    y_end = location + height // 2
    return y_start, y_end
