The immune system protects the body from infection through a complex network of cells and proteins. It has both primary organs that produce immune cells like the bone marrow and thymus, and secondary organs that process antigens like lymph nodes and the spleen. The major function of the immune system is to recognize foreign substances and protect the integrity of the body through distinguishing self from non-self. The endocrine system includes glands like the hypothalamus, pituitary, pineal, thymus, thyroid, pancreas, adrenals, ovaries, and testicles that secrete hormones to regulate important bodily functions.