A graphical expansion formula for non-commutative matrix integrals with values in a finite-dimensional real or complex von Neumann algebra is obtained in terms of ribbon graphs and their non-orientable counterpart called Möbius graphs. The contribution of each graph is an invariant of the topological type of the surface on which the graph is drawn. As an example, we calculate the integral on the group algebra of a finite group. We show that the integral is a generating function of the number of homomorphisms from the fundamental group of an arbitrary closed surface into the finite group. The graphical expansion formula yields a new proof of the classical theorems of Frobenius, Schur and Mednykh on these numbers.