There is an ancient secret of life hidden in this question. Where do thoughts come from? The second before that thought popped into your head, where was it? If you say thoughts don't come from anywhere except our own memory/brain, then I ask you: what about the hundreds of completely random thoughts you have everyday that have nothing to do with anything you've ever experienced before? Where do those thoughts come from? Is there a database of random thoughts that are stored in your brain and your brain randomly generates one every 2 seconds? Obviously this is not the case.
No need to go digging deep into scientific papers because you will not find the answer there. If you are a true seeker, you can do an experiment right now to find the answer. For the next 2 minutes, just sit quietly. And observe any thoughts that pop up in your mind. The first 2 thoughts might be something like: "this is kinda weird, i can hear myself speaking in my head.." or "Ok.. so now what?" Hear these and recognize these as thoughts and go back to just being silent in your mind, observing. In about 10-15 seconds, one thought after the other will come. Every time you hear/notice a thought in your head, look into where it came from before it popped into your mind. Whoever continues this experiment and truly searches, will find an incredible discovery that will free you from your suffering.