===SOLUTION====
and good news, its free and takes about 10 min
I had this EXACT problem, drove me nutts for months. it was a fairly common occourance and it was like the bike flicked a switch between "fine" and "stall /idle bad until the ignition is reset"
had the bike in the shop for months and they couldnt work it out.
I eventually found a solution burried on this forum.
Even better somone has now posted a video of the fix on Youtube!
http://youtu.be/oMAKX4Ca9I4
or just look up 2007 r1 stalling fix.
aparently there is an adjustment yamaha make to the throttle bodies to help pass polution scrutineering when the bikes arrive in certain countries (Australia in my case) and usually it doesnt cause any problems but on some bikes it plays up. you just need to reverse this.
And so you're aware this problem didnt exist from the beginning, for me it developed after about 10,000km
Its a simple adjustment, when i first did it the fix worked a little too well and at the time and rather than stall and idle low it would actually idle a touch higher than usual, so i backed the adjustment off a little, and the bike has been fine for the last 2 years. As it would turn out the "switch" was alterations made by the O2 sensor program to the way the engine wanted to work.
I hope this helps you and anyone else who has this problem!