Magnetic structures with controlled domain wall pattern may be applied as potential building blocks for three-dimensional magnetic memory and logic devices. Using a unique electrochemical self-assembly method, we achieve regular single-crystalline cobalt filament arrays with specific geometric profile and crystallographic orientation, and the magnetic domain configuration can be conveniently tailored. We report for the first time the transition of periodic anti-parallel magnetic domains to a compressed vortex magnetic domains depending on the ratio of height vs. width of the wires. A "phase diagram" is obtained to describe the dependence of the type of magnetic domains and the geometrical profiles of the wires. Magnetoresistance of the filaments demonstrates that the contribution of series of 180 o domain walls is over 0.15% of the zero-field resistance ρ(H = 0). These self-assembled magnetic nanofilaments, with controlled periodic domain patterns, offer an interesting platform to explore domain-wall-based memory and logic devices.