Faculty Spotlight: Joshua Barrios, PhD
Using Deep Learning to Improve Heart Health
His intellectual passions have led him from philosophy to neuroscience to cardiology; what connects these disparate fields for Joshua Barrios, PhD, is the pursuit of truth.
Born and raised in Baton Rouge, La., as a young student Dr. Barrios developed an interest in philosophy. “I was thinking a lot about epistemology – how we know what we know – and the philosophy of science,” he said. “How cool is it that as scientists, our job is to find truth?”
Dr. Barrios completed his PhD in neurobiology and anatomy at the University of Utah. He was part of a lab that studied dopaminergic control of motor behaviors. “That’s been studied for a long time in the context of neurodegenerative diseases such as Parkinson’s, but there isn’t a lot of mechanistic understanding of dopaminergic circuits in the hypothalamus,” he said. “It’s been very well characterized in the basal ganglia, but the hypothalamic dopamine neurons are very deep in the brain, so it’s technically very difficult to record them.”
To overcome this obstacle, he and his colleagues used larval zebrafish as a model organism. Even though their target was deep in the brain, these transparent vertebrates allowed them to visualize and record dopaminergic neurons in the hypothalamus, with single neuron resolution. Using two-photon microscopy and genetically encoded calcium indicators, they recorded the activity of these neurons as they fluoresced. They also employed optogenetics to selectively activate or silence specific neurons and observe the impact on behavior.
“The whole-brain imaging approach allowed us to ask much broader, systems-level questions,” said Dr. Barrios. “We could identify all of the projection targets of the dopamine cells we were interested in to get a comprehensive understanding how they influence behavior. Our work also found something unexpected about the timing of the dopaminergic neurons. Dopamine is traditionally thought to act on very long timescales, but we found that many of these hypothalamic dopamine neurons fire short bursts very tightly correlated with the timing of motor behaviors, so they play a fast-acting role that had not been previously understood.”
A Love for Building Things
Dr. Barrios also developed expertise in several areas that provided an ideal foundation for his later transition to cardiology research. “In the context of systems neuroscience I became really interested in information theory and information processing systems in general,” he said. He also started training deep learning models to analyze large amounts of data, developing vision-based models for analyzing videos of the zebrafishes’ behavior. “We trained a model that gave us detailed information about the different quantitative aspects of how a fish was swimming at any given time, at high temporal resolution,” he said. “I also built deep learning systems to analyze the neural activity behavior, which got me excited about what we call artificial intelligence, or deep learning.”
In 2015 he took a UC Berkeley summer course about deep learning, and fell in love with training these models. “You can think about these microcircuits and systems in terms of information processing and multimodal integration,” said Dr. Barrios. “It was also exciting to do really rapid experimentation. You can change the [data] architecture easily, in silico. You can run a lot of experiments and get lots of results very quickly. That was much more appealing than waiting for fish to reproduce and grow up, or conducting molecular biology and genetics experiments that took a long time. During my PhD I spent about half my time doing computational research; I wanted it to become my whole life.”
Working in a small lab with a limited budget, Dr. Barrios developed a passion for tinkering and engineering. “I made our auditory stimulation rig from a piece of plastic I’d gotten from another PI’s garbage pile, plus a miniature guitar amplifier,” he said. “I pulled the speaker out from the amp, mounted it to the plastic, then ran a sine wave generator into the guitar amp and cranked it up so it gave the pulse and vibrated the platform. I realized that I love building things.”
Pivoting to Cardiology Research
After completing his PhD, Dr. Barrios applied for jobs in deep learning research. He looked at industry positions and postdocs, and came across the laboratory of Geoffrey Tison, MD, which uses machine learning and large-scale epidemiologic and clinical research methods to improve disease prevention, prediction, and phenotyping.
“I talked with Geoff, and realized that there is so much more potential for this work to have an impact on patients in cardiology now, compared with neuroscience,” said Dr. Barrios. “We understand much more about how the heart works compared with the brain. In cardiology, the questions were much more tractable and closer to clinical application. I wanted to make a difference and build systems that could be useful in a real-world context. Cardiology was the perfect opportunity.” He joined UCSF and the Tison Lab in 2020 as a staff scientist, and joined the UCSF Cardiology faculty in 2024.
While his career trajectory has been unconventional, Dr. Barrios’s training puts him at the fortuitous intersection of several disciplines. “I’m a computational researcher and basic scientist, but with my background in biology and physiology, I can communicate effectively with physicians and figure out what they need,” he said. “With my electrical engineering and electrophysiology experience, I also have a deep understanding of the acquisition devices.”
This suite of skills helps him troubleshoot experiments. For example, Dr. Barrios and his colleagues used machine learning to better predict which patients might have pulmonary hypertension, based on existing electrocardiograms (ECGs). They realized that many of the hospital’s mobile ECG carts had different filter settings, resulting in the loss of essential information.
“Even if these differences aren’t readily apparent to the eye, a deep learning model can learn systematic biases such as, ‘The patients that were acquired using these filters are sicker, because it was at a different clinic,’” said Dr. Barrios. “It would be like training a model to detect different kinds of dogs. One day you take pictures of poodles, but when you take pictures of beagles the next day you have dust on your lens. The model may conclude, ‘If there’s dust on the lens, it must be a beagle.’ You have to look at the nitty gritty of how data were acquired.”
After resolving those issues, Dr. Barrios and his colleagues developed a deep learning algorithm that detects pulmonary hypertension using ECGs alone, up to two years before cardiologists diagnosed the condition using right heart catheterization and echocardiogram. “For pulmonary hypertension, early detection is very important,” he said. “Being able to get high-risk patients into a diagnostic testing pipeline early is a game changer.”
Dr. Barrios also helped develop a deep learning model that outperformed cardiologists in detecting structural heart disease from ECGs. Working with the lab of Francesca Delling, MD, MPH, he contributed to other models that help identify patients with mitral valve prolapse (MVP) who were at increased risk for ventricular arrhythmias, fibrosis, or death, and could benefit from closer follow-up, and used both ECG and echocardiography to predict whether MVP patients without severe mitral regurgitation were at low, intermediate, or high risk of potentially life-threatening cardiac arrhythmias.
He also helped to develop and evaluate the efficacy of an AI-ECG algorithm in measuring patient response to mavacamten, a novel therapy for obstructive hypertrophic cardiomyopathy (HCM). “One nice thing about this work was that we proved that very short timescale changes in disease state can be predicted by the modeling,” said Dr. Barrios. “That allows us to track progression of disease during treatment, which is really important to identifying whether or not someone is responding to the drug.”
ECGs have a lot of potential for helping cardiologists identify high-risk patients across a number of diseases. “ECG is in a lovely niche where it can be acquired with relatively little expertise, and it’s pretty cheap,” said Dr. Barrios. Unlike echocardiograms, which require a highly trained sonographer, or a heart catheterization, which is an invasive diagnostic procedure performed by an interventional cardiologist, ECGs are routinely administered by many health care professionals. “The idea is not only early detection of disease, but also increasing efficiency of the health care system,” he said.
Deep learning models have another potential advantage: reducing interobserver variability. “We’re focusing on tasks that a human could do, but a model might do more consistently,” said Dr. Barrios. “If you have multiple doctors looking at the same test, some might miss a diagnosis. But if you have a model flagging it exactly the same way every time, you can increase the sensitivity of physicians, who find things more often because the model initially flags them.” When used properly, he and his colleagues see AI as a tool that can complement, rather than replace clinical knowledge.
Boosting Performance with Foundation Models
In another investigation, Dr. Barrios and his colleagues created what’s known as a foundation model to help identify rare diseases. First they pretrained an AI algorithm to identify common diagnoses using a dataset of 1.6 million UCSF ECGs. That taught the model basic things, like what different segments of the ECG normally look like, and how to extract specific features. “It takes a lot of data to teach the model those basic concepts,” he said.
However, rare diseases pose a challenge for AI: since there aren’t many examples of these in most datasets, researchers need to teach the algorithm to recognize these another way. Using their foundation model, they showed the model a few hundred examples each of three rare conditions: carcinoid syndrome, pericardial effusion, and rheumatic doming of the mitral valve. Because the foundation model gave the algorithm a head start by teaching it the basics, they found the algorithm that was then fine-tuned to identify these rare diseases performed significantly better than algorithms trained only on the rare disease ECGs.
“These foundation models are much more data-efficient, and don’t need as much data downstream to do these more specific tasks like identifying a rare disease,” said Dr. Barrios. “Foundation models leverage transferrable skills like extracting features and understanding the structure of the data. We can also share these foundation models with the community. They are flexible tools that take advantage of all the data we have.”
They further validated this foundation model, finding that it improved detection of rheumatic mitral valve disease from ECG alone when compared with a model that lacked pretraining. Their finding shows promise as a way to improve global health equity. “Rheumatic heart disease is something that’s more common in lower-resource settings,” said Dr. Barrios. “The 12-lead ECG is pretty accessible and widely available. This avenue of research is something that could potentially democratize and spread the tools of predictive power to places around the world.”
Integrating Many Data Sources into Emerging Models
While Dr. Barrios and his colleagues have focused much of their attention in using ECGs to identify, predict, and manage cardiac disease, they are now pursuing a broader goal. “Multimodality is a major interest in the lab,” he said. “A human physician would never just look at an ECG and make a prediction using that and nothing else. They have the patient notes, patient history, demographics, echocardiogram, test results, labs, and other context. We want to mimic that process and train a model that looks at an ECG plus all that other information, and then make a prediction that exceeds human performance.”
He and his collaborators are building architectures and creating new models that synthesize all this information. For example, they are showing their model an echocardiogram and asking it to predict what an associated ECG looks like, or showing the model a clinical note and asking it to predict an associated lab result. “We can do that without having to create any further labels, which allows us to start training foundation models that are multimodal,” said Dr. Barrios. “That’s the next big thing, both in the Tison Lab as well as medical AI in general.”
Each data source has its challenges. For example, an echocardiogram is much more difficult to analyze than an ECG. “The echocardiogram study includes hundreds of videos that are acquired at different angles to visualize all of the anatomy,” said Dr. Barrios. “There are also many different acquisition parameters and techniques, so there’s a massive amount of variation in the data. That makes it much more difficult for AI to analyze. Yet it’s also much more information-rich compared with ECG.”
Similarly, physician notes can be complex. While some portions may be built from dropdown menus that insert standardized text, other parts are more challenging to analyze. “Free text notes are very information-rich, but very hard to work with,” said Dr. Barrios. “That’s an area where you would need a large language model to pull out more information so you can ask it, ‘Please generate more structured text and some yes/no information for me.’”
There is some low-hanging fruit. “We see a huge boost in model performance if we just give the model the patient’s age,” said Dr. Barrios. “Something that is normal on an older person’s ECG may be extremely concerning in a young person. Giving the model that context allows it to do a much better job.”
Dr. Barrios is excited about this approach’s potential. “A massively multimodality foundational model that can understand data from a variety of sources, as well as the variation among the whole human population, would enable every doctor to be more efficient and accurate in their predictions,” he said. “It would take the knowledge and wisdom that is baked into all that data, and put it into a model that can share that power.”
He is energized by the challenge. “The engineering side of me loves identifying the problem and figuring out how to build the right tool or model for the job,” said Dr. Barrios. “A big part of the work is determining the right size and class of architecture. Can we take two architectures and tie them together to do a better job? What we’re doing is both science and engineering, and that’s a lot of fun.”
‘A Desire for Truth’
Dr. Barrios is glad to have joined the UCSF Cardiology faculty. “UCSF is an amazing place,” he said. “There are so many brilliant people who work here. I love working in a clinical division – I learn so much from clinicians, and have soaked up a lot of information over the last few years. The division is extremely collaborative and highly values research. Geoff has been a fantastic mentor, coworker, and co-PI. He has set me up with amazing projects and collaborators, not just at UCSF but around the world.”
“Josh brings a unique and highly valuable skillset at the intersection of machine learning/AI and scientific biomedical investigation,” said Dr. Tison. “His multidisciplinary expertise is central to the work of the lab and broadens the research capabilities of the Division of Cardiology.”
Dr. Barrios also appreciates working with medical students, residents, and fellows who spend time in the Tison Lab. “I love mentorship, and want to provide experiences that will advance their careers,” he said. “When I talk with students, I only take them if we can clearly identify a project together that will result in a paper and a conference experience.”
He encourages trainees to meticulously document everything. “Write everything down in great detail, and record every piece of the experiment so you could go back in five years and run it again,” advises Dr. Barrios. “It’s very easy when you’re coding to change a parameter without recording it, but if it’s not reproducible, you’ve wasted your time.”
He credits one of his own mentors, Todd Schoborg, PhD, who taught him to focus on scientific questions rather than fancy new techniques. “I was a very excitable undergrad when Todd was a PhD student,” recalled Dr. Barrios. “I wanted to use chip seq, a super complicated technique to figure out all the proteins that are bound to a gene of interest. He said, ‘What protein are you interested in? If it were bound to the gene, would it make a difference? We have a bunch of questions to answer, and that won’t answer any of them.’ He was a very pragmatic guy, and brought me down to earth in a really useful way.”
Dr. Schoborg also inspired Dr. Barrios to become an early riser. “Unlike many scientists who are in the lab all night, he was a morning person,” said Dr. Barrios. “I also started getting to the lab early, something I still do today.” He is usually up by 5:30 a.m., and starts coding or writing by 6 a.m. “It’s dark and quiet, no one else is awake at home, and the critiquing voice in my head isn’t on yet, so I can write without second-guessing myself,” he said.
Dr. Barrios is happy with his work. “The wonderful thing about academia is intellectual freedom,” he said. “My research is driven by a desire for truth. I’m working to build useful algorithms, to improve the health care system, or to discover new understanding of biology. I like that my work is just trying to make patient care better. That’s something I can feel good about at the end of the day.”
Outside of research, Dr. Barrios enjoys camping, skiing, and playing keyboard in jazz jam sessions with family and friends. He is married to Macy Barrios, a clinical research manager in the UCSF Department of Neurology. Together they are on a quest to visit every national park in the U.S.
- Elizabeth Chur