I have a friend who works at the research institute beside the university hospital, and he told me they basically ask a set of questions, while taking a series of measurements via the fMRI machine. They then compare the expected responses with the output from the brain scanner, and can match up the blood flow rates in different parts of the brain with a "positive" or "negative" response. They then perform the inquiries multiple times, until they have a high degree of probability that the questions were answered in a consistent manner.
To add to Breakthrough's answer, the article states:
"The patients were repeatedly asked to imagine playing tennis or walking around their home. In healthy volunteers each produces a distinct pattern of activity, in the premotor cortex for the first task and the parahippocampal gyrus for the second. It allowed the researchers to put a series of yes or no questions to severely brain-injured patients. A minority were able to answer by using the power of thought."
So, I imagine they could say "To answer YES, imagine playing tennis. To answer NO, imagine walking around your home". Then they could ask yes/no questions and monitor the patterns of brain activity.