Counselor
A counselor is a position aboard Starfleet vessels and installations, usually held by a senior Starfleet officer with training in psychology.
Qualified psychiatrists served aboard starships during the 23rd century. (TOS: "Where No Man Has Gone Before", "Dagger of the Mind")
By the mid-24th century, starship and starbase crews included a counselor, who was responsible for the mental well-being of the crew and civilian staff. The position was considered vital enough that it warranted inclusion in the senior staff of the Federation flagship; in that instance at least, the ship's counselor also had a diplomatic role, advising the captain in first contact and other situations.
As with the chief medical officer, the ship's counselor has the power to relieve other officers and crewmembers of duty if he or she feels that their patient is suffering from a condition that may hinder their ability to perform their duties effectively.
At the captain's discretion, the ship's counselor may be allowed to wear something other than their normal Starfleet uniform while on duty. This was the case with Deanna Troi, the ship's counselor on the USS Enterprise-D. Troi elected to wear a uniform permanently after being told to do so by Captain Edward Jellico. (TNG: "Chain of Command, Part I")
Some Starfleet officers, such as Captain Lisa Cusak and Chief Miles O'Brien, disliked the concept of a designated ship's counselor, preferring to seek advice about their problems from friends. (DS9: "The Sound of Her Voice")