It's hard to know how applicable my experiences are to your situation, but here are some things that I figured out (after a lot of time and frustration) that proved effective. Grad school, for many people, seems inevitably to entail some prolonged dark night of the soul. Accept this as part of the process. It can cause you to lose yourself and your connection to what you really care about... or you can use it to stre…
Man, that is my exactly experience! The thesis I eventually handed in bore almost no resemblance to the work I was doing and interested in :)
I'd definitely echo the "prolonged dark night" comment too. Sometimes, you just have to accept that and keep on plugging away, albeit maybe taking the night off to recharge a bit (it's like debugging, it's hard to see how that's going to achieve anything but it can make a huge difference).