I understand there are two kinds of active vaccination
Injecting complete viruses that are weakened to not cause the disease being vaccinated against
Injecting only antigen particles of viruses that the body creates antibodies for. So the disease can't arise, not even in a weakened form.
I am wondering how the viruses for vaccination are weakened. Is this simply a process where randomly parts of the virus DNA/RNA are taken out and tested on animals, and as soon as it is sufficiently weakened, it is considered suitable? Or is this an analytical and systematic process?
I am wondering because some popular vaccinations (including that against measles) can still (very rarely) cause fatal complications. Which made me think whether it's systematic or just "accelerated mutation and selection".
I'm interested in an answer for layman, if that is possible at all.