First of all, learning just basic music theory is a must. I don't know what you'reyour background is but if you're unable to read a piece of music it's likely you're going to have difficulty writing it. Learning how chords work is a must. Not only recognizing what they look like but if someone plays one on a piano or something you can recognize that its a major 7th.
You don't have to have perfect pitch or be able to recognize every chord anyone could throw at you but it'll help a lot when trying to sort through your thoughts. A good way to learn these things is through sight singing and recognizing intervals, etc. A teacher helps with this sort of thing.
Finally, you should probably learn how to play an instrument, piano is probably your best bet since you want to write music and I just think its easiest on a piano since you can play all the parts. It's not necessarily true that if you can't play it, you can't write it but it's almost certainly true that if you can play it, you'll likely be able to transcribe it as well, with a bit of music theory background of course.