prepare function

Apply treatments and restrict to useful variables.