There are two ways that an infection can affect the brain and cause encephalitis: primary and secondary encephalitis.