Periodic and non-periodic brainwaves emerging via random syncronization of closed loops of firing neurons