Mazdaspeed Miata Random Miss

I have a random miss code and rough idle in my miata. I’ve replaced coils and crank sensor with no result. compression is good. The problem started after a head gasket replacement. Any ideas anyone?

You’ll have more luck here if you post the car year, and the DTC code ID. A common cause of misfiring is degraded spark plug wires. Look at them carefully, twist them, bend them, see if there are any breakes in the insulation. Degraded spark plugs/ignition rotors/distributor caps (if you have them) and too wide spark plug gaps can be a cause too. A mechanic would probably look at the spark plugs to see if there is any difference from one to the other in appearance. That would provide a clue to what is causing this. Rough idle can also be caused by air leaks and degraded O2 sensors.