The gut microbiota can influence human behavior. However, due to the massive multiple-testing problem, research into the relationship between microbiome ecosystems and the human brain faces drawbacks. This problem arises when attempting to correlate thousands of gut bacteria with thousands of brain voxels. We performed brain magnetic resonance imaging (MRI) scans on 133 participants and applied machine-learning algorithms (Ridge regressions) combined with permutation tests. Using this approach, we were able to correlate specific gut bacterial families with brain MRI signals, circumventing the difficulties of massive multiple testing while considering sex, age, and body mass index as confounding factors. The relative abundance (RA) of the Selenomonadaceae, Clostridiaceae, and Veillonellaceae families in the gut was associated with altered cerebellar, visual, and frontal T2-mapping and diffusion tensor imaging measures. Conversely, decreased relative abundance of the Eubacteriaceae family was also linked to T2-mapping values in the cerebellum. Significantly, the brain regions associated with the gut microbiome were also correlated with depressive symptoms and attentional deficits. Our analytical strategy offers a promising approach for identifying potential brain biomarkers influenced by gut microbiota. By gathering a deeper understanding of the microbiota-brain connection, we can gain insights into the underlying mechanisms and potentially develop targeted interventions to mitigate the detrimental effects of dysbiosis on brain function and mental health.