Motor imagery-based brain-computer interfaces (BCI) have shown potential for the rehabilitation of stroke patients; however, low performance has restricted their application in clinical environments. Therefore, this work presents the implementation of a BCI system, coupled to a robotic hand orthosis and driven by hand motor imagery of healthy subjects and the paralysed hand of stroke patients. A novel processing stage was designed using a bank of temporal filters, the common spatial pattern algorithm for feature extraction and particle swarm optimisation for feature selection. Offline tests were performed for testing the proposed processing stage, and results were compared with those computed with common spatial patterns. Afterwards, online tests with healthy subjects were performed in which the orthosis was activated by the system. Stroke patients' average performance was 74.1 ± 11%. For 4 out of 6 patients, the proposed method showed a statistically significant higher performance than the common spatial pattern method. Healthy subjects' average offline and online performances were of 76.2 ± 7.6% and 70 ± 6.7, respectively. For 3 out of 8 healthy subjects, the proposed method showed a statistically significant higher performance than the common spatial pattern method. System's performance showed that it has a potential to be used for hand rehabilitation of stroke patients.