Seems like you managed to erase the EFS partition of your device. Now I would ask if you have a back up of the partition (as most people recommend before you do anything custom with your phone such as ROM flashing or rooting) but seeing that you have no idea what happened, I am going to assume you don't. In that case, I can direct you to a XDA guide (though it's for a galaxy s3 but you can try your luck and have to find the official firmware for the s4 yourself). Just Google: "help...Restore Galaxy s3 imei no? XDA developers" Before you dismiss the whole thing, do know that the guide was adapted and made to work from a similar guide for a s2 so you just never know. The response you're looking for is a post on the second page of this thread by leahcim_za.
It's all thanks to the usage of the EFS PRO tool