The court may, and upon objection shall, exclude testimony in the form of an opinion that is based in whole or in significant part on matter that is not a proper basis for such an opinion. In such case, the witness may, if there remains a proper basis for his opinion, then state his opinion after excluding from consideration the matter determined to be improper.