A Closed-loop Adaptive Brain-computer Interface Framework