I'm not sure wether this can be considered RAW.
There is an item in the Magic Item Compendium
Third Eye Clarity
3000 gp, 1/day, immediate mental action, face slot
You can activate this crystal to negate any one of the following conditions affecting you: confused, dazed, fascinated, or stunned. You can activate the eye in response to an effect that would impose one of these conditions (for instance, after failing your save against a monk's Stunning Fist attack but before the stun takes effect)
Since this Item allows the character to negate the Stunned Condition and takes an immediate mental action to activate, it can be argued that purely mental immediate Actions can be taken, even if stunned.
However, upon rereading the description I think the item text actually implies that you need to do it before the stun takes effect therefore undermining the argument above.