As far as I know, this effect cannot be eliminated, other than [stratifying][1] the subjects into groups according to type of drug, dosage, duration of use *etc*. and use statistical testing to look for any differences between the groups with, *e.g.*, [linear mixed modeling][2].

However, a cursory search on Google Scholar yields multiple studies where unmedicated folks were successfully recruited in the study, *e.g.* [Kraguljac *et al.* (2016)][3].

<sub>**Reference**  
**-** [Kraguljac *et al*., *Schizophrenia Bull* (2016); **42**(4): 1046–55][3]</sub>

  [1]: https://en.wikipedia.org/wiki/Stratified_sampling
  [2]: https://stats.idre.ucla.edu/other/mult-pkg/introduction-to-linear-mixed-models/
  [3]: https://academic.oup.com/schizophreniabulletin/article/42/4/1046/2413960