Did you know that morphine, codeine, and heroin are produced from the seeds of certain kinds of poppy flowers? Morphine and codeine are often used as medications for treating pain, and all three—known as opiates—can be abused.

Poppy seeds are also used as a flavorful ingredient in many popular foods, including muffins and bagels. Although poppy seeds used in food are produced legally, they can contain high enough levels of the opioid to trigger a positive result on some types of drug urine tests.

So, you may wonder, if you ate a poppy seed bagel for breakfast, could results of a drug test come out positive for these opiates?

Once poppy seeds are eaten, the body develops detectable levels of opiates almost immediately. As a 2003 “MythBusters” episode notes, someone can test positive for opiates as soon as 2 hours after eating a poppy seed-loaded item. Other studies have shown that the levels remain elevated for up to 3 days.

School athletes may want to pay attention to this. Across the country, about one in seven school districts perform some sort of drug testing on their students. Students in middle school, high school, or college may be asked to take a drug test in order to participate in athletic activities or other programs.

False positives (when the test wrongly reports someone used drugs) can and do happen. For example, Federal prisoners, who undergo drug tests with some frequency, are forbidden to eat foods that contain poppy seeds.

Over the past 20 years, legal cases by law enforcement officials, workers, athletes, or students “caught” or penalized for positive urine tests for opiates have made famous the “poppy seed bagel defense.” A series of lawsuits and evolving research have proven that an individual’s urine can indeed produce a positive test result for opiates after the person eats poppy seed-containing cakes, muffins, or bagels. In one large study, up to 87 percent of tests considered positive for opiate use were due in part to poppy seeds in foods as well as prescription medications.

When positive test results are proven to have been due to eating poppy seeds, they are overturned. More accurate measurement of opiate levels can be done by analyzing a blood or hair sample. These tests cost more and may be used to double-check a positive urine result.

To all you poppy seed lovers out there: They can be a tasty treat in favorite foods, but may be one to avoid before undergoing drug testing. Keep things simple: Try an onion bagel instead.

Jack Maypole, M.D., is the Director of Pediatrics at the South End Community Health Center as well as the Comprehensive Care Program at Boston Medical Center. He is also an assistant professor of pediatrics at Boston University School of Medicine. Cartooning has been a lifelong fascination and hobby.

Update: To learn more about drug testing, read these posts on professional football, cycling, and video gaming, and this post on how alcohol breath tests work.