Since the beginning of the project, we have established a closed-loop B/NMI-TES system to identify and modulate the neural substrates of various brain functions (e.g. memory, motor control, visual perception) (WP1/WP2). To achieve this, the following tasks were performed: First, we integrated the B/NMI hardware combining MEG/EEG with TES into a multi-core real-time machine and established necessary communication protocols to minimize time delays between recorded brain signals, interpretation, and resulting sensory feedback or transcranial stimulation. Besides advanced source reconstruction algorithms improving spatial resolution of the B/NMI system, other approaches were tested. A B/NMI environment was also programmed to allow real-time estimation of phase and amplitude and flexible adjustment of B/NMI output signals, e.g. to adjust TES or feedback signal (WP1). In WP2, we focused on identifying effective stimulation parameters to modulate brain function, characterizing brain stimulation-related artifacts in innovative TES protocols. Moreover, we assessed the boundaries of different stimulation parameters regarding artifact contamination of reconstructed signal sources. We developed a novel stimulation artifact source separation algorithm (SASS) that is real-time compatible and allows recording EEG signals during adaptive, closed-loop electric brain stimulation (CLAM-tACS). The algorithm was made publicly available along with raw data. The system was validated using a phantom model, assessing pulse stimulation durations, lengths, and overlay of multiple continuous stimulation signals oscillating at different frequencies and intensities. We then compiled a stimulation parameter database of safe, tolerable settings that allow reliable reconstruction of brain oscillations. After completing this work, we evaluated the effects of brain-state dependent TES protocols on normal brain physiology. For this, we recruited healthy volunteers and identified the optimal brain-state dependent stimulation parameters to target conscious awareness of bistable percepts. Based on this, we developed a software tool to automatically adapt TES parameters to modulate the targeted brain function. We then applied this methodology to modulate brain states enhancing specific brain functions, e.g. memory formation. In a controlled study with healthy volunteers, we demonstrated the potential of the NGBMI prototype to enhance memory formation (Haslacher et al. 2024, Brain Stimulation). This paradigm was then successfully translated into various patient populations targeting different domains, e.g. the motor domain in stroke or the cognitive/affective domain in mild cognitive disorder (MCI) and alcohol use disorder (AUD). Importantly, the artifact suppression approach was successfully applied in combination with optically pumped magnetometers (OPM) in targeting gamma band responses in the auditory domain.