Kaien Yang, 14, was a runner-up in the Broadcom MASTERS national science competition for an app he developed to gauge the risk a patient will develop depression based on brain scans. He is an eighth-grader at the Nysmith School for the Gifted in Herndon, Va. (Linda Doane/Society for Science and the Public)

Kaien Yang had a family member who was prone to mood swings and bad headaches, and his parents explained that there was something wrong with his relative’s brain — the man’s cerebellum had shrunk.

The brain has long fascinated Kaien, 14 — “It’s only three pounds of matter, but it’s so exquisite” — and his interest deepened when he accompanied his mother, Fengrong Li, to doctor’s appointments at Johns Hopkins Bayview, where she received treatment for a brain aneurysm in 2011. He looked curiously over brain scans, and he once brought along one of his favorite books, “Gifted Hands,” the autobiography of neurosurgeon and former presidential candidate Ben Carson, and was elated to meet his idol.

With his late relative’s struggles as inspiration, Kaien has developed a diagnostic app that aims to identify the probability that a patient will develop depression based on changes in the hippocampus. He did extensive research to figure out what changes in the brain are related to depression.

Kaien’s project earned him a $10,000 prize from the Broadcom MASTERS competition, a national science competition for middle schoolers. It is the middle school version of the oldest and most prestigious high school science competition known as the Regeneron Science Talent Search.

Eleanor Sigrest, 13, took home the top prize for the Broadcom MASTERS national science competition for her research on cold-gas rockets, inspired when she saw a SpaceX rocket’s failed landing. Eleanor is a student at Benton Middle School in Manassas, Va. (Linda Doane/Society for Science & the Public)

Kaien, an eighth-grader at the Nysmith School for the Gifted in Herndon, Va., is one of two Northern Virginia middle schoolers to earn an award in the competition. Eleanor Wren Sigrest, a 13-year-old eighth-grader at Benton Middle School in Manassas, Va., won the top prize of $25,000 for her research on the nozzles of cold gas rockets, which are used to stabilize spacecraft as they land.

Out of about 2,300 competitors nationwide, just 30 middle schoolers made it to the final round of the competition, a multiday science fair that included science-related challenges. Competitors were judged on their research projects and on their ability to work in teams and collaborate in the competitions.

The competition is designed to groom the next generation of scientists and to inspire youngsters to pursue careers in science, technology, engineering and math (STEM). Organizers hope that young scientists such as Kaien, Eleanor and the competition’s two other winners — 15-year-old Aria Eppinger of Pittsburgh, and Nathan Deng, 14, of San Marino, Calif. — will be leaders in science and innovation.

“This is the most important beginning of the talent pipeline for STEM,” said Maya Ajmera, chief executive of the Society for Science and the Public, the nonprofit organization that runs the competition. “You have to get young people in middle school, especially girls, in the field.”

Eleanor, like Kaien, found inspiration for her project in real life. Eleanor’s father, Wren, is a former engineer, and her crowded home in Woodbridge, Va., doubles as a makerspace, replete with art supplies, glue guns and even a weaving loom. The busy middle schooler, the third of five children, builds and launches model rockets with her father. Her sister, Piper, is a student at MIT and spent the summer of 2015 interning at SpaceX.

Eleanor once sat glued to a laptop watching riveting footage of a failed landing of a SpaceX rocket that was equipped with small, cold-gas rockets, which are intended to help guide it into position as it lands.

That got Eleanor interested in the nozzles on cold-gas rockets, which are fine-tuned to deliver precise amounts of thrust so they can be used for navigation and stabilization. Eleanor opted to study cold-gas rockets — which do not use any combustion — for another reason: “Because my mom said no explosives on the kitchen table.”

The nozzles, which have a narrow and a wide end, are often designed with 15-degree half-angles, a measurement that had become a sort of engineering “rule of thumb,” Eleanor said. Eleanor wondered if there might be a better half-angle, if a nozzle that had a proportionally wider or narrower end would produce better thrust. She designed a series of nozzles and built them on a 3-D printer and then tested them. Her findings? Nozzles with a 20-degree half-angle produce the best thrust.

As she pondered whether she had disproved a conventional understanding, she recalls doubting herself, thinking: “This is really weird, because engineers and scientists, they’re supposed to be the smart guys. They’re supposed to know everything.”

But she retested the nozzles with a variety of gases with the same result, leading to her project: “Rockets and Nozzles, and Thrusts, Oh My!”

She hopes to follow her sister to MIT, using the prize money toward tuition. But she has grander dreams after that, and she hopes the top prize will give people confidence in her abilities. “I’m going to show the world that I’m going to be the first person on Mars,” Eleanor said.

Kaien said he, too, is saving his prize money for college, hoping to attend Stanford or Yale.

But first, he wants to refine his app and get it to doctors, who could use it to gauge a patient’s risk of depression and potentially get them a diagnosis earlier.

“Depression is a really serious psychological disorder,” Kaien said. “The key to stopping this epidemic is early detection and early prevention.”