A Framework for Programming Brain-Computer Interfaces