['We tested whether brain gray matter (GM) imaging measures can differentiate between multiple sclerosis (MS) and neuromyelitis optica (NMO) using random-forest classification.', 'Ninety participants (25 patients with MS, 30 patients with NMO, and 35 healthy controls [HCs]) were studied in Tehran, Iran, and 54 (24 patients with MS, 20 patients with NMO, and 10 HCs) in Padua, Italy. Participants underwent brain T1 and T2/fluid-attenuated inversion recovery MRI. Volume, thickness, and surface of 50 cortical GM regions and volumes of the deep GM nuclei were calculated and used to construct 3 random-forest models to classify patients as either NMO or MS, and separate each patient group from HCs. Clinical diagnosis was the gold standard against which the accuracy was calculated.', 'The classifier distinguished patients with MS, who showed greater atrophy especially in deep GM, from those with NMO with an average accuracy of 74% (sensitivity/specificity: 77/72; p < 0.01). When we used thalamic volume (the most discriminating GM measure) together with the white matter lesion volume, the accuracy of the classification of MS vs NMO was 80%. The classifications of MS vs HCs and NMO vs HCs achieved higher accuracies (92% and 88%).'] Does gray matter MRI differentiate neuromyelitis optica from multiple sclerosis using random forest?