I think you had a false awakening; It's actually quite common. The shaking is also common, it has something to do with sleep paralysis. The weird flashing lights are from your eyes moving due to REM (actually i'm bullshiting you, I don't know what causes the flashing.) But I do know it's called hypnotic imagery. I'm not sure about the details, but i'm sure someone here can fill you in.