The ספר הישר discusses the connection between one's thoughts, his מחשבה, and the level of his spirituality, or, his נשמה. The two are very much inter-related.
When one consistently allows himself to let in negativity and negative thoughts, it's an indication that he has a weak soul. If one had a strong soul, he would always think positively and optimistically.
The comparison is to our physical body. If we don't take care of ourselves and allow our body to consume bad foods, our bodies will be weak. If we eat right and exercise, everything will be flowing and we will be healthy.
The solution for our weak spirituality is to bombard it with "healthy" foods of holiness. We do this by surrounding ourselves with holy, positive, people. We immerse ourselves in Torah and allow only the teachings of Chazal to enter. Allowing a negative thought to enter, is like allowing damaged food into our bodies.
If we create a spiritual filter, we will become much stronger and more productive people. We will always be in a state of happiness and contentment. Great advice from Rabbeinu Tam and his ספר הישר.