The selective removal of oxygen from rare earth and thorium metals through oxyhalide formation