Brain Stimulation
Brain stimulation methods, including transcranial magnetic stimulation (TMS) transcranial direct current stimulation (TDCS), non-invasive techniques that use electrical or magnetic fields to stimulate nerve cells in the brain. methods have shown promise in treating a variety of neurological and psychiatric disorders, including depression, anxiety and chronic pain.
Transcranial Magnetic Stimulation (TMS)
​
TMS is a powerful and precise method of brain stimulation that has gained significant traction in both research and clinical settings.
How does it Works?
TMS operates on the principle of electromagnetic induction, discovered by Michael Faraday in 1831.
Main ideas:
-
A TMS device contains a magnetic coil placed near the scalp.
-
When activated, the coil generates a rapidly changing magnetic field.
-
This magnetic field easily passes through the skull and induces electric currents in the underlying brain tissue.
-
These induced currents can depolarize neurons, causing them to fire.
The spatial resolution of TMS is relatively high, allowing for targeted stimulation of specific brain regions.
​
Applications of TMS
TMS has a wide range of applications, including:
-
Treatment of Depression: FDA-approved for treatment-resistant depression.
-
Neurological Disorders: Shows promise in treating migraines, Parkinson's disease, and stroke rehabilitation.
-
Psychiatric Conditions: Being studied for anxiety disorders, OCD, and PTSD.
-
Cognitive Enhancement: Research suggests potential benefits for memory and learning.
-
Neuroscience Research: Used to study brain function and connectivity.
​​
Advantages and Limitations
Advantages:
-
Non-invasive with minimal side effects
-
High spatial and temporal precision
-
Can reach deeper brain structures compared to tDCS
-
Immediate effects observable in many cases
Limitations:
-
Requires specialized, expensive equipment
-
Not easily portable
-
May require multiple sessions for lasting effects
-
Contraindicated for people with certain types of metal implants

Transcranial Direct Current Stimulation (tDCS)
tDCS is a simpler, yet still powerful method of brain stimulation that has gained popularity due to its ease of use and potential for home application.
​
How tDCS Works
tDCS uses direct electrical currents to stimulate specific areas of the brain. Here's how it works:
-
Two or more electrodes are placed on the scalp.
-
A low-intensity direct current (typically 1-2 mA) is passed between the electrodes.
-
The current flows from the anode (positive electrode) to the cathode (negative electrode).
-
This current subtly modifies the resting membrane potential of neurons, making them more or less likely to fire.
Unlike TMS, tDCS doesn't directly cause neurons to fire. Instead, it modulates their excitability.
Applications of tDCS
While still largely in the research phase, tDCS has shown potential in various areas:
-
Cognitive Enhancement: Studies suggest improvements in working memory, attention, and learning.
-
Mental Health: Being investigated for depression, anxiety, and addiction.
-
Pain Management: Shows promise in treating chronic pain conditions.
-
Motor Function: Potential applications in stroke recovery and motor learning.
-
Neurodegenerative Diseases: Being studied for conditions like Alzheimer's and Parkinson's.
​​
Advantages and Limitations
Advantages:
-
Simple and inexpensive compared to TMS
-
Portable and potentially suitable for home use
-
Generally well-tolerated with minimal side effects
-
Can be applied for longer durations
Limitations:
-
Less focal than TMS, affecting broader areas of the brain
-
Effects can be subtle and variable between individuals
-
Optimal protocols (current strength, duration, electrode placement) still being researched
-
Long-term effects not yet fully understood
​

The Future of Brain Stimulation
​
​
As we stand on the brink of a new era in neurotechnology, the future of brain stimulation holds immense promise and potential. Here are some key areas where we can expect significant developments:
1. Advanced Targeting and Precision
Future brain stimulation techniques will likely offer unprecedented levels of precision:
-
High-Definition tDCS (HD-tDCS): Already in development, this technique uses multiple smaller electrodes for more focused stimulation.
-
Temporal Interference Stimulation: This emerging method could allow deep brain stimulation without invasive procedures.
​​
2. Personalized Neuromodulation
The one-size-fits-all approach will give way to highly personalized treatments:
-
AI-driven protocols: Machine learning algorithms will analyze individual brain data to determine optimal stimulation parameters.
-
Genetic and biomarker integration: Treatments will be tailored based on an individual's genetic profile and specific biomarkers.
​
3. Integration with Other Technologies
Brain stimulation will increasingly be combined with other cutting-edge technologies:
-
Closed-loop systems: Integrating stimulation with EEG or fMRI for real-time adjustment based on brain activity.
-
Virtual and Augmented Reality: Combining brain stimulation with immersive environments for enhanced cognitive training or therapy.
-
Brain-Computer Interfaces (BCIs): Merging stimulation techniques with BCIs for enhanced control and feedback.
Future Tech: Picture a rehabilitation system where a stroke patient uses a BCI to control a robotic arm, while targeted TMS enhances neuroplasticity in real-time, speeding up recovery.
​
While these future developments are exciting, it's important to approach them with both optimism and caution. As we unlock new potentials in brain stimulation, we must also carefully consider the ethical implications and ensure that these powerful tools are used responsibly for the benefit of individuals and society as a whole.
The journey into the future of brain stimulation is just beginning, and it promises to be a fascinating exploration of the most complex and mysterious organ in the human body - the brain.
TMS-EEG Analysis Tutorial: From Power Spectrum To Artifact Removal
This tutorial provides a structured approach to analyzing TMS-EEG data, focusing on power spectrum analysis, the data were taken from Hypnosis TMS-EEG dataset from OSP home website, thank you for your open platform.
01
Step 1: Data Loading and Visualization
-
Load the preprocessed TMS-EEG data
-
Visualize the raw EEG data
-
Identify TMS pulses
-
Create a Topographic map to see spatial activation.
03
Step 3: Power Spectrum Analysis - TMS Period
-
Compute the power spectrum for the TMS stimulation period
-
Plot the average power spectrum across all channels
-
Compare with the baseline spectrum
05
Step 5: TMS Artifact Identification and Removal
-
Identify and characterize TMS artifacts
-
Implement a simple artifact removal technique
-
Compare power spectra before and after artifact removal
02
Step 2: Power Spectrum Analysis - Baseline
-
Compute the power spectrum for the baseline period (before TMS)
-
Plot the average power spectrum across all channels
-
Identify dominant frequency bands
04
Step 4: Individual Channel Analysis
-
Select a subset of channels
-
Plot individual power spectra for these channels
-
Compare baseline and TMS periods for each channel
06
Step 6: Analyze the impact of artifact removal on spectral content:
-
compare the raw data and power spectra analisys before and after artifact cleaning
STEP BY STEP INSTRUCTIONS
Step 1: Data Loading and Visualization
-
Download the tms-eeg folder from here and extract it.
-
Choose an appropriate window size and load the preprocessed data using the load_data function from utils.
-
Use the plot_raw_data function to visualize the raw EEG data.
-
Use the existing find_tms_pulses function to identify TMS pulses.
-
Choose a frecuncy band and use the plot_topographic_map from utils to visualize the spatial activation map.
Step 2: Power Spectrum Analysis - Baseline
-
Define the baseline period (e.g., data before the first TMS pulse).
-
Use the compute_psd function to calculate the power spectrum for the baseline period.
-
Plot the average power spectrum across all channels using matplotlib.
-
Label the plot axes and add a title.
-
Identify and annotate important frequency bands (e.g., delta, theta, alpha, beta).
Step 3: Power Spectrum Analysis - TMS Period
-
Define the TMS period (e.g., data during and immediately after TMS pulses).
-
Compute the power spectrum for the TMS period using the same method as in Step 2.
-
Plot the TMS period power spectrum on the same axes as the baseline spectrum.
-
Use different colors to distinguish baseline and TMS spectra.
-
Add a legend to the plot.
-
Discuss observable differences between baseline and TMS spectra.
Step 4: Individual Channel Analysis
-
Select 6 representative channels (e.g., frontal, central, parietal, on both hemispheres).
-
Create a 2x3 subplot figure.
-
For each selected channel:
a. Plot the baseline and TMS power spectra.
b. Label axes and add a title with the channel name.
c. Add a legend.
Stage 5: TMS Artifact Identification and Removal
5.1 Artifact Identification
-
Create a new plot focusing on a short time window around a TMS pulse (e.g., ±50ms).
-
Select a representative TMS pulse from your data.
Extract data for all channels in the specified time window. -
Plot multiple channels to show how the artifact appears across the scalp.
-
Analyze the characteristics of the TMS artifact:
-
Measure the typical amplitude of the artifact across channels.
-
Estimate the duration of the artifact (time until the signal returns to baseline).
-
Note any variations in artifact appearance across different channels or scalp regions.
5.2 Simple Artifact Removal
-
Implement a basic artifact removal technique:
-
Choose a simple method, such as linear interpolation or zeroing out the artifact.
-
Define a small window around each TMS pulse for artifact removal (e.g., ±5ms).
-
Apply the chosen method to all TMS pulse locations across all channels.
Step 6: Analyze the impact of artifact removal on spectral content:
-
Identify frequency bands most affected by artifact removal.
Compare the differences between baseline and TMS spectra before and after cleaning.
Look for any unexpected changes in the spectra that might indicate issues with the artifact removal process.