Multiple sclerosis can damage the central nervous system, and current drugs are difficult to completely cure symptoms. The aim of this paper was to use deep learning methods to increase the detection rate of multiple sclerosis, thereby increasing the patient’s chance of treatment. We presented a new method based on hu moment invariant and artificial neural network trained by particle swarm optimization. Our method was carried out over ten runs of ten-fold cross validation. The experimental results show that the optimization ability of particle swarm optimization algorithm is superior to the genetic algorithm, simulated annealing algorithm and immune genetic algorithm. At the same time, compared with the HWT+PCA+LR method and the WE-FNN-AGA method, our method performs better in the performance of the detection.