If you see a guinea pig have a fit, usually after a frantic scratch, nine times out of ten it means that a fungal skin complaint as not be diagnosed early enough which has advanced to become systemic.
The guinea pig will roll over onto it's back, the whole of it's body will shake for a while then it will arch backward and stay still for a couple of seconds then flip over onto it's feet and get up.
The first time owners see this they think that the animal is having a heart attack and if the fungal infestation is not cleared it could lead to this eventually. However, this kind of fitting can carry on for quite a long time before they have a serious effect upon the guinea pig.
Let the guinea pig come out of the fit in it's own time, then pick it up and nurse it for a couple of minute before you check it over for the fungal problem. See Skin problems.
There are fits that can be caused by neurological problems but it would take a far better expert than I am to give the causes and suggest remedies, if there are any.