<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mahdis bagheri on Medium]]></title>
        <description><![CDATA[Stories by Mahdis bagheri on Medium]]></description>
        <link>https://medium.com/@mahdisbagheri?source=rss-1ff67a440738------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dR4MFlt-PJwN6mqxBM-Zhg.jpeg</url>
            <title>Stories by Mahdis bagheri on Medium</title>
            <link>https://medium.com/@mahdisbagheri?source=rss-1ff67a440738------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:51:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mahdisbagheri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Between Waves & Weights — Week 4: An Introduction to rTMS]]></title>
            <link>https://mahdisbagheri.medium.com/between-waves-weights-week-4-an-introduction-to-rtms-0f3fbc9d79a4?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f3fbc9d79a4</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 10:43:23 GMT</pubDate>
            <atom:updated>2026-08-01T10:59:07.669Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hYLMN6ocJJWjXBsY.jpg" /><figcaption><strong>Visual illustration of the induction of electrical currents in the brain during rTMS. image source : [</strong><a href="https://brainclinics.com/research/articles/repetitive-transcranial-magnetic-stimulation-rtms-in-depression-protocols-mechanisms-and-new-developments"><strong>Link]</strong></a></figcaption></figure><p>Throughout this series, I have explored signal processing, Deep Learning, and Brain-Computer Interfaces, all centered around a common objective:</p><p><strong>Understanding how the brain functions.</strong></p><p>With EEG, we can measure neural activity, study cognitive processes, detect neurological disorders, and even translate brain signals into commands for external devices.</p><p>But what if, instead of simply treating the brain as a source of information, we could directly interact with its neural circuits and influence how they process information?</p><p>This is where <strong>Repetitive Transcranial Magnetic Stimulation (rTMS)</strong> changes the conversation.</p><h3>rTMS</h3><p>rTMS is an active neuromodulation technique that allows us to influence brain activity rather than simply observe it. The fundamental principle behind rTMS comes from Faraday’s Law of Electromagnetic Induction: a changing magnetic field can generate an electrical field.</p><p>During rTMS, a rapidly changing electrical current flows through a coil placed on the scalp. This current creates a time-varying magnetic field that can pass through the skull with minimal resistance. As this magnetic field reaches the brain, it induces a small electrical field in the underlying cortical tissue.</p><p>When this induced electrical field is strong enough, it can change the electrical activity of cortical neurons by affecting their membrane potential and firing patterns.</p><p>Unlike invasive brain stimulation methods, rTMS does not require implanted electrodes and does not send electrical current directly through the scalp. Instead, it uses magnetic fields to indirectly influence neural circuits, making it a safe and non-invasive approach for studying and modulating brain function.</p><h3>Changing Brain Activity — Not Just Measuring It</h3><p>One of the most fascinating aspects of rTMS is that its effects extend beyond the stimulation period itself.</p><p>Repeated stimulation can modify cortical excitability, producing changes that may last from several minutes to even weeks after repeated treatment sessions. These lasting effects are believed to arise from mechanisms related to synaptic plasticity — the brain’s ability to strengthen or weaken connections between neurons.</p><p>Two important forms of synaptic plasticity are:</p><ul><li><strong>Long-Term Potentiation (LTP):</strong> a process where repeated neural activity strengthens synaptic connections, making communication between neurons more efficient.</li><li><strong>Long-Term Depression (LTD):</strong> a process where specific patterns of neural activity weaken synaptic connections, allowing neural circuits to reorganize.</li></ul><p>These mechanisms play a fundamental role in learning and memory because they allow the brain to adapt based on experience. Similarly, repeated rTMS stimulation is thought to induce plastic changes that influence how neural circuits communicate.</p><p>Although the exact biological pathways are still under investigation, evidence suggests that rTMS can affect neurotransmitter release, functional connectivity, and the synchronization of large-scale brain networks.</p><p>In other words, rTMS does not simply “activate” neurons, it can reshape how neural circuits communicate and adapt over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/0*0Xuyoak2HhDlfjkC" /><figcaption><strong>image source : [</strong><a href="https://fieldtriphealth.ca/transcranial-magnetic-stimulation-depression-treatment/"><strong>Link</strong></a><strong>]</strong></figcaption></figure><h3><strong>Frequency Matters</strong></h3><p>Interestingly, not all magnetic stimulation produces the same outcome.</p><p>The physiological effect depends heavily on stimulation parameters, including:</p><ul><li>Stimulation frequency</li><li>Pulse intensity</li><li>Number of pulses</li><li>Coil orientation</li><li>Targeted cortical region</li></ul><p>As a general principle:</p><ul><li><strong>Low-frequency stimulation (around 1 Hz)</strong> tends to reduce cortical excitability.</li><li><strong>High-frequency stimulation (typically 5–20 Hz)</strong> often enhances cortical excitability.</li></ul><p>More recently, protocols such as Theta Burst Stimulation (TBS), a specialized form of rTMS, have gained attention. By delivering magnetic pulses in patterns that mimic the brain’s natural theta rhythms, TBS can induce plastic changes in neural circuits while significantly reducing stimulation time</p><p>This illustrates an important idea:</p><p><strong>In brain stimulation, timing can be just as important as intensity.</strong></p><h3>From Observation to Neuromodulation</h3><p>rTMS allows neuroscientists to ask a different kind of question.</p><p>Instead of observing that a brain region becomes active during a cognitive task, researchers can temporarily perturb that region and determine whether performance actually changes.</p><p>This transforms neuroscience from an observational science into an experimental one. Rather than asking:</p><p><em>“Which brain areas become active?”</em></p><p>we can ask:</p><p><em>“Which brain areas are necessary for this function?”</em></p><p>That ability to probe causal relationships is one of the reasons rTMS has become an indispensable tool in cognitive neuroscience.</p><h3>Beyond the Laboratory</h3><p>The same mechanisms that make rTMS valuable for research have also made it an increasingly important clinical technology.</p><p>Today, rTMS is an established treatment for conditions such as:</p><ul><li>Treatment-resistant Major Depressive Disorder</li><li>Obsessive-Compulsive Disorder (OCD)</li><li>Smoking addiction</li><li>Migraine</li></ul><p>Researchers are also investigating its potential in:</p><ul><li>Stroke rehabilitation</li><li>Parkinson’s disease</li><li>Chronic pain</li><li>Tinnitus</li><li>Alzheimer’s disease</li><li>Cognitive enhancement</li></ul><p>While many of these applications remain under active investigation, the field is advancing remarkably quickly.</p><h3>Where AI Becomes Part of the Loop</h3><p>Imagine a system capable of continuously monitoring brain activity through EEG. A Deep Learning model analyzes oscillatory dynamics, functional connectivity, or biomarkers in real time. The algorithm predicts the optimal stimulation parameters based on the current neural state.</p><p>Finally, rTMS delivers personalized stimulation exactly when and where it is needed.</p><p>This concept is known as closed-loop neuromodulation.</p><p>Instead of applying identical stimulation protocols to every individual, future systems may continuously adapt stimulation according to each person’s ongoing brain dynamics.</p><p>This represents a major step toward precision neuroscience.</p><h3>Looking Ahead</h3><blockquote><em>The future of neuroscience may not only be about decoding the brain’s activity, but also about understanding how to interact with it intelligently.</em></blockquote><blockquote><em>The combination of EEG, AI, and rTMS brings us one step closer to building systems that can listen to the brain, learn from it, and respond to it.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f3fbc9d79a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Between Waves & Weights — Week 3: Why Preprocessing Matters in EEG-Based BCI]]></title>
            <link>https://mahdisbagheri.medium.com/between-waves-weights-week-3-why-preprocessing-matters-in-eeg-based-bci-5da1de03da0b?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/5da1de03da0b</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 15:36:18 GMT</pubDate>
            <atom:updated>2026-07-29T16:15:27.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aVYEU20BEvoySjy_.jpg" /><figcaption><strong>image source : [</strong><a href="https://www.cognixion.com/blog/2018/10/19/using-brain-computer-interfaces-to-enable-the-disabled"><strong>Link</strong></a><strong>]</strong></figcaption></figure><p>Neural decoding is the process of translating recorded brain activity into meaningful information, such as a user’s intention, imagined movement, internal speech, or emotional state. In EEG-based Brain–Computer Interfaces (BCIs), this decoding process enables direct communication between the brain and external devices without relying on muscles or peripheral nerves, making it a promising technology for assistive communication, neurorehabilitation, and human–computer interaction.</p><p>Modern EEG-BCI research spans six major paradigms, each decoding a different aspect of brain activity:</p><ul><li><strong>Event-Related Potentials (ERP/P300): </strong>Measures the brain’s response to a meaningful visual stimulus. In a typical P300 spelling system, letters on a screen flash one by one. When the user focuses on the desired letter, the brain produces a distinctive P300 signal, enabling the BCI to identify the intended letter without any physical movement.</li><li><strong>Steady-State Visual Evoked Potentials (SSVEP):</strong> Decodes brain activity synchronized with the frequency of a flickering visual stimulus. When multiple targets flicker at different frequencies, focusing on one target generates EEG oscillations at the same frequency, enabling fast and reliable selection of commands or device control.</li><li><strong>Motor Imagery (MI):</strong> Decodes imagined limb movements without physical execution, making it one of the most established paradigms for neurorehabilitation and prosthetic control.</li><li><strong>Speech Imagery (SI):</strong> Attempts to recognize silently imagined words or phonemes directly from neural activity, representing a promising direction for restoring communication in individuals with severe speech impairments.</li><li><strong>Visual Imagery (VI):</strong> Infers internally generated visual representations, aiming to decode what a person imagines rather than what they physically observe.</li><li><strong>Emotion Recognition:</strong> Identifies affective states from EEG patterns, expanding BCIs beyond motor control toward adaptive and personalized human–computer interaction.</li></ul><p>Despite these advances, EEG remains one of the most challenging biological signals to decode. It suffers from a low signal-to-noise ratio (SNR), substantial variability across individuals, and pronounced non-stationarity across recording sessions.</p><p>For this reason, preprocessing and denoising are not optional engineering steps — they are fundamental components of every EEG decoding pipeline. Whether a study employs traditional machine learning or state-of-the-art deep learning architectures, the quality of preprocessing often determines how accurately the recorded EEG reflects the underlying neural processes.</p><h3>Why Preprocessing Deserves More Attention</h3><p>Much of the recent literature emphasizes comparing CNNs, Transformers, Conformers, or other deep learning architectures. While these comparisons are valuable, they often overlook an equally important factor: the preprocessing pipeline.</p><p>Before any model receives EEG data, several processing steps are typically performed:</p><ul><li><strong>Band-pass filtering:</strong> removes unwanted frequency components while preserving the frequency bands relevant to the target cognitive task.</li><li><strong>Artifact removal:</strong> suppresses contamination caused by eye movements, muscle activity, heartbeats, or electrical noise.</li><li><strong>Re-referencing:</strong> changes the reference electrode configuration to improve signal consistency and spatial interpretability.</li><li><strong>Signal normalization:</strong> rescales EEG amplitudes to stabilize training and reduce variability between recordings.</li><li><strong>Channel selection:</strong> identifies the most informative electrodes, reducing computational complexity while maintaining useful neural information.</li><li><strong>Segmentation into analysis windows:</strong> divides continuous EEG recordings into fixed temporal segments that can be used as model inputs.</li></ul><p>Each of these decisions changes the statistical properties of the input data. Consequently, differences in reported performance may reflect preprocessing choices rather than genuine improvements in the decoding algorithm.</p><h3>Deep Learning Is Not Always the Answer</h3><p>Deep learning has undoubtedly expanded the capabilities of EEG decoding, but it has not replaced traditional machine learning.</p><p>Classical approaches continue to provide strong baselines, especially when datasets are relatively small:</p><ul><li><strong>Linear Discriminant Analysis (LDA):</strong> a simple linear classifier that is computationally efficient and widely used as a baseline.</li><li><strong>Support Vector Machines (SVM):</strong> effective for separating EEG classes in high-dimensional feature spaces, particularly with limited training data.</li><li><strong>Random Forests:</strong> ensemble-based classifiers that improve robustness by combining multiple decision trees.</li><li><strong>Common Spatial Pattern (CSP):</strong> a feature extraction method that enhances discriminative spatial information, particularly for motor imagery tasks.</li></ul><p>Meanwhile, deep learning demonstrates its greatest advantages when combined with modern training strategies such as:</p><ul><li><strong>Self-supervised learning:</strong> learns meaningful EEG representations without requiring extensive labeled data.</li><li><strong>Transfer learning:</strong> adapts knowledge learned from one dataset or subject to another with minimal retraining.</li><li><strong>Domain adaptation:</strong> reduces differences between recording sessions, devices, or participants.</li><li><strong>Continual learning:</strong> enables models to update over time while minimizing catastrophic forgetting.</li></ul><p>Rather than simply increasing network depth, these strategies address one of EEG’s most fundamental challenges: distribution shifts across subjects, sessions, and recording devices.</p><h3>The Importance of Input Representation</h3><p>An important insight from recent research is that the representation of EEG data may influence performance more than the choice of neural network.</p><p>Researchers commonly employ three input formats:</p><ul><li><strong>Raw time-series signals:</strong> preserve the original temporal dynamics of EEG recordings and are commonly used with end-to-end models.</li><li><strong>Time-frequency representations:</strong> transform EEG into spectrogram-like images that capture both temporal and spectral information.</li><li><strong>Hand-crafted features:</strong> summarize EEG using engineered descriptors such as spectral power, covariance matrices, or spatial filters.</li></ul><p>Each representation naturally favors different model families.</p><p>For example:</p><ul><li><strong>1D CNNs</strong> are well suited for raw temporal signals.</li><li><strong>2D CNNs</strong> excel at learning patterns from time-frequency images.</li><li><strong>Classical machine learning</strong> often performs competitively when carefully engineered features are available.</li></ul><p>Therefore, comparing two models without controlling for the input representation can easily produce misleading conclusions.</p><h3>Clinical Implications</h3><p>Unlike laboratory datasets collected from healthy participants, clinical EEG recordings are substantially more heterogeneous. Lesion location, recovery stage, medication, fatigue, electrode placement, and recording conditions all influence neural activity.</p><p>Consequently, developing clinically useful BCIs requires models that generalize across patients and recording sessions — not simply models that achieve high offline accuracy on a single dataset.</p><p>Future EEG-BCI research should therefore prioritize:</p><ul><li><strong>Strict subject-level evaluation:</strong> ensuring that data from the same individual never appear in both training and testing sets.</li><li><strong>Leakage-free preprocessing:</strong> estimating preprocessing parameters exclusively from the training data to avoid optimistic performance estimates.</li><li><strong>Transparent reporting of experimental protocols:</strong> documenting preprocessing, segmentation, normalization, and evaluation settings in sufficient detail for reproducibility.</li><li><strong>Robust cross-session validation:</strong> demonstrating that models remain reliable despite changes across recording sessions.</li><li><strong>Real-world usability:</strong> evaluating calibration time, robustness, and long-term stability rather than focusing solely on benchmark accuracy.</li></ul><h3>Looking Forward</h3><p>The future of EEG-based BCIs is unlikely to be determined by increasingly deeper neural networks alone.</p><p>Instead, meaningful progress will come from designing systems that are:</p><ul><li><strong>Robust to noise:</strong> capable of distinguishing neural activity from physiological and environmental artifacts.</li><li><strong>Resistant to distribution shifts:</strong> maintaining reliable performance across subjects, sessions, and recording devices.</li><li><strong>Transferable across users:</strong> requiring minimal recalibration for new individuals.</li><li><strong>Efficient with limited labeled data:</strong> reducing the dependence on expensive annotation through modern learning strategies.</li><li><strong>Clinically deployable:</strong> operating reliably under realistic healthcare conditions rather than only in laboratory environments.</li></ul><p>As the field moves toward real-world clinical deployment, the central question is no longer:</p><blockquote><strong><em>“Which model achieves the highest accuracy?”</em></strong></blockquote><p>but rather:</p><blockquote><strong><em>“Which system can reliably generalize to new users under realistic conditions?”</em></strong></blockquote><p>Answering that question will define the next generation of EEG-based Brain–Computer Interfaces.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5da1de03da0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Between Waves & Weights — Week 2: Brain Rhythms & EEG Frequency Bands]]></title>
            <link>https://mahdisbagheri.medium.com/between-waves-weights-week-2-brain-rhythms-eeg-frequency-bands-94f5a845cbc0?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/94f5a845cbc0</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 20:29:31 GMT</pubDate>
            <atom:updated>2026-07-27T21:07:07.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/682/0*NTAQbR3AIySvI5zi" /><figcaption><strong>image source : [</strong><a href="https://www.globalvegetarian.ca/meditation-and-the-brain-waves/"><strong>Link</strong></a><strong>]</strong></figcaption></figure><p>Last week, I explored how EEG signals are recorded. Once these electrical signals are captured, the next question naturally follows:</p><p><strong>What exactly are we measuring?</strong></p><p>Although EEG recordings often appear as irregular waveforms, they are far from random. Hidden within these signals are rhythmic oscillations that reflect synchronized neural activity across the brain. These oscillations, commonly known as brain rhythms, are one of the most fundamental concepts in EEG analysis.</p><h3>1. What Are Brain Rhythms?</h3><p>When large populations of cortical neurons become active in a synchronized manner, their electrical activity combines to produce rhythmic oscillations that can be measured by EEG electrodes.</p><p>These oscillations vary in frequency, amplitude, and spatial distribution, reflecting different neural processes occurring within the brain.</p><h3>2. Looking at EEG in the Frequency Domain</h3><p>EEG signals can be analyzed in two complementary ways.</p><p>The <strong>time domain</strong> represents how voltage changes over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wY0MgprneomOIcZpx4HvsQ.png" /><figcaption>Example of a single-channel EEG signal represented in the time domain.</figcaption></figure><p>The <strong>frequency domain</strong> describes how much power is contained within different frequencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*aDZJWvaNXhDlxvgTcQ0SsA.png" /><figcaption>Frequency-domain representation of the EEG signal obtained using the Fourier Transform</figcaption></figure><p>A mathematical transformation, such as the Fast Fourier Transform (FFT), converts the EEG signal from the time domain into its frequency spectrum.</p><p>Two EEG signals may have the same frequency while having completely different amplitudes. Likewise, signals with similar amplitudes may oscillate at very different frequencies.</p><p>Instead of observing individual oscillations, researchers can identify which frequency bands contain the greatest amount of energy. This representation is commonly known as the <strong>Power Spectrum</strong>.</p><h3>3. Why Does the Brain Produce Different Frequencies?</h3><p>Brain activity is constantly changing as we sleep, think, remember, move, and perceive the world around us.</p><p>Different neural circuits communicate over different time scales. As a result, synchronized neuronal activity can occur at both slow and fast frequencies.</p><p>For example:</p><ul><li>Slow oscillations become dominant during deep sleep.</li><li>Intermediate rhythms often appear during relaxed wakefulness.</li><li>Faster oscillations are commonly associated with attention, perception, and active cognitive processing.</li></ul><p>Rather than representing isolated brain functions, these rhythms reflect different modes of communication within large-scale neural networks.</p><h3>4. The Classical EEG Frequency Bands</h3><p>Although brain activity exists across a continuous spectrum of frequencies, EEG signals are traditionally divided into five major frequency bands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*KbHdGVP-HZzRgwW3.png" /><figcaption>image source: [<a href="https://www.neuronic.online/blog/what-are-the-different-types-of-brain-waves">Link</a>]</figcaption></figure><p><strong>Delta (0.5–4 Hz)</strong></p><p>Delta waves are the slowest EEG rhythms and typically exhibit the largest amplitudes.</p><p>They are most prominent during deep, slow-wave sleep and are believed to support restorative physiological processes.</p><p>In awake adults, excessive delta activity may indicate neurological abnormalities or brain injury.</p><p><strong>Theta (4–8 Hz)</strong></p><p>Theta rhythms are commonly observed during drowsiness, light sleep, meditation, and memory-related tasks.</p><p>Research has shown that theta activity plays an important role in learning, memory encoding, and navigation.</p><p>Increased frontal theta activity is frequently reported during tasks requiring sustained mental effort.</p><p><strong>Alpha (8–13 Hz)</strong></p><p>Alpha rhythm is one of the most recognizable EEG patterns.</p><p>It is strongest when a person is awake, relaxed, and resting with their eyes closed.</p><p>One classic EEG demonstration involves asking a participant to close their eyes. Almost immediately, alpha activity increases over the occipital region, where visual processing occurs. Opening the eyes suppresses this rhythm, a phenomenon known as <em>alpha blocking</em>.</p><p>Because of its reliability, alpha activity has become one of the most widely studied EEG rhythms.</p><p><strong>Beta (13–30 Hz)</strong></p><p>Beta activity is associated with active thinking, concentration, problem-solving, and motor preparation.</p><p>It often becomes more pronounced during tasks requiring focused attention or voluntary movement.</p><p>Compared with slower rhythms, beta waves generally have lower amplitudes but occur at much higher frequencies.</p><p><strong>Gamma (&gt;30 Hz)</strong></p><p>Gamma oscillations represent the fastest of the classical EEG frequency bands.</p><p>They have been associated with sensory perception, attention, feature integration, and higher cognitive functions.</p><p>However, measuring gamma activity with scalp EEG is challenging because muscle activity can generate high-frequency signals that resemble genuine gamma oscillations. Careful preprocessing is therefore essential when studying this frequency range.</p><h3>5. Brain Rhythms Are Not Strict Categories</h3><p>A common misconception is that each EEG frequency band corresponds to a single mental state.</p><p>In reality, brain rhythms overlap continuously.</p><p>A person may simultaneously exhibit alpha activity in the occipital cortex, beta activity over motor regions, and theta oscillations in frontal areas.</p><p>Furthermore, the same frequency band can participate in multiple cognitive processes depending on the brain region, task, and individual.</p><p>These frequency bands should therefore be viewed as useful conventions rather than rigid biological boundaries.</p><h3>8. AI Perspective</h3><p>Traditional machine learning models often rely on handcrafted features derived from frequency analysis, including:</p><ul><li>Band power</li><li>Power Spectral Density (PSD)</li><li>Spectral entropy</li><li>Theta/Beta ratio</li><li>Relative alpha power</li></ul><p>Modern deep learning approaches can learn directly from raw EEG signals, spectrograms, or time-frequency representations. Nevertheless, many of these models ultimately capture patterns that closely resemble the classical EEG rhythms.</p><h3>9. Reflection</h3><p>Brain rhythms are far more than frequency labels. They reflect coordinated neural activity across large populations of neurons and form the foundation of how we interpret brain function. Before applying machine learning models, it’s worth remembering that every EEG signal already carries a rich temporal structure shaped by these rhythms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94f5a845cbc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Between Waves & Weights — Week 1: The Technical Foundations of EEG Signals]]></title>
            <link>https://mahdisbagheri.medium.com/between-waves-weights-week-1-the-technical-foundations-of-eeg-signals-76cbbc248b84?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/76cbbc248b84</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 17:46:09 GMT</pubDate>
            <atom:updated>2026-07-27T18:04:41.427Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*qvhRpOt7lbIpT82bkddX-w.png" /><figcaption><strong>image source : [ </strong><a href="https://somatosphere.com/2019/staging-seizure-the-chronic-contingency-of-epilepsy-diagnosis.html/"><strong>Link </strong></a><strong>]</strong></figcaption></figure><p>Before analyzing EEG signals or applying machine learning models, it is important to understand how EEG is actually recorded. Many preprocessing choices, model architectures, and interpretation methods depend on the technical characteristics of the recording system itself.</p><p>This week focuses on the fundamentals of EEG acquisition, from electrode placement to sampling frequency.</p><p><strong>1. Why Electrode Placement Matters</strong></p><p>EEG electrodes do not measure activity from a single neuron. Instead, each electrode records the summed electrical activity of millions of cortical neurons beneath the scalp.</p><p>The location of each electrode therefore determines which brain regions contribute most strongly to the recorded signal. Consistent electrode placement is essential for comparing recordings across participants, laboratories, and datasets.</p><p><strong>2. The International 10–20 System</strong></p><p>EEG electrodes are typically positioned according to the International 10–20 System, the most widely used standard for electrode placement. The system defines electrode locations relative to anatomical landmarks on the head, including the nasion, inion, and the left and right preauricular points. Rather than using fixed distances, electrode positions are determined as percentages of these head measurements, allowing the layout to adapt to different head sizes.</p><p>The name <strong>10–20</strong> refers to the spacing between adjacent electrodes: the first and last intervals are <strong>10%</strong> of the measured distance, while the intermediate intervals are <strong>20%</strong>. This proportional placement ensures that electrodes are positioned consistently over corresponding cortical regions across individuals, enabling reproducible EEG recordings and meaningful comparisons between studies conducted at different laboratories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*6PMu-A6T6wSyUGIMFrhf6w.png" /></figure><p><strong>3. Electrode Naming</strong></p><p>Each electrode name contains both a letter and a number.</p><p>The letter indicates the cortical region:</p><ul><li><strong>Fp</strong> — Frontopolar</li><li><strong>F</strong> — Frontal</li><li><strong>C</strong> — Central</li><li><strong>T</strong> — Temporal</li><li><strong>P</strong> — Parietal</li><li><strong>O</strong> — Occipital</li></ul><p>The number specifies the hemisphere:</p><ul><li>Odd numbers → Left hemisphere</li><li>Even numbers → Right hemisphere</li><li><strong>z</strong> → Midline (zero)</li></ul><p>For example:</p><ul><li><strong>F3</strong> → Left frontal cortex</li><li><strong>F4</strong> → Right frontal cortex</li><li><strong>Cz</strong> → Center of the scalp</li></ul><p><strong>4. Brain Regions</strong></p><p>Although EEG has relatively low spatial resolution, electrode locations roughly correspond to functional brain areas.</p><ul><li><strong>Frontal:</strong> planning, decision making, executive functions</li><li><strong>Central:</strong> motor control</li><li><strong>Parietal:</strong> sensory integration</li><li><strong>Temporal:</strong> hearing and memory</li><li><strong>Occipital:</strong> visual processing</li></ul><p>Understanding these regions helps interpret why certain electrodes become more informative for specific cognitive tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*AbrqUBIG_qXzSxZURoW-OQ.png" /></figure><p><strong>5. From 10–20 to High-Density EEG</strong></p><p>Modern EEG systems vary greatly in the number of electrodes.</p><p>Typical systems include:</p><ul><li>16 channels</li><li>32 channels</li><li><strong>64 channels</strong></li><li>128 channels</li><li>256 channels</li></ul><p>A <strong>64-channel EEG</strong> provides substantially better spatial coverage than lower-density systems while remaining practical for most neuroscience and BCI studies.</p><p>Higher-density recordings improve spatial sampling but also increase setup time, computational cost, and preprocessing complexity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*fX8mCteqL-_0JGXCTS735Q.png" /><figcaption><strong>image source : [</strong><a href="https://pressrelease.brainproducts.com/choosing-your-electrode-technology/"><strong>Link</strong></a><strong>]</strong></figcaption></figure><p><strong>6. EEG Referencing</strong></p><p>EEG measures voltage differences, not absolute voltages. Every recorded channel is measured relative to a reference.</p><p>Several referencing strategies are commonly used.</p><p><strong>Referential Reference</strong></p><p>Each electrode is referenced to a single electrode, often placed on the mastoid, earlobe, or Cz.</p><p>Simple and widely used, but the choice of reference can influence the recorded signals.</p><p><strong>Bipolar Reference</strong></p><p>The voltage difference is computed between two neighboring electrodes.</p><p>This approach often reduces common noise and emphasizes local activity.</p><p><strong>Average Reference</strong></p><p>The average of all electrodes is used as the reference.</p><p>Average referencing is particularly effective for high-density EEG recordings and is commonly adopted in modern research.</p><p><strong>7. Useful EEG Frequency Range</strong></p><p>Although EEG hardware may record a broad spectrum of frequencies, most physiologically meaningful EEG activity lies between <strong>0.5 and 100 Hz</strong>.</p><p>Many studies focus on an even narrower range: <strong>1–40 Hz</strong></p><p>because it contains the classical EEG rhythms:</p><ul><li>Delta (0.5–4 Hz): Deep sleep, slow-wave activity</li><li>Theta (4–8 Hz): Drowsiness, memory processes, meditation</li><li>Alpha (8–13 Hz): Relaxed wakefulness, especially with eyes closed</li><li>Beta (13–30 Hz): Active thinking, attention, cognitive engagement</li><li>Gamma (&gt;30 Hz): Sensory processing, attention, higher cognitive functions</li></ul><p><strong>8. Sampling Frequency</strong></p><p>EEG signals are recorded digitally by sampling the continuous electrical signal at regular time intervals.</p><p>The sampling frequency (Hz) indicates how many measurements are taken each second.</p><p>For example:</p><ul><li>250 Hz → 250 samples per second</li><li>500 Hz → 500 samples per second</li></ul><p>Higher sampling rates preserve more temporal detail but also generate larger datasets.</p><p>Common sampling frequencies used in EEG acquisition include:</p><ul><li><strong>128 Hz</strong> — Common in portable and wearable EEG devices where low power consumption and reduced data storage are priorities.</li><li><strong>250 Hz</strong> — A widely used sampling frequency in research, sufficient for most cognitive and clinical EEG studies.</li><li><strong>256 Hz</strong> — Another popular choice because it is a power of two, making digital signal processing more computationally efficient.</li><li><strong>500 Hz</strong> — Frequently used when higher temporal precision or more detailed signal analysis is required.</li><li><strong>512 Hz</strong> — Similar to 500 Hz but preferred in many commercial EEG systems due to its computational advantages in digital signal processing.</li><li><strong>1000 Hz</strong> — Used in high-resolution research, particularly when analyzing high-frequency EEG activity or combining EEG with other neurophysiological recordings.</li><li><strong>1024 Hz</strong> — Another common high-resolution sampling frequency. As a power of two, it is well suited for FFT-based spectral analysis and other signal processing algorithms.</li></ul><p><strong>Nyquist Theorem</strong></p><p>According to the Nyquist Theorem, the sampling frequency must be at least twice the highest frequency present in the signal.</p><p>For example:</p><p>If the highest frequency of interest is <strong>100 Hz</strong>, the sampling frequency should be <strong>at least 200 Hz</strong>.</p><p>Sampling below this limit introduces <em>aliasing</em>, where higher-frequency components appear as lower-frequency signals, distorting the recording.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*OQ9A1coAqHuUE8X68rtfxg.png" /><figcaption><strong>Image source : [</strong><a href="https://www.geeksforgeeks.org/electronics-engineering/nyquist-sampling-theorem/"><strong>Link</strong></a><strong>]</strong></figcaption></figure><p><strong>Why Higher Sampling Isn’t Always Better</strong></p><p>A common misconception is that higher sampling frequencies always improve EEG analysis.</p><p>In practice, this is not necessarily true.</p><p>Increasing the sampling rate:</p><ul><li>increases storage requirements,</li><li>increases computational cost,</li><li>lengthens training time for deep learning models,</li></ul><p>while providing little additional information if the frequencies of interest are already well below the Nyquist limit.</p><p>For many cognitive EEG studies, <strong>250–512 Hz</strong> is entirely sufficient.</p><p><strong>9. AI Perspective</strong></p><p>Understanding EEG acquisition is not only important for neuroscientists but also for AI researchers.</p><p>Many differences between public EEG datasets arise from:</p><ul><li>different electrode layouts,</li><li>different references,</li><li>different sampling frequencies,</li><li>different numbers of channels.</li></ul><p>Ignoring these acquisition parameters can significantly reduce model generalization across datasets.</p><p>Successful EEG deep learning often begins with understanding how the data were recorded, not only how the neural network is designed.</p><p><strong>10. Reflection</strong></p><p>One idea that became increasingly clear while studying EEG is that recording choices are part of the data itself. Electrode placement, referencing, and sampling frequency all shape the signals long before preprocessing or machine learning begins.</p><p>Understanding these technical foundations makes it much easier to interpret published research and to build more reliable AI models for EEG analysis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76cbbc248b84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Between Waves & Weights — Week 0: An Introduction to EEG]]></title>
            <link>https://mahdisbagheri.medium.com/between-waves-weights-week-1-understanding-eeg-02ffb02299f1?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/02ffb02299f1</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 14:10:24 GMT</pubDate>
            <atom:updated>2026-07-26T18:34:44.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/488/0*m3a__jCdEPW2Hch-" /><figcaption>Image source: [<a href="https://www.cognitive-development.ceu.edu/research-methods/eeg">link</a>]</figcaption></figure><h3><strong>Week 0 —</strong>An Introduction to EEG</h3><blockquote><em>Every second, billions of neurons communicate through tiny electrical signals. EEG gives us a way to observe this activity, without opening the skull. Despite its simplicity, EEG remains one of the most widely used tools in neuroscience, medicine, and increasingly, artificial intelligence.</em></blockquote><h3>1. Understanding EEG</h3><p>Electroencephalography (EEG) is a non-invasive technique used to record the brain’s electrical activity through electrodes placed on the scalp. Rather than measuring the activity of individual neurons, EEG captures the synchronized electrical activity generated by large populations of cortical neurons. Consequently, the recorded signals are relatively weak and highly susceptible to various sources of interference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mk2seJl1ZcplXYjDM0Z1_A.png" /><figcaption><strong><em>A single neuron. EEG records the summed electrical activity of large populations of neurons.</em></strong></figcaption></figure><p>One of the defining characteristics of EEG is its <em>high temporal resolution</em>, allowing neural activity to be observed on the order of milliseconds. This makes EEG particularly suitable for studying rapidly changing cognitive processes.</p><p>EEG has an important limitation: its relatively<em> poor spatial resolution</em>. Compared with imaging techniques such as MRI and fMRI, EEG is considerably less accurate in identifying the precise location of neural activity within the brain.</p><h3>2. Challenges in EEG Analysis</h3><p>Although EEG is a powerful tool for studying brain activity, several characteristics of the data make analysis particularly challenging.</p><h4>Low Signal-to-Noise Ratio (SNR)</h4><p>The electrical activity generated by the brain is relatively weak, while numerous external and physiological factors introduce unwanted noise into the recordings. As a result, the signals of interest are often difficult to distinguish from background interference.</p><h4>Artifacts</h4><p>Another major challenge is the presence of artifacts. Artifacts are signals that originate from sources other than neural activity. Common examples include:</p><p><strong>·</strong> Eye blinks</p><p><strong>·</strong> Eye movements</p><p><strong>·</strong> Muscle contractions</p><p><strong>·</strong> Body movements</p><p><strong>·</strong> Electrical interference from surrounding devices</p><p>In many recordings, these artifacts have much larger amplitudes than the EEG signal itself, making preprocessing an essential step in almost every EEG analysis pipeline.</p><h4>Inter-subject Variability</h4><p>EEG recordings can differ substantially across individuals, even when participants perform exactly the same cognitive or motor task.</p><h4><strong>Limited Data</strong></h4><p>Compared with computer vision datasets containing millions of labeled images, EEG datasets are typically much smaller because collecting brain signals is expensive and time-consuming. Recording EEG requires:</p><p><strong>·</strong> Specialized hardware</p><p><strong>·</strong> Carefully designed experiments</p><p><strong>·</strong> Human participants</p><p><strong>·</strong> Extensive annotation and quality control</p><p>These limitations have motivated the growing adoption of <em>transfer learning</em>, <em>self-supervised learning</em>, and <em>data augmentation</em> in recent EEG research.</p><h3>3. Major Research Directions in EEG</h3><p>The wide range of EEG applications demonstrates its importance across neuroscience, medicine, and artificial intelligence.</p><p>Some of the major research areas include:</p><h4>Neurological Disorders</h4><p>EEG plays an important role in the diagnosis and monitoring of conditions such as:</p><p><strong>·</strong> Epilepsy</p><p><strong>·</strong> Alzheimer’s disease</p><p><strong>·</strong> Parkinson’s disease</p><p><strong>·</strong> Sleep disorders</p><h4>Brain–Computer Interfaces (BCIs)</h4><p>Brain–Computer Interfaces (BCIs) translate EEG signals into commands that allow direct communication between the brain and external devices. These systems are increasingly used for controlling:</p><p>· Robotic arms</p><p>· Prosthetic limbs</p><p>· Wheelchairs</p><p>· Computer interfaces</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2HNgNcW_YPfzRrakYL1BA.jpeg" /><figcaption><strong>Neural signals are decoded to generate control commands for a prosthetic hand.</strong></figcaption></figure><h4>Cognitive State Monitoring</h4><p>Researchers also use EEG to estimate cognitive states, including:</p><p><strong>·</strong> Attention</p><p><strong>·</strong> Mental workload</p><p><strong>·</strong> Fatigue</p><p><strong>·</strong> Memory performance</p><p><strong>·</strong> Stress</p><h4>Emotion Recognition</h4><p>Emotion recognition combines neuroscience, psychology, and artificial intelligence. Although identifying emotional states directly from EEG remains challenging, recent studies suggest that meaningful emotional information can be extracted under controlled conditions.</p><h3>4. The Role of Deep Learning</h3><p>Traditional EEG analysis has largely relied on manually engineered features designed using signal processing expertise. In contrast, deep learning aims to learn informative representations directly from raw or minimally processed EEG recordings.</p><p>Among the deep learning architectures most commonly used for EEG analysis are:</p><p><strong>·</strong> <strong>Convolutional Neural Networks (CNNs)</strong> for learning local spatial and temporal patterns.</p><p><strong>·</strong> <strong>Recurrent Neural Networks (RNNs)</strong> and <strong>LSTMs</strong> for modeling temporal dependencies.</p><p><strong>·</strong> <strong>Transformers</strong> for capturing long-range relationships within EEG signals.</p><p><strong>·</strong> <strong>Graph Neural Networks (GNNs)</strong> for modeling spatial relationships among EEG electrodes.</p><h3>5. Reflection and Learning Roadmap</h3><p>One thing I realized while reading the literature is that EEG is much more than just another time-series dataset. Understanding the underlying neuroscience is just as important as choosing the right neural network architecture.</p><p>Over the coming weeks, I plan to continue documenting this learning journey through the systematic review of research papers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02ffb02299f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When God Speaks in Numbers]]></title>
            <link>https://mahdisbagheri.medium.com/when-god-speaks-in-numbers-a221748ecac0?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/a221748ecac0</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 17:17:56 GMT</pubDate>
            <atom:updated>2025-09-24T17:31:06.749Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>When God Speaks in Numbers</strong></p><p>“<em>An equation for me has no meaning unless it expresses a thought of God.</em>” Srinivasa Ramanujan (1887–1920)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jhH9puU53Kg-Uc8z.jpg" /><figcaption>image from <a href="https://indianexpress.com/article/evergreen/srinivasa-ramanujan-untold-story-9078961/">link</a></figcaption></figure><p>Ramanujan was a self-taught Indian mathematician who believed that his ideas came to him as divine inspiration. He was one of the most extraordinary figures of the 20th century, a man who played with numbers the way impressionists played with colours. For him, equations seemed to come as naturally as nest-building comes to birds. Without a formal degree, he sent some of his formulas to G.H. Hardy at Cambridge, and Hardy soon realised he was corresponding with a genius.</p><p>One of Ramanujan’s most dazzling feats was his work on the <strong>summation of divergent series</strong>. He claimed that the sum of all natural numbers equals -1/12. At first glance, it looks not only wrong but absurd, like trying to count the drops in the ocean and then insisting the answer is a fraction. But Ramanujan had a way of giving meaning to such divergent series through clever manipulations. For him, mathematics wasn’t about obeying boundaries; it was about pushing them. Not all of his theories turned out to be correct, but his infinite series reminds us that intelligence sometimes lies in daring to touch the untouchable.</p><p>Here’s a glimpse of how his strange yet beautiful reasoning worked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-JI9_dQKuU6D3BgoZHdIA.png" /></figure><p><strong>1729 (The Hardy–Ramanujan Number)</strong><br> When Ramanujan was hospitalised in England, G.H. Hardy once came to visit him. Hardy recalled:<br> “<em>I remember once going to see him when he was lying ill at Putney. I had ridden in taxi cab number 1729 and remarked that the number seemed to me rather a dull one, and that I hoped it was not an unfavourable omen. ‘No,’ he replied, ‘it is a very interesting number; it is the smallest number expressible as the sum of two cubes in two different ways.’”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*6ZTTRapdVfQF6WzBScLE2A.png" /></figure><p>Today, this is fondly remembered as the <strong>Hardy–Ramanujan number</strong>.</p><p>Ramanujan’s life was tragically short, but his output was astonishing. He filled notebooks with formulas — some proven, some still puzzling — that continue to inspire mathematicians today. His legacy is proof that sometimes genius doesn’t follow the rules… it rewrites them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a221748ecac0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Euclid’s theorem, in very simple language]]></title>
            <link>https://mahdisbagheri.medium.com/euclids-theorem-in-very-simple-language-e4c09c471c94?source=rss-1ff67a440738------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4c09c471c94</guid>
            <dc:creator><![CDATA[Mahdis bagheri]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 21:08:59 GMT</pubDate>
            <atom:updated>2025-08-21T22:20:36.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NXlPxVRpYlTA-uXm8F_fvg.png" /></figure><p>Imagine: on a lovely evening, you’re walking in a park, relaxed and happy with an iced matcha latte in hand and the weather perfect.<br> In this situation, one of the most unlikely things to happen is that a car pulls up, someone jumps out with a gun, and shouts: <strong><em>“Either teach me Euclid’s theorem on the infinitude of prime numbers in simple language, or you die.”</em></strong></p><p>If you have no clue about Euclid’s theorem, or you used to sleep through math classes, this 3‑step guide can save your life (since nothing is impossible in this world).</p><p><strong>Step 1.</strong> Take a deep breath and savour your drink.<br> <strong>Step 2.</strong> Invite the math-obsessed maniac to sit on a bench.<br> <strong>Step 3.</strong> Recite the following lines…</p><p>“Ok, let’s start from the very beginning.</p><p>Natural numbers are either prime or not prime. Prime numbers are only divisible by 1 and themselves (for example: 7 = 7 × 1, 13 = 13 × 1). Non‑prime (composite) numbers can be written as the product of two or more primes. For example: 6 = 2 × 3, 8 = 2 × 2 × 2.</p><p>Euclid proved that there are infinitely many prime numbers by contradiction. First, we assume the primes are finite (so we can list them), and then we show that this assumption leads to a contradiction.</p><p>Assume the primes are finite. Then we can list them all: p₁, p₂, …, pₙ.</p><p>Supposedly, there is no prime greater than pₙ. Now let’s challenge that. Build a bigger number by multiplying every prime in the list and then adding 1. Call the result q:</p><p>q = p₁ × p₂ × … × pₙ + 1</p><p>Clearly q is larger than every prime in the list. Now check: is q prime or not?</p><ul><li>If q is prime, great, we have found a prime not in the list.</li><li>If q is composite, it must have at least one prime factor. But it cannot be divisible by any prime in our list, because for any listed prime pᵢ we have</li></ul><p>q ≡ 1 (mod pᵢ),</p><p>so dividing q by pᵢ leaves remainder 1.</p><p>Thus, q is either prime itself or has a prime factor not in the list. Either way, the assumption that the list contained all primes is contradicted. Therefore, the assumption “there are finitely many primes” is false, and hence there are infinitely many primes.”</p><p>Afterwards, the psycho probably leaves you alive and lets you go. Or maybe not. By the way, if you found this helpful, like this post, and let’s connect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4c09c471c94" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>