Here is the fragment:
So he doesn't actually say he was conscious the whole time. I find it a bit hard to though reconcile those "brief, terrifying periods of consciousness" with his "seemed longer than 4 years", but then again we don't know anything about how a sentient but "disembodied" holodeck character would experience time in the first place ....
MORIARTY: How long have I been locked away?
BARCLAY: Well, it looks like about four years.
MORIARTY: It seemed longer.
BARCLAY: What are you talking about? You can't possibly have been aware of the passage of time.
MORIARTY: But I was. Brief, terrifying periods of consciousness. Disembodied. Without substance.
BARCLAY: I don't see how that could be possible. Maybe there was a fragmentation of the protected memory circuits.
MORIARTY: Call it what you will. All I know is that despite Picard's promise, he's done nothing. Just left me to go quietly mad.
BARCLAY: He would not have forgotten his promise. The Captain would not do that.
MORIARTY: I'd like to talk to him.
BARCLAY: Well, I can ask.
MORIARTY: Ask him to meet me in the sitting room at Baker Street. That would be far more appropriate.
BARCLAY: I'll have to store you in memory again until I get an answer.
So he doesn't actually say he was conscious the whole time. I find it a bit hard to though reconcile those "brief, terrifying periods of consciousness" with his "seemed longer than 4 years", but then again we don't know anything about how a sentient but "disembodied" holodeck character would experience time in the first place ....