<?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 Amina Kalandarova on Medium]]></title>
        <description><![CDATA[Stories by Amina Kalandarova on Medium]]></description>
        <link>https://medium.com/@kalandarovaaminakhon?source=rss-9d7d869d1b07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eRY5tWbk934Q61D_1nH8Qw.png</url>
            <title>Stories by Amina Kalandarova on Medium</title>
            <link>https://medium.com/@kalandarovaaminakhon?source=rss-9d7d869d1b07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:00:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kalandarovaaminakhon/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[Preprocessing EEG Data for ML Model Use]]></title>
            <link>https://medium.com/@kalandarovaaminakhon/preprocessing-eeg-data-for-ml-model-use-4592dddf0f59?source=rss-9d7d869d1b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/4592dddf0f59</guid>
            <category><![CDATA[neurotech]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[brain-computer-interface]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[preprocesing]]></category>
            <dc:creator><![CDATA[Amina Kalandarova]]></dc:creator>
            <pubDate>Sat, 14 Dec 2024 18:00:57 GMT</pubDate>
            <atom:updated>2024-12-14T19:59:00.483Z</atom:updated>
            <content:encoded><![CDATA[<p>The First Step to Creating Machine Learning Models for Neurotech Applications</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LxUJvsruL-7AGskntlPvIA.png" /></figure><p>Electroencephalography (EEG) data is one of the most challenging yet fascinating sources for machine learning applications. This article provides a <strong>step-by-step guide to preprocessing EEG data using Python</strong>. We’ll leverage a real-world project to demonstrate a practical workflow, complete with code snippets for easy replication.</p><h3>NextGen ML: EEG Forecasting</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Bz3EblYmr7V_FUecCrXzKw.png" /></figure><p>The inspiration for this article comes from my work with the NextGen ML team, a group of ambitious high school students from around the world who are passionate about AI and emerging technologies. Together, we are developing a model to forecast EEG signals using previous samples to predict upcoming brain activity. We recognized a significant limitation in current EEG applications: delays caused by the processing of signals. By leveraging machine learning, we aim to forecast these signals to eliminate delays. My focus within this project has been on the preprocessing stage, and in this article, I’m excited to share the insights and techniques I’ve gained from this experience!</p><h3>Preprocessing is Crucial for EEG Data</h3><p><strong>EEG</strong> (<strong>electroencephalography) </strong>data captures electrical activity from the brain through electrodes placed on the scalp. While rich in temporal resolution, these signals are prone to issues like high dimensionality, sensitivity to noise, and susceptibility to unnecessary artifacts that can ruin the performance of even the most sophisticated ML models. To prepare the data I needed to<strong> detect and remove unnecessary artifacts</strong> such as eye blinks and muscle movements, <strong>filter out noise, </strong>and cater for <strong>high dimensionality </strong>(due to multiple channels recording simultaneously). Preprocessing also involves steps like re-referencing, segmentation, and exporting clean data for downstream ML tasks. For reference, I used a Github repository provided with the dataset, which I linked at the bottom.</p><p><strong>Let’s dive in!</strong></p><h3>Code-Along</h3><p>In this section, we’ll walk through the preprocessing of EEG data using a robust pipeline. You’ll find code snippets, explanations, and insights for each step to deepen your understanding of EEG preprocessing.</p><h4>1. Setting Up the Environment</h4><p>We start by importing the required libraries:</p><pre>import numpy as np<br>import os.path as op<br>from pprint import pformat<br><br># EEG utilities<br>import mne<br>from mne.preprocessing import ICA, create_eog_epochs<br>from pyprep.prep_pipeline import PrepPipeline<br>from autoreject import get_rejection_threshold<br><br># BIDS utilities<br>from mne_bids import BIDSPath, read_raw_bids<br>from util.io.bids import DataSink<br>from bids import BIDSLayout</pre><ul><li><strong>MNE</strong>: Handles EEG/MEG data processing, including loading, filtering, and plotting.</li><li><strong>PyPrep</strong>: Automates preprocessing tasks like filtering and bad channel detection.</li><li><strong>Autoreject</strong>: Optimizes rejection thresholds for noisy epochs.</li><li><strong>MNE-BIDS</strong>: Works with BIDS (Brain Imaging Data Structure) format to manage datasets.</li><li><strong>NumPy</strong>: Provides numerical operations for manipulating arrays.</li></ul><h4>2. Initial Configuration</h4><p>We define constants and load our dataset:</p><pre>BIDS_ROOT = &#39;path to your BIDS dataset&#39;<br>DERIV_ROOT = op.join(BIDS_ROOT, &#39;derivatives&#39;)<br>HIGHPASS = .3 # low cutoff for filter<br>LOWPASS = 50. # high cutoff for filter</pre><ul><li><strong>Highpass </strong>and <strong>lowpass filters</strong>: These remove unwanted frequencies, such as slow drifts (below 0.3 Hz) and high-frequency noise (above 50 Hz).</li><li><strong>BIDS</strong>: A standardized format for organizing and sharing neuroimaging data.</li><li><strong>Derivatives: </strong>Processed forms of the raw data, such as preprocessed EEG signals, cleaned epochs, event-related potentials (ERPs), or results from statistical analysis. This data is the outcome of preprocessing hence this is what goes into the model.</li></ul><h4>3. Exploring the Dataset</h4><p>We use <strong>BIDSLayout</strong> to explore the dataset and fetch subject information:</p><pre>layout = BIDSLayout(BIDS_ROOT, derivatives=True)<br>subjects = layout.get_subjects()<br>subjects.sort()<br><br>already_done = layout.get_subjects(scope=&#39;preprocessing&#39;)<br><br>for i, sub in enumerate(subjects):<br><br>    if sub in already_done:<br>        continue<br><br>    np.random.seed(i)</pre><p>This ensures that we process only subjects that haven’t been preprocessed yet.</p><h4>4. Reading and Preprocessing Data</h4><p>For each subject, we load raw EEG data, apply filtering, and prepare it for further steps:</p><pre>bids_path = BIDSPath(root=BIDS_ROOT, subject=sub, task=&#39;kickstarter&#39;, datatype=&#39;eeg&#39;)<br>raw = read_raw_bids(bids_path, verbose=False)<br>events, _ = mne.events_from_annotations(raw)<br>raw.load_data()</pre><ul><li><strong>Events</strong>: Markers within EEG data (e.g., stimulus presentations or responses).</li><li><strong>Annotations</strong>: Metadata associated with EEG recordings.</li></ul><h4>5. Running the PREP Pipeline</h4><p>The <strong>PyPrep</strong> pipeline performs:</p><ol><li><strong>Rereferencing</strong>: Adjusting EEG signals relative to a reference.</li><li><strong>Bad channel detection</strong>: Identifying noisy electrodes.</li><li><strong>Notch filtering</strong>: Removing line noise (e.g., from electrical grids).</li></ol><pre>prep_params = {&quot;ref_chs&quot;: &quot;eeg&quot;, &quot;reref_chs&quot;: &quot;eeg&quot;, &quot;line_freqs&quot;: [raw.info[&#39;line_freq&#39;]]}<br>prep = PrepPipeline(raw, prep_params, raw.get_montage(), ransac=False, random_state=i)<br>prep.fit()<br>raw = prep.raw<br><br>if sub == &#39;109&#39;: # get channel we know prep misses for some reason<br>        raw.info[&#39;bads&#39;] = [&#39;E44&#39;]<br>    else:<br>        raw.info[&#39;bads&#39;] = []<br>    bads = prep.noisy_channels_original<br>    bads[&#39;bad_after_PREP&#39;] = raw.info[&#39;bads&#39;] + prep.still_noisy_channels<br>    del prep # save memory</pre><h4>6. Interpolating Noisy Channels</h4><p>We interpolate bad channels to ensure continuity of the EEG signal:</p><pre>raw.interpolate_bads()</pre><p><strong>What is happening?</strong></p><p>Noisy or faulty channels can distort the data analysis. However, we don’t want to drop these channels as it could result in a loss of spatial resolution. Additionally, EEG data is spatially dependent — electrodes close to each other often have correlated signals. Hence, after the PREP pipeline identifies bad channels, these channels are interpolated, meaning their data is reconstructed based on the surrounding electrodes’ information to retain spatial continuity.</p><h4>7. Filtering and Re-referencing</h4><pre>raw.filter(l_freq=HIGHPASS, h_freq=LOWPASS)</pre><p><strong>Bandpass filtering</strong> ensures that only the meaningful EEG components remain, improving the signal-to-noise ratio.</p><pre>def reref(dat):<br>    dat[1, :] = (dat[1, :] - dat[0, :]) * -1<br>    return dat</pre><pre>raw.apply_function(reref, picks = [&#39;E25&#39;, &#39;E126&#39;], channel_wise=False)<br>raw.apply_function(reref, picks = [&#39;E8&#39;, &#39;E127&#39;], channel_wise = False)</pre><p><strong>Re-referencing EOG Channels: </strong>the reref function calculates the difference between two electrodes (e.g., E25 and E126) to isolate EOG activity, then applies this transformation across the dataset. <strong>T</strong>his helps us better capture eye movement (EOG) signals.</p><pre>raw.set_channel_types({&#39;E126&#39;: &#39;eog&#39;, &#39;E127&#39;: &#39;eog&#39;})</pre><p><strong>Setting Channel Types </strong>labels specific electrodes (e.g., E126 and E127) as EOG channels for artifact detection. Properly identifying channel types helps separate EOG artifacts (e.g., eye blinks) from brain activity during later preprocessing steps like ICA.</p><h4>8. Segmenting and Downsampling</h4><p>We split continuous data into <strong>epochs</strong> (time-locked segments) and reduce its sampling rate:</p><pre>epochs = mne.Epochs(raw, events, tmin=-0.2, tmax=0.8, baseline=None)<br>epochs.load_data()<br>del raw # free memory<br>epochs.resample(sfreq=2 * LOWPASS)</pre><p><strong>tmin=-0.2 and </strong><strong>tmax=0.8 seconds</strong>: the time window for each epoch, starting 200 ms before the event marker and ending 800 ms after. This window captures pre-event and post-event brain activity.</p><p><strong>sfreq=2 * LOWPASS (100 Hz)</strong>: reducing the sampling rate to twice the LOWPASS value (due to Nyquist theorem). This preserves all relevant frequencies while reducing data size.</p><h4>9. Artifact Removal with ICA</h4><p>We use <strong>Independent Component Analysis (ICA)</strong> to remove artifacts like eye blinks:</p><pre>ica = ICA(n_components=15, random_state=0)<br>ica.fit(epochs, picks=&#39;eeg&#39;)<br>eog_indices, eog_scores = ica.find_bads_eog(epochs, threshold=1.96)<br>ica.exclude = eog_indices<br>ica.apply(epochs)<br><br># apply baseline correction *AFTER* ICA<br>epochs.apply_baseline((-.2, 0.))<br># and remove EOG channels now that we&#39;re done with them<br>epochs.drop_channels([&#39;E126&#39;, &#39;E127&#39;])</pre><p><strong>n_components=15</strong>: the number of independent components to decompose the EEG signal. Fewer components simplify the model while retaining sufficient variance.</p><p><strong>threshold=1.96</strong>: statistical z-score threshold used to identify components strongly correlated with EOG signals (eye artifacts).</p><h4>10. Rejecting Bad Epochs</h4><p>Using <strong>Autoreject</strong>, we exclude epochs with excessive noise:</p><pre>thres = get_rejection_threshold(epochs)<br>epochs.drop_bad(reject=thres)<br>fig_erp = epochs.average().plot(spatial_colors = True, show = False)</pre><p><strong>thres</strong>: The rejection threshold for noisy epochs, automatically calculated using cross-validation. For example, an epoch might be rejected if the signal exceeds a predefined amplitude limit, such as <strong>100 μV</strong>.</p><h4>11. Saving the Cleaned Data</h4><p>Finally, we save the cleaned data in BIDS format and generate reports:</p><pre>sink = DataSink(DERIV_ROOT, &#39;preprocessing&#39;)<br>fpath = sink.get_path(subject=sub, task=&#39;kickstarter&#39;, desc=&#39;clean&#39;, suffix=&#39;epo&#39;, extension=&#39;fif.gz&#39;)<br>epochs.save(fpath)</pre><pre>report = mne.Report(verbose = True)<br>report.parse_folder(op.dirname(fpath), pattern = &#39;*epo.fif.gz&#39;,<br>                            render_bem = False)<br>report.add_figs_to_section(<br>        fig_erp,<br>        captions = &#39;Average Evoked Response&#39;,<br>        section = &#39;evoked&#39;<br>        )<br>if ica.exclude:<br>        fig_ica = ica.plot_components(ica.exclude, show = False)<br>        report.add_figs_to_section(<br>            fig_ica,<br>            captions = &#39;Removed ICA Components&#39;,<br>            section = &#39;ICA&#39;<br>            )<br>html_lines = []<br>for line in pformat(bads).splitlines():<br>        html_lines.append(&#39;&lt;br/&gt;%s&#39; % line)<br>html = &#39;\n&#39;.join(html_lines)<br>report.add_htmls_to_section(html, captions = &#39;Interpolated Channels&#39;,<br>                            section = &#39;channels&#39;)<br>crit = &#39;&lt;br/&gt;threshold: {:0.2f} microvolts&lt;/br&gt;&#39;.format(thres[&#39;eeg&#39;] * 1e6)<br>report.add_htmls_to_section(crit, captions = &#39;Trial Rejection Criteria&#39;,<br>                            section = &#39;rejection&#39;)<br>report.add_htmls_to_section(epochs.info._repr_html_(),<br>                            captions = &#39;Info&#39;,<br>                            section = &#39;info&#39;)<br>report.save(op.join(sink.deriv_root, &#39;sub-%s.html&#39;%sub), overwrite = True)</pre><p>And with that, we’re done with preprocessing! Files with derivatives will go into the derivative folder in your repository once you run the code.</p><p>Now, we need to group the derivatives together and convert them into a format that we can effectively utilize for machine learning purposes.</p><h3>Converting the Processed Data to CSV</h3><p>Once the EEG data has been preprocessed, it needs to be exported in a format that machine learning frameworks can easily use. One common format is CSV, which is compatible with most ML libraries and pipelines. Below, we demonstrate how to convert processed EEG epochs data into a structured CSV file for downstream machine learning applications.</p><h4>Code Overview:</h4><pre>import mne<br>import os<br>import pandas as pd</pre><pre># Path to your files<br>input_folder = &#39;path to the folder with preprocessed files&#39;<br>output_folder = &#39;path to a new folder for converted files&#39;</pre><pre># Process each file<br>for file in os.listdir(input_folder):<br>    if file.endswith(&#39;_epo.fif&#39;):  </pre><pre># Make sure we&#39;re dealing with epochs data<br>        print(f&quot;Processing {file}...&quot;)<br>        file_path = os.path.join(input_folder, file)<br>        <br>        # Read the epochs data<br>        epochs = mne.read_epochs(file_path)</pre><pre>        # Check the shape of the data<br>        print(f&quot;Data shape: {epochs.get_data().shape}&quot;)<br>        <br>        # Convert the epochs data to a 2D array suitable for a    DataFrame<br>        data = epochs.get_data()  # (n_epochs, n_channels, n_times)<br>        reshaped_data = data.reshape(-1, data.shape[-1]).T           # Flatten epochs to save each channel&#39;s data<br>        <br>        # Convert to DataFrame<br>        df = pd.DataFrame(reshaped_data)</pre><pre>        # Save to CSV<br>        output_file = os.path.join(output_folder, &#39;combined_data.csv&#39;)<br>        df.to_csv(output_file, index=False)</pre><pre>        print(f&quot;Data saved to {output_file}&quot;)</pre><p><strong>Epochs File Filtering</strong>:</p><p><strong>file.endswith(&#39;_epo.fif&#39;)</strong>: ensures that only epochs files (e.g., trial-based data) are processed, avoiding unnecessary computation on irrelevant files.</p><p><strong>Loading Epochs</strong>:</p><p><strong>mne.read_epochs(file_path)</strong>: reads the epochs data into a Python object, allowing access to its shape and underlying array structure.</p><p><strong>Data Reshaping</strong>:</p><ul><li><strong>Shape</strong>: epochs data has a structure of (n_epochs, n_channels, n_times).</li><li><strong>Flattening</strong>: The data is reshaped into a 2D array, with each row representing a single time point across all channels.</li></ul><p><strong>Converting to DataFrame</strong>:</p><ul><li><strong>pd.DataFrame(reshaped_data)</strong>: Converts the reshaped array into a DataFrame for easier manipulation and storage.</li><li>Each column corresponds to a channel, and each row represents a single time point.</li></ul><p><strong>Saving to CSV:</strong></p><p>The reshaped DataFrame is saved as a .csv file in the specified output folder.</p><p>CSV format is lightweight, readable, and widely supported by ML libraries. Flattening epochs ensures that all time-series data is represented in a tabular structure, making it easy to feed into models like RNNs or CNNs for sequential analysis.</p><p>This final step bridges the preprocessing pipeline with the machine learning stage, ensuring compatibility and ease of use for predictive modeling. Now you can use this converted file to train your ML models!</p><h4>Debugging tips:</h4><ul><li><strong>File Path Errors:</strong> Ensure correct use of \ or / based on your OS.</li><li><strong>Missing Metadata:</strong> Check dataset completeness.</li><li><strong>Library Conflicts:</strong> Ensure compatible versions of MNE, PyPrep, and Autoreject.</li><li>You can find additional folders you need (i.e., util) in the repository mentioned below in the “Credits” section.</li><li>If you have any questions, feel free to comment on this article and I’ll do my best to help!</li></ul><h4>Happy preprocessing!</h4><h4>Credits:</h4><p><a href="https://github.com/john-veillette/eeg-neuroforecasting/tree/main">https://github.com/john-veillette/eeg-neuroforecasting/tree/main</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4592dddf0f59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Neuralink Can’t Do (Yet?)]]></title>
            <link>https://medium.com/@kalandarovaaminakhon/what-neuralink-cant-do-yet-e48ef5ceb57c?source=rss-9d7d869d1b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/e48ef5ceb57c</guid>
            <category><![CDATA[neurotechnology]]></category>
            <category><![CDATA[neuralink]]></category>
            <category><![CDATA[blindness]]></category>
            <category><![CDATA[brain-computer-interface]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Amina Kalandarova]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 03:13:30 GMT</pubDate>
            <atom:updated>2024-11-21T03:13:30.017Z</atom:updated>
            <content:encoded><![CDATA[<h3>Restoring High-Quality Vision with Brain-Computer Interfaces: Challenges and Opportunities</h3><p>In the past few months, we’ve heard a lot of discussion around Neuralink and its Blindsight project aimed at restoring vision for people affected by blindness using BCIs.</p><p>But what does Neuralink really have to offer?</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/elonmusk/status/1836120537883644049&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/4775b53c7f932817dfec2a132357ed01/href">https://medium.com/media/4775b53c7f932817dfec2a132357ed01/href</a></iframe><p>Although Neuralink is creating breakthrough interfaces, the quality of the vision it provides is being questioned.</p><blockquote>“I’m leery about the fact that they are very superficial in their description of the devices, …There’s no clear evaluation or pre-clinical work that has been published, …It’s all based on: ‘Trust us, we’re Neuralink.’”</blockquote><p>— said Gislin Dagnelie, a vision scientist at Johns Hopkins University who has been involved in multiple clinical trials for vision prosthetics.</p><p>Realistically, if you were to get any BCI vision implant right now, you would see in phosphenes. To gain a better understanding of what that means, rub your eyes — you will see bursts of light, or phosphenes, randomly firing in your visual field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*JZZbbHGq-Wm9NMHTmdiwCg.png" /><figcaption>an interpretation of seeing phosphenes</figcaption></figure><p>Evidently, this is not enough for, or nearly comparable to, the vision humans need for everyday life.</p><p>Despite advances, current visual BCIs are limited, offering only rudimentary vision. However, ongoing innovations could enhance these systems significantly. While current BCIs cannot yet offer high-resolution, full-color vision, the advancements being made show promise for future breakthroughs that could meaningfully improve life for individuals with vision loss.</p><p><strong>In this article, we will review the gaps in current cortical implants for vision restoration to understand the challenges holding us back from replicating high-resolution vision.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*jQu8dxIrgKYJTki2SVGr8g.jpeg" /><figcaption>progression of vision quality</figcaption></figure><p>First, let’s recall how cortical BCI implants for vision restoration work…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hQfzWf1-BPKlO6J62dBwQ.jpeg" /><figcaption>brain activity: signals passing between neurons</figcaption></figure><p>When light enters a healthy eye, it is received by photoreceptors on our retina (the back part of the eye) and is converted into electrical signals. These signals travel through the optical nerve to the visual cortex and further parts of our brain. At each visual area the signals travel to, they are mapped out according to our visual field, but with alterations. For example, if we record the activity on our primary visual cortex when it perceives an image, you will see that it represents the same image, but distorted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*05wdAAb7ZJR2iwm5PCqJUQ.jpeg" /></figure><p><strong>Retinotopic maps</strong> are used to visualize the spatial arrangement in the primary visual cortex where each neuron represents a specific small region of the visual field, forming a spatial map of the opposite half of the field of view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*cPr74xnKkzHLTLzIUBH-8Q.jpeg" /><figcaption>retinotopic maps</figcaption></figure><p>Cortical brain-computer interfaces for vision restoration work by stimulating the visual cortex of our brain— using implanted electrodes. These electrodes generate electrical pulses that mimic the natural signals produced by healthy photoreceptors in response to light entering the eye. The brain interprets these artificial signals as visual information, allowing the user to perceive basic shapes, light, or movement. BCIs essentially ‘hack’ the visual system by bypassing damaged areas and reintroducing visual signals directly into the brain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HAPJDwh6JFllAPF-UDbp4Q.jpeg" /></figure><p>While we have found out how to replicate signals, there are a few significant aspects that we still have to figure out:</p><ol><li><strong>Low Resolution and Limited Field of View</strong>: the images generated are highly pixelated, often equivalent to seeing a handful of light points rather than a clear picture.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*dDAGrM3gG7nZYlIbV4wgAw.jpeg" /><figcaption>v<a href="https://www.sciencedirect.com/science/article/pii/S0042698909000467">isual models of phosphenes</a></figcaption></figure><p><strong>2. Lack of Color Perception:</strong> Current BCIs struggle with color encoding, restricting the visual experience to shades of gray.</p><p><strong>3. Limited Depth Perception and Object Recognition:</strong> Without depth and object recognition, navigating real-world environments can be challenging for users.</p><p><strong>4. High Cognitive Load:</strong> These systems require significant mental effort to interpret the limited visual information, leading to fatigue and potential cognitive strain.</p><p>So what are the challenges we face that restrict us from replicating high-quality vision? There are several issues, mostly under two categories: <em>technical</em> and <em>biological</em>.</p><h3>Technical Challenges</h3><ol><li><strong>Electrode Density and Biocompatibility:</strong> Higher electrode density improves image resolution, but more electrodes increase complexity and can cause inflammation, impacting long-term function.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ilRxHrFRvSKg6BCuSe6AeQ.jpeg" /><figcaption><a href="https://pubs.acs.org/doi/10.1021/acschemneuro.7b00403">Inflammatory Tissue Reaction to Brain Implants</a></figcaption></figure><p>2. <strong>Signal Processing and Decoding Algorithms:</strong> Decoding visual data into patterns that can be interpreted by the brain is difficult. Advanced algorithms are needed to process these signals accurately and quickly.</p><p>3. <strong>Power Consumption and Wireless Transmission:</strong> Powering BCIs wirelessly without bulky equipment is critical for user mobility but remains technically difficult, especially considering the need for more electrodes and computation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DaiDN2_1ugeFijeJnrdGKg.jpeg" /><figcaption>inductive charging</figcaption></figure><p>4. <strong>Long-term Stability and Durability:</strong> Implants must withstand the body’s natural immune response, which can degrade device effectiveness over time.</p><h3>Biological Challenges</h3><ol><li><strong>Understanding Visual Cortex Organization and Plasticity</strong>: Visual areas of our brain are extremely complex and not yet fully understood which makes it hard to replicate our visual system artificially. Furthermore, variability in how visual areas of the brain are organized across individuals makes it challenging to design BCIs that work universally.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NdntmK0BNbg_n6NJRbaB0g.jpeg" /><figcaption>human brain connectivity</figcaption></figure><p><strong>2. Interfacing with Different Levels of the Visual System</strong>: Stimulating different levels of the visual pathway requires precise, tailored approaches to avoid sensory mismatches. This also relates to the challenge of reaching the right parts of the brain as the areas of the brain responsible for essential aspects of vision such as depth perception and object recognition are located deeper in the brain and are hard to reach.</p><ul><li>This is <em>also a technical challenge</em>, as we have to position electrodes precisely enough to stimulate the particular neurons we need. This poses yet another challenge: making sure the electrodes stay in place, as any movement can cause misplacement of stimulation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*zetGgz2km63WMUTPdokd2g.png" /><figcaption>The Visual System</figcaption></figure><p>As the biological challenges are more research-intensive and data-oriented, today we are going to focus on technical obstacles. Among them, <strong>improving signal processing and decoding algorithms </strong>stands out most.</p><h3>Improving Processing and Decoding Algorithms</h3><p>Developing better algorithms for cortical BCI implants could be considered <strong>the most critical challenge</strong> in visual BCIs because these aspects are responsible for translating raw data from our visual field into a format the brain can interpret as meaningful vision, which is the essence of the application of BCIs as a way of vision restoration.</p><p>Vision isn’t just a matter of light and dark — it involves layers of detail like<strong> depth, color, motion, and object recognition</strong>. To restore vision that feels natural, BCIs must process this complex information and break it down into signals that mimic the way a healthy eye would send data to the brain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xv63058df8HhtBa_aG4h2g.jpeg" /><figcaption><a href="https://www.youtube.com/watch?v=14FJU1kP6-M">Visual Encodings</a></figcaption></figure><p>Additionally, <strong>our brains don’t interpret each pixel individually;</strong> they recognize patterns, faces, and objects almost instantly. Decoding algorithms need to adapt and simplify vast amounts of raw data into patterns that mimic this high-level interpretation.</p><p><strong>Lastly, every individual’s brain structure is unique</strong>, which affects how visual information is processed. Algorithms that can learn from and adjust to each user’s specific brain responses would make the BCI’s output more effective, but this requires<em> advanced, flexible</em> decoding approaches.</p><p>The multi-layer nature of our vision, its pattern recognition, and variability of brain structure among individuals must be considered when improving processing and decoding algorithms.</p><h3>Decoding Algorithms: Status Quo</h3><p><strong>Traditional Machine Learning: </strong>Support Vector Machines (SVM), Linear Discriminant Analysis (LDA), and Random Forests are often used in many BCIs.</p><p><strong>Deep Learning: </strong>Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs) are increasingly being applied to BCI decoding tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LC-M4HMKKQnGEn6FbZMBWw.jpeg" /><figcaption><a href="https://towardsdatascience.com/a-comprehensive-guide-to-convolutional-neural-networks-the-eli5-way-3bd2b1164a53">Convolutional Neural Network</a></figcaption></figure><h3>Processing and Decoding Algorithms: Future</h3><p>What technologies are scientists and engineers working on to improve the algorithms? Here are some technologies that the BCI field seems to be moving towards:</p><p><strong>Hybrid BCIs:</strong> Combining multiple brain signals and modalities for improved performance.</p><p><strong>Personalized Models: </strong>Developing subject-specific decoders to address inter-individual differences[3].</p><p><strong>Unsupervised and Self-Supervised Learning:</strong> Reducing the need for labeled training data[1].</p><p><strong>Integration with Computer Vision: </strong>Leveraging advancements in computer vision to enhance BCI visual decoding capabilities[1].</p><p><strong>Improved Temporal Resolution: </strong>Developing algorithms that can better utilize the high temporal resolution of EEG for real-time applications[4].</p><p>Recent innovations in decoding algorithms for visual BCIs show promising advancements that could significantly improve the quality of vision offered by BCI implants. Here are some <strong>key innovations</strong> and their <strong>potential impact:</strong></p><h4><strong>Adaptive Thinking Mapper (ATM)</strong></h4><p>A novel EEG encoder that can be used in a plug-and-play manner to extract representations in real-time for both EEG and MEG data[2]. This innovation has several potential benefits for visual BCIs:</p><p><strong>Improved Signal Processing:</strong> ATM’s ability to handle different types of neural signals could lead to more robust and versatile visual decoding.</p><p><strong>Real-time Capabilities:</strong> The real-time processing feature of ATM could enable more responsive and dynamic visual feedback in BCI implants.</p><p><strong>Cross-modal Adaptability: </strong>Its ability to work with both EEG and MEG suggests it might be adaptable to various types of neural interfaces, including invasive BCIs.</p><h4><strong>Two-Stage Image Generation</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vq8TroacqwcAYkZpO32jlQ.jpeg" /><figcaption>an application of <a href="https://www.aimodels.fyi/papers/arxiv/giving-hand-to-diffusion-models-two-stage">Two-Stage</a> Image Generation in art</figcaption></figure><p>This approach first transforms EEG features into image priors and then reconstructs visual stimuli using a pre-trained image generator[2][3]. This innovation could improve visual BCIs in several ways:</p><p><strong>Enhanced Visual Reconstruction: </strong>By using a two-stage process, this method could potentially produce more detailed and accurate visual reconstructions.</p><p><strong>Improved Generalization:</strong> The use of pre-trained image generators might allow the system to reconstruct a wider range of visual stimuli, even those not seen during training.</p><p><strong>Faster Processing: </strong>Separating the process into two stages might allow for more efficient computation, potentially leading to faster visual feedback.</p><h4><strong>Contrastive Learning</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3gdqLFHLfh6HXln0MXzPCw.png" /><figcaption><a href="https://medium.com/@abdullahsamilguser/clip-contrastive-language-image-pretraining-83b8913cb7eb">CLIP: Contrastive Language-Image Pretraining</a></figcaption></figure><p>Adapting techniques like CLIP (Contrastive Language-Image Pre-training) for BCI applications could improve image embedding and alignment with neural signals[1][2]. This could benefit visual BCIs through:</p><p><strong>Better Feature Extraction:</strong> Improved alignment between neural signals and visual features could lead to more accurate decoding of visual information.</p><p><strong>Reduced Training Requirements:</strong> Contrastive learning techniques might reduce the amount of subject-specific training data needed, making BCIs more practical for widespread use.</p><p><strong>Improved Generalization:</strong> These techniques could help BCIs better interpret novel visual stimuli, expanding the range of visual experiences they can provide.</p><h4>Transfer Learning and Personalized Models</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*WYhySvigCTzeteglSXsyHw.jpeg" /><figcaption><a href="https://encord.com/blog/transfer-learning/">Transfer Learning</a></figcaption></figure><p>This technique is being explored to reduce the amount of training data needed and to address inter-subject variability. The exploration of transfer learning techniques and the development of subject-specific models[1] could significantly enhance visual BCIs by:</p><p><strong>Reduced Calibration Time:</strong> Transfer learning could shorten the initial setup time for individual users, making BCIs more practical for daily use.</p><p><strong>Improved Accuracy:</strong> Personalized models could better account for individual differences in brain structure and function, leading to more accurate visual decoding.</p><p><strong>Adaptive Performance: </strong>These techniques could allow BCIs to continuously improve their performance for individual users over time.</p><h4>Predictive Decoding Algorithms Using Generative AI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*q25E33cBNA9E9nyhQhCRdA.png" /></figure><p>Another AI-heavy idea is to apply<strong> generative AI </strong>models like the ones used in image generation to predict and “fill in” missing visual details based on limited inputs. Generative AI could be used to reconstruct high-quality images from partial or low-resolution data, using predictive algorithms to provide enhanced detail. For example, if only basic shape information is available, the AI could “imagine” a likely detailed scene based on patterns in similar situations. This technique could deliver more detailed and contextually accurate visual experiences, significantly improving the quality of artificial sight even when the input data is sparse.</p><p>These innovations collectively have the potential to significantly enhance the quality of vision offered by BCI implants. They could lead to higher resolution visual reconstructions, more accurate interpretation of complex visual scenes, faster processing times, and more personalized experiences.</p><p>…so what’s the plan?</p><h3>Next Steps for Developing Decoding Algorithms and Signal Processing for High-Quality Vision</h3><p>Step 1: <strong>Expand Neuroscientific Understanding of Visual Processing</strong></p><p>To map how the brain processes different aspects of vision (color, depth, motion, etc.), we need to conduct detailed studies using advanced imaging techniques (e.g., fMRI, electrophysiology) to understand neural responses to visual stimuli. This foundational knowledge will guide how we design algorithms to replicate natural visual processing.</p><p>Step 2: <strong>Create Large Datasets of Visual-Neural Response Data</strong></p><p>To build comprehensive datasets capturing how neural circuits respond to visual inputs, we can use both human and animal models to collect visual stimulus data alongside corresponding brain responses. These datasets will provide the training material needed for machine learning algorithms to “learn” how to translate visual information into neural signals effectively.</p><p>Step 3: <strong>Develop and Train Machine Learning Models on Visual-Neural Data</strong></p><p>Next, we would need to use <strong>AI</strong> and <strong>deep learning</strong> to recognize patterns and structures in visual data that correspond to brain responses. For that, we have to train models on large datasets to decode complex visual information, such as faces, objects, and movement, into neural patterns. We can do that by utilizing techniques like <strong>supervised learning</strong> to associate visual stimuli with specific neural activation patterns. These trained models will enable more sophisticated decoding, moving from basic light patterns to meaningful visual experiences.</p><p>Step 4: <strong>Implement Real-Time, Adaptive Algorithms</strong></p><p>This step involves making decoding algorithms adaptable and responsive to individual brain differences. It requires developing algorithms that adjust in real time based on each user’s unique neural responses. Utilizing <strong>reinforcement learning</strong> will allow algorithms to improve with continued user feedback. This personalization will make BCIs more intuitive and reduce the cognitive load, allowing users to interpret visual information more naturally.</p><p>Step 5: <strong>Enhance Hardware to Support Faster Processing and Higher Resolution</strong><br>Then, we’ll need to integrate more efficient and powerful processing units within the BCI system to handle high data loads. This will involve designing low-latency processing chips optimized for neural signal decoding and implementing parallel processing architectures to handle complex visual information in real-time. Improved hardware will reduce lag and support more detailed image transmission, allowing for a clearer, more stable visual experience.</p><p>These are the steps that the industry is predicted to take to move Brain-Computer Interfaces towards higher-quality vision restoration, making artificial sight more effective and practical for daily life.</p><p>The plan above did not go too far from what companies like Neuralink are implementing right now. Here are some <strong>cutting-edge, innovative ideas</strong> that go far beyond current approaches:</p><h4>Closed-Loop, Multisensory BCIs with AI-Driven Contextual Awareness</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*eplcxmWwLgsmO3wfmsyUZQ.png" /><figcaption><a href="https://www.frontiersin.org/journals/human-neuroscience/articles/10.3389/fnhum.2023.1085173/full">Closed-loop brain stimulation systems for improving the quality of life</a></figcaption></figure><p>This implies integrating a closed-loop system where visual BCI algorithms are combined with inputs from other senses, such as <em>auditory, haptic, and spatial data</em>, to provide context and improve interpretation. The BCI would not only process visual data but also predict what the user <em>should </em>be seeing based on other sensory information and the immediate environment, using <strong>context-aware AI</strong>. For instance, if a user hears footsteps, the system can anticipate and highlight the visual of a moving person. By combining sensory inputs with AI-based context prediction, BCIs could provide a richer, more immersive experience that helps the brain “fill in the gaps” for a fuller visual interpretation.</p><h4>On-Chip AI Processing for Real-Time Image Reconstruction</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zl74JIQqphcncOsJevOjFA.jpeg" /><figcaption><a href="https://builtin.com/articles/ai-chip">AI Chips</a></figcaption></figure><p>Another thing we could do is implementing <strong>on-chip AI processing</strong> right at the implant site for <strong>near-instantaneous image reconstruction</strong>. Instead of sending raw data to an external processor, the implant would perform real-time, high-level decoding and reconstruction of visual scenes directly on the chip. This would allow more complex computations (like high-resolution image decoding) to happen right at the source, reducing latency and power demands. This approach could allow for detailed, real-time images that feel more like natural vision, significantly enhancing the quality of artificial sight for users.</p><h4>Neural Networks That Mimic Brain’s Visual Hierarchy</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*c4gHKaxcF_LkGDRP5Lzjsw.jpeg" /><figcaption><a href="https://gracewlindsay.com/2018/05/17/deep-convolutional-neural-networks-as-models-of-the-visual-system-qa/">Deep Convolutional Neural Networks as Models of the Visual System</a></figcaption></figure><p>A more advanced idea would be to create a <strong>neural network architecture </strong>that mirrors the hierarchical processing seen in the brain’s visual cortex, from basic edge detection to high-level object recognition. By modeling neural networks to follow the brain’s visual hierarchy, BCIs can decode visual information in a way that feels more natural to the user, processing simple elements first and then building up to complex scenes. This hierarchy could lead to a smoother, more naturalistic vision, where users experience refined details and object recognition without cognitive strain.</p><p>However, this idea requires loads of research on the organization and functioning of our brain as well as structuring this data and retrieving actionable information, which makes it a particularly challenging idea to undertake.</p><h4><strong>Optogenetic Stimulation for Precise Visual Information</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*9WZQz1vzBs7SAGHHMR8RxQ.jpeg" /><figcaption><a href="https://kids.frontiersin.org/articles/10.3389/frym.2017.00051">Optogenetics</a></figcaption></figure><p><strong>Optogenetics </strong>could be used to stimulate individual neurons in the visual cortex with precise patterns of light, allowing for finely tuned visual representation. Optogenetics offer a level of precision that electrode-based systems struggle with. By genetically modifying neurons to respond to light, optogenetics could stimulate specific cells with high precision, potentially allowing for high-definition “pixels” and improved control over color and intensity. This could create much more<strong> detailed and color-sensitive visual representations</strong>, bringing BCIs closer to natural vision.</p><h4>Hybrid BCIs with Brain-to-Brain Interfaces</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*xO56XDF7IyzoF7xNEYqiHg.jpeg" /></figure><p>This is one of the most <em>interesting </em>ideas — combining traditional BCI approaches with <strong>brain-to-brain interface</strong> technology to create a shared, “networked” visual experience. In cases where one user’s neural responses to visual stimuli are robust, this data could be transferred to another user in real time. For example, a caregiver or companion with sight could send certain visual information directly to a user’s BCI, enriching their experience in specific contexts like navigating a new environment. This innovation would enable a unique type of sensory support, allowing users to share and gain from others’ visual perspectives, which could be especially valuable in complex environments.</p><h4>High-Bandwidth Wireless Transmission Using Quantum Communication</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBq1hAiWkkIgPWCNEDZrgA.jpeg" /><figcaption><a href="https://www.technologyreview.com/2019/02/14/103409/what-is-quantum-communications/">quantum communication</a></figcaption></figure><p>As an experiment, we could use <strong>quantum communication</strong> for faster and more secure transmission of visual data from external sensors to implants. Quantum technology, though experimental, could offer much higher data rates and eliminate delays associated with traditional wireless communication. If implemented, this could facilitate rapid and detailed image streaming directly to the BCI. Such a high-speed system would support high-resolution, lag-free vision, making BCIs more effective for navigating dynamic, real-world environments.</p><h4>Direct Cortical Mapping via Electrophysiological “Fingerprints”</h4><p>To further personalize the implants, we could develop <strong>individualized cortical maps</strong> that capture each user’s unique brain patterns to tailor decoding algorithms specifically to their neural “fingerprint.” By mapping each person’s cortex in detail, we could create a customized BCI configuration that decodes signals in a way that optimally matches the user’s brain patterns, ensuring <strong>maximum compatibility and efficacy</strong>. This tailored approach could greatly improve the natural feel of artificial vision, making it easier for users to interpret visual data intuitively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*KDiYiIw3P8NHPb40UcXwyQ.jpeg" /><figcaption>Neuroimaging and Electrophysiology meet Invasive Neurostimulation for causal interrogations and modulations of brain states</figcaption></figure><p>Incorporating these strategies would push beyond current BCI limitations, opening up new dimensions for vision restoration and making artificial sight more natural, reliable, and adaptive for users. By tackling these novel challenges, researchers can create transformative advancements in the BCI landscape.</p><h3>…so what’s next?</h3><p>While significant progress has been made in processing and decoding algorithms for visual BCIs, there is still a considerable gap between current capabilities and the goal of high-quality visual reconstruction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pLpCjVpeSHLMBdXcCcetQ.jpeg" /></figure><p>We have yet to find out the real impact these technologies can make on visual BCIs. Of course, high-quality vision will require more than changing algorithms, but improving this aspect will be a huge step towards offering a vision quality that is enough for everyday life and improving the lives of millions. All we have to do now is to continue building and coming up with novel solutions to complex challenges posed by visual BCIs.</p><p>If you want to stay updated about the latest developments in neurotech, follow me here and on LinkedIn. See you there!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k382zf0cGdQnP8KJqWEo0w.jpeg" /></figure><p>Citations &amp; Sources:<br>[1] <a href="https://academic.oup.com/pnasnexus/article/3/4/pgae145/7656016">https://academic.oup.com/pnasnexus/article/3/4/pgae145/7656016</a><br>[2] <a href="https://arxiv.org/html/2403.07721v7">https://arxiv.org/html/2403.07721v7</a><br>[3] <a href="https://arxiv.org/html/2403.07721v1">https://arxiv.org/html/2403.07721v1</a><br>[4] <a href="https://www.tandfonline.com/doi/full/10.1080/2326263X.2023.2287719">https://www.tandfonline.com/doi/full/10.1080/2326263X.2023.2287719</a><br>[5] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC4015971/">https://pmc.ncbi.nlm.nih.gov/articles/PMC4015971/</a><br>[6] <a href="https://arches.union.edu/do/54150/iiif/7c9571ed-aae7-489d-b415-b02f53cbcc2b/full/full/0/2022_AtkinsA.pdf">https://arches.union.edu/do/54150/iiif/7c9571ed-aae7-489d-b415-b02f53cbcc2b/full/full/0/2022_AtkinsA.pdf</a><br>[7] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC8286913/">https://pmc.ncbi.nlm.nih.gov/articles/PMC8286913/</a><br>[8] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7116116/">https://pmc.ncbi.nlm.nih.gov/articles/PMC7116116/</a></p><p>— <br>[1] <a href="https://arxiv.org/html/2403.07721v1">https://arxiv.org/html/2403.07721v1</a><br>[2] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC8286913/">https://pmc.ncbi.nlm.nih.gov/articles/PMC8286913/</a><br>[3] <a href="https://academic.oup.com/pnasnexus/article/3/4/pgae145/7656016">https://academic.oup.com/pnasnexus/article/3/4/pgae145/7656016</a><br>[4] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7116116/">https://pmc.ncbi.nlm.nih.gov/articles/PMC7116116/</a><br>[5] <a href="https://arxiv.org/html/2403.07721v7">https://arxiv.org/html/2403.07721v7</a><br>[6] <a href="https://www.tandfonline.com/doi/full/10.1080/2326263X.2023.2287719">https://www.tandfonline.com/doi/full/10.1080/2326263X.2023.2287719</a><br>[7] <a href="https://arches.union.edu/do/54150/iiif/7c9571ed-aae7-489d-b415-b02f53cbcc2b/full/full/0/2022_AtkinsA.pdf">https://arches.union.edu/do/54150/iiif/7c9571ed-aae7-489d-b415-b02f53cbcc2b/full/full/0/2022_AtkinsA.pdf</a><br>[8] <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7529781/">https://pmc.ncbi.nlm.nih.gov/articles/PMC7529781/</a></p><p>—</p><p><a href="https://spectrum.ieee.org/neuralink-blindsight">https://spectrum.ieee.org/neuralink-blindsight</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e48ef5ceb57c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI for better decision-making: Building a Song Recommendation System]]></title>
            <link>https://medium.com/@kalandarovaaminakhon/ai-for-better-decision-making-building-a-song-recommendation-system-3a93523e8a2f?source=rss-9d7d869d1b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a93523e8a2f</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Amina Kalandarova]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 20:24:06 GMT</pubDate>
            <atom:updated>2024-04-07T20:45:48.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l--yJo2ZRfaTKXEzk5iQXw.jpeg" /><figcaption>the more options there are, the harder it is to choose</figcaption></figure><p>What movie should I watch? What cafe should I eat at? What college do I want to attend? Nowadays, there are so many options to choose from that you can spend hours upon hours just scrolling through them.</p><p>Take for example one of the most common pastimes of humanity — listening to <strong>music</strong>. I want my playlist to match my mood, my music taste, modern trends, and be as long as possible so I can listen nonstop. But handpicking the songs that match these criteria among millions will take hours so instead of doing it myself, I go to streaming services like Spotify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXklaXtjvzq_ZCRfQf64Pw.jpeg" /></figure><p><strong>Spotify </strong>is famous for having the best recommendations that match your taste with incredible preciseness. In fact, Spotify is the most popular streaming platform in the world, with<strong> 350 million users</strong> and <strong>150 million subscribers</strong>. But how does a music streaming platform analyze so much data and make recommendations that actually match users’ tastes? As you might have guessed, to achieve this success in predicting preferences, Spotify uses <strong>artificial intelligence</strong>.</p><p>To be more precise, streaming services use <strong>recommendation systems</strong> that analyze previous decisions of users and characteristics of products using data about their interactions to suggest the options that are most likely to fit the user’s taste.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15EDL8eYErMAjLdu4TvgQQ.png" /><figcaption>ai-generated 👀</figcaption></figure><p>In this article, I am going to walk you through creating a simplified version of a <strong>music recommendation system</strong> that you can use to find ten similar songs to a song you input into the system.</p><h3>A short note from the author:</h3><blockquote>Hey there! My name is Amina and I am a beginner innovator in the spaces of AI and Brain-Computer Interfaces. This is one of my first projects involving AI and I started it without any knowledge of Python so if you are a beginner as well, welcome to the club! If you have experience in the field, I hope you learn something new! Lastly, if you have any questions, feel free to reach out.</blockquote><h3>Types of Recommendation Systems:</h3><p>Recommendation systems are broadly categorized into two types: <strong>collaborative filtering models and content-based models</strong>.</p><ol><li><strong>Content-Based Recommendation Systems</strong>:</li></ol><ul><li>recommend items to users based on the characteristics of the items themselves and the user’s past interactions with items.</li><li>analyze the content of the items (such as text, tags, metadata) and create profiles for users based on their preferences or behavior.</li><li>recommendations are made by finding items that are similar to those the user has liked or interacted with in the past.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KnMslcyIdBxnMwhxXeaX-Q.png" /></figure><p>For example, if a user has liked action movies in the past, a content-based recommendation system might suggest other action movies with similar themes, actors, or directors.</p><p>2.<strong> Collaborative Filtering Recommendation Systems</strong>:</p><ul><li>recommend items to users based on the preferences or behavior of other users.</li><li>do not rely on the content of the items but instead analyze the interactions between users and items.</li><li>Collaborative filtering can be further divided into two sub-types:</li></ul><p><strong>User-based collaborative filtering</strong>: Recommendations are made based on the preferences of users who are similar to the target user. If user A and user B have similar tastes and preferences, items liked by user B but not by user A may be recommended to user A.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOsVgKW-Kxg7W91JvusEfQ.png" /></figure><p><strong>Item-based collaborative filtering</strong>: Recommendations are made based on the similarity between items. If two items have been liked or interacted with by similar users in the past, one item may be recommended to a user who has interacted with the other item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*qjmclb5S98OsoeZfad1tvg.jpeg" /></figure><ul><li>Collaborative filtering techniques often rely on user-item interaction data such as ratings, likes, purchases, or clicks.</li></ul><p>For example, if two users have rated movies similarly, the system might assume they have similar tastes. Therefore, it recommends movies that user 1 has rated highly but user 2 hasn’t seen yet to user 2.</p><p>Often, streaming services use hybrid systems with elements from both types of systems. Today, we will be building a <strong>content-based recommendation system </strong>because it doesn’t require<strong> </strong>data on preferences or behavior of several users.</p><h3>Build Prep</h3><p>Before diving into the building of a recommendation system, let’s make sure we have everything we need:</p><ul><li>an integrated development environment (I used <a href="https://code.visualstudio.com/">Visual Studio Code</a>)</li><li><a href="https://www.python.org/downloads/">Python</a> installed</li><li>dataset (I used <a href="https://www.kaggle.com/datasets/rakkesharv/spotify-top-10000-streamed-songs">this</a> one)</li><li><a href="https://scikit-learn.org/stable/index.html">Scikit-Learn</a> installed (run <strong>pip install scikit-learn</strong> in your terminal)</li><li><a href="https://pandas.pydata.org/">Pandas</a> installed (run <strong>pip install pandas</strong> in your terminal)</li></ul><h3>Let’s Dive In!</h3><p>I used a Kaggle notebook instead of an IDE at first which is great for beginners, but I had to transport the code into Visual Code Studio in the end to try to deploy it so my recommendation is doing it there from the start.</p><p>Start by importing <strong>pandas </strong>— a Python library used for data manipulation and analysis.</p><pre>import pandas as pd</pre><p>Next, import two tools from the Scikit-Learn library: CountVectorizer and Cosine Similarity.</p><pre>from sklearn.feature_extraction.text import CountVectorizer<br>from sklearn.metrics.pairwise import cosine_similarity</pre><p><strong>CountVectorizer</strong> is used for converting a collection of text documents into a matrix of token counts. It is one of the most commonly used techniques for text preprocessing and feature extraction in natural language processing (NLP) tasks.</p><p><strong>Cosine Similarity</strong> computes the cosine similarity between all pairs of vectors in two input matrices. The input matrices are typically feature representations of items, or data points, where each row represents an item and each column represents a feature. The function returns the cosine similarity between the two vectors, which is a value between -1 and 1, where 1 indicates perfect similarity and -1 indicates perfect dissimilarity.</p><p>Now let’s set the dataframe to the csv file we got from Kaggle and read it using pandas.</p><pre>df = pd.read_csv(&quot;PATH TO THE FILE&quot;, low_memory=False) [:10000]</pre><p>I set the system to read the first 10000 lines, but you can regulate this number using [:number] after the parentheses.</p><p>Also, don’t forget to input the <strong>correct path</strong> to your file — it may vary depending on what IDE you are using.</p><p>Use this code to tailor the data frame so it is easier to work with:</p><pre>df = df.drop_duplicates(subset=&quot;Song Name&quot;)<br>df = df.dropna(axis=0)<br>df = df.drop(df.columns[3:], axis=1)<br>df[&quot;Artist Name&quot;]=df[&quot;Artist Name&quot;].str.replace(&quot; &quot;,&quot;&quot;)<br>df[&quot;data&quot;] = df.apply(lambda value: &quot; &quot;.join(value.astype(&quot;str&quot;)), axis=1)</pre><p>This code drops duplicates, blanks, unnecessary columns and spaces. The last line combines all the column values into a single new column value.</p><p>Activate the two features we imported from the Scikit-Learn library (CountVectorizer and Cosine Similarity):</p><pre>vectorizer = CountVectorizer()<br>vectorized = vectorizer.fit_transform(df[&quot;data&quot;])<br>similarities = cosine_similarity(vectorized)</pre><p>Assign the new dataframe with `similarities` values</p><pre>df_tmp=pd.DataFrame(similarities, columns=df[&quot;Song Name&quot;], index=df[&quot;Song Name&quot;]).reset_index()</pre><p><strong>We’re halfway through!</strong></p><p>Now let’s set the input-output system using <strong>while</strong> loops.</p><p>First, we will print the text describing this system and asking for input. Then, we will set it to let the user know if the song they entered is not in the database:</p><pre>true = True<br>while true:<br>        print (&quot;Get your top 10 recommended songs&quot;)<br>        print (&quot;                          &quot;)<br>        print (&quot;This will generate the 10 songs from the database that are similar to the song you entered.&quot;)<br><br>        while True:<br>        input_song = input (&quot;Please enter a name of the song you like: &quot;)<br>        if input_song in df_tmp.columns:<br>        recommendation = df_tmp.nlargest(11, input_song)[&quot;Song Name&quot;]<br>        break<br><br>        else:<br>        print(&quot;Sorry, this song is not in our database. Try another one!&quot;)<br><br>        print(&quot;Check out these songs: \n&quot;)<br>        for song in recommendation.values[1:]:<br>        print(song)<br><br>        print(&quot;\n&quot;)<br>        while True:<br>        next_command = input(&quot;Do you want to generate again for the next song? [yes, no] &quot;)<br><br>        if next_command == &quot;yes&quot;:<br>        break<br>        <br>        elif next_command == &quot;no&quot;:<br>        true = False<br>        break<br><br>        else:<br>        print(&quot;Please type &#39;yes&#39; or &#39;no&#39;&quot;)</pre><p>The code above will use the new dataframe to output a list of ten songs that are most similar to the song entered. After that, it will ask if the user wants to generate a list for another song. The user has two answer options: yes and no. If they answer yes — the system asks for another song, if they answer no — the system stops.</p><p><strong>And we’re done!</strong></p><p>Now you have a recommendation system that you can use whenever you’re feeling indecisive or share it with your friends! More importantly, you now know how to make a <strong>simple recommendation system</strong> and you can use this as a template for other ideas (if you have any — feel free to drop it in the comments!)</p><h3>Here is how it came out:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaHBv61g5kBA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaHBv61g5kBA&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8667d5e67f4f96ca74966dc2bc8255d/href">https://medium.com/media/b8667d5e67f4f96ca74966dc2bc8255d/href</a></iframe><h3>Pro-s</h3><ul><li>the database consists the most popular songs of 2023</li><li>easy to use</li><li>you only input one song, no other information</li><li>the system responds to invalid inputs</li></ul><h3>Con-s</h3><ul><li>song names have to be typed exactly like they are in the database</li><li>the database is limited</li><li>recommendations are not very precise</li><li>it is not deployed/available for everyone to use</li></ul><h3>Challenges</h3><p>As it was my first python project, I faced a few obstacles while building this system, and I’ll share some tips below:</p><ul><li>I didn’t know how to work with libraries like <strong>pandas</strong> or <strong>Scikit-Learn. Solution: </strong>run <strong>pip install (name of library)</strong> in your terminal. Also it’s useful to learn to work with <strong>command prompt </strong>in general and there are lots of great videos on it on YouTube.</li><li>My code wasn’t running outside of Kaggle because python wasn’t added to <strong>PATH</strong>, though it was installed. <strong>Solution:</strong> look where python is stored, copy the path, right-click on the “Start” button and select “System”. Click on “About” then select “System info”, then “Advanced system settings“. In “System Properties” window, go to “Advanced” tab and click on “Environment Variables”. Then, under “System Variables” section find and select the Path variable, then click on “Edit”. Click on “New” and add the path to your Python installation folder (the one you copied earlier). And also add the path to the Scripts folder - where pip is located. Click “OK” and verify again by typing these 2 commands:</li></ul><pre>py --version</pre><pre>pip --version</pre><ul><li>The last challenge I am still working on is <strong>deploying </strong>this system to a webpage. I’ve tried platforms like Streamlit, GitHub Pages, and more, spending hours trying to figure it out, but I didn’t get it to run on a webpage yet. If you have ideas on how it can be done, I’d love to hear them!</li></ul><p>Let me know if you faced similar challenges and feel free to reach out with any questions!</p><p>Also, a HUGE shoutout to <a href="https://medium.com/u/9a7b9f039239">Mark-Daniel Leupold</a> for helping me figure out adding python to PATH. TKS community = best 💪</p><h3>Ways to improve</h3><ul><li>Setting the system to recognize song names without regard to capitalization</li><li>Building a hybrid system: both content and collaborative filtering</li><li>Deploying the system and making it accessible to the public</li><li>Using a bigger database or APIs</li></ul><p>As you can imagine, there is a lot of room for improvement! Still, I hope this article was helpful and you learnt something new.</p><p>I’ll see you in the next one!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3ag_qdZ2Qd4lyg9K" /><figcaption>Photo by <a href="https://unsplash.com/@oskaryil?utm_source=medium&amp;utm_medium=referral">Oskar Yildiz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Credits</h3><ul><li><a href="https://365datascience.com/tutorials/how-to-build-recommendation-system-in-python/">How to Build a Recommendation System in Python? | 365 Data Science</a></li><li><a href="https://medium.com/artificialis/music-recommendation-system-with-scikit-learn-30f4d07c60b3">Building Music Recommendation System</a></li><li><a href="https://www.kaggle.com/datasets/rakkesharv/spotify-top-10000-streamed-songs">Spotify Top 10000 Streamed Songs</a></li><li><a href="https://github.com/AminaKalandarova/Replicate-1/tree/main">GitHub - AminaKalandarova/Replicate-1: Song Recommendation System</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a93523e8a2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Processing in BCIs: interacting with our devices at light speed ⚡]]></title>
            <link>https://medium.com/@kalandarovaaminakhon/processing-in-bcis-interacting-with-our-devices-at-light-speed-842e96c2eca0?source=rss-9d7d869d1b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/842e96c2eca0</guid>
            <category><![CDATA[bci]]></category>
            <category><![CDATA[emerging-technology]]></category>
            <category><![CDATA[processing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computationalneuroscience]]></category>
            <dc:creator><![CDATA[Amina Kalandarova]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 04:30:38 GMT</pubDate>
            <atom:updated>2023-12-09T04:30:38.860Z</atom:updated>
            <content:encoded><![CDATA[<h3>Processing in BCIs: interacting with our devices at light speed</h3><h3>I recently got an idea…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uE63MA8fwxBOPfq2" /></figure><p>Most interaction that we have with our devices is done through clicking. Touchscreen or keyboard: almost any act requires us to click a button.</p><p>What if we wouldn’t have to click on our phones every time we want to take a photo, change a song, turn the power off or on, regulate the sound level, or do any other annoying little click? For the entire existence of computers, we have to physically interact with the trigger to act, but what if there is a way to <strong>revolutionize </strong>our interaction with devices and use our minds to control them?</p><p>To achieve that, we would only have to build a device that would read our brain signals non-invasively, process the gathered data, transfer it to a phone, identify patterns, decode the data into commands, and program the phone to recognize and exercise these commands — easy, right? 😅</p><p>Fortunately, we can use <strong>BCIs or Brain-Computer Interfaces</strong> to do that! We have already seen inventions where BCIs help paralyzed individuals complete everyday tasks on electronic devices, which is absolutely ground-breaking! For example, in <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0204566">research funded by Stanford</a>, three research participants with tetraplegia had multi-electrode arrays implanted in the motor cortex to give them the ability to browse the web, send emails, chat, play music on a piano application, send text messages, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MDJOgcrIj7TChjNF" /></figure><p>This means that scientists have already found a way to do all of these actions with just a power of thought, and while the priority is given to helping people with disabilities, there is a chance that the iPhone 20 will be controlled with your mind.</p><p>While the whole process of creating a phone extension that reads your mind seems complex, some aspects are more familiar to us than one might assume:</p><ul><li>We use EEG to read brain signals to check our health at the doctor’s office</li><li>We transfer data every day from different devices</li><li>Finally, we use code to command our phones to perform actions</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-uG0GFpzoXbz0sXaJfuSA.jpeg" /><figcaption>EEG (left), data transfer (right)</figcaption></figure><p>The most complex, challenging, and, at the same time, the most interesting part lies in <strong>processing</strong> brain signals, <strong>extracting </strong>features, and <strong>decoding </strong>the gathered data into commands. Variability in individual brain activity and the complexity of mapping neural signals to specific commands or actions require sophisticated signal processing and decoding algorithms. However, these processes are essential for brain-computer interfaces, and understanding them will help us understand the working mechanisms of BCIs.</p><p><strong>In this article, we will delve deep into how BCIs process signals, including pre-processing, feature extraction, and classification.</strong></p><h3>Refresher on BCIs:</h3><p><strong>Brain-computer interfaces (BCIs)</strong> are intricate systems designed to establish a direct communication pathway between the brain and an external device, allowing bidirectional information transfer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScIGk7y7Qaj7W49tCLkx_Q.png" /><figcaption>INSIGHT — 5-channel wireless EEG headset from EMOTIV</figcaption></figure><h3>Preprocessing: neural amplifiers explained</h3><p>After a BCI acquires data, we get raw and intricate neural signals. They are noisy, contain various frequencies, and often carry interference. Preprocessing techniques, such as amplification, filtering, and noise reduction, are employed to refine these signals, making them suitable for analysis. <strong>Amplifiers </strong>are used to carry out pre-processing in modern-day BCIs.</p><blockquote>“The EEG amplifier is part of the data acquisition system responsible for accommodating, amplifying, and converting the analog electrical signals from the sensor into a digital signal that can be processed by the computer.” — BitBrain</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ph9EeLB6UUrcDLB4" /><figcaption>an amplifier on the <a href="https://www.bitbrain.com/neurotechnology-products/semi-dry-eeg/versatile-eeg">Versatile EEG</a> cap from BitBrain</figcaption></figure><p>To understand how amplifiers pre-process data we first need to realize that the EEG is an analog signal (continuous in time) and it has to be converted into a digital signal (discrete in time) to be processed by the computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-hnhozFrNBoJiEV2" /></figure><p>For this conversion to happen, the amplifier needs to know the number of times a signal should be measured in one second — the <strong>sampling rate</strong>.</p><p>There are five basic types of brain waves: delta (0.5–4 Hz), theta (4–8 Hz),<a href="https://www.bitbrain.com/blog/alpha-brain-waves"> </a>alpha (8–12 Hz), beta (16–24 Hz), and gamma (up to 80 Hz). The sampling rate has to be <strong>at least twice the maximum frequency</strong> of the signal being measured, therefore, most amplifiers have a sampling rate of 256 Hz so they can capture all mentioned types of waves.</p><blockquote>The higher the sampling rate → the higher the resolution</blockquote><p>Now that the amplifier knows the speed of measurements (sampling rate), it needs the range of frequencies that can pass through a system without significant loss or distortion — the <strong>bandwidth</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UO-zzbhqrWB5_qVN" /><figcaption><strong>- gain </strong>refers to the number of times the input signal is amplified</figcaption></figure><p>Bandwidth depends on the sampling rate and internal filters of the amplifier. There are low-pass and high-pass filters that attenuate low and high frequencies. The bandwidth is the frequency band where the signal amplitude is attenuated less (&lt; 3 decibels (dB)).</p><p>For general research, it is usually desirable to cover all frequencies up to 80Hz, however, the bandwidth selection depends on the range of frequencies you want to use.</p><p>We know the rate of measurements and the range of frequencies. Now, we need to digitize the data or, in other words, convert the analog EEG signal voltage into a digital value so the computer can read it. For this purpose, the amplifier uses an <strong>analog-to-digital converter (ADC)</strong> that gives each voltage value a certain number of bits. This number of bits is the <strong>resolution </strong>of the amplifier. The standard resolution in research EEG amplifiers is at least 24 bits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DWzmXe0990hzHODmfkChBw.png" /><figcaption>Why Do You Need an Analog-to-Digital Converter (ADC)?</figcaption></figure><blockquote>The higher the bit resolution → the more detailed and accurate the digital representation of the analog signal</blockquote><p>The next step is to frame our data or define the levels of voltage the amplifier can accept as input without distortion or damage — the <strong>input range</strong>. We know that the output range (Vcc) is fixed and depends on the power supply. Therefore, the input range is delimited by the output range and the amplifier’s internal gain (the number of times the input signal is amplified):</p><p><strong><em>Vout = G x Vin</em></strong></p><p><strong>Signal saturation</strong> can be thought of as a police officer of brain signals. It enforces the input and output range. In the process of saturation, the physical signal exceeds the input or output range and its excess gets clipped off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N2dmfjByuuz7xkI4" /></figure><p>The input range should be at least 50mV for the amplifier to be able to record all the previously enumerated signals without saturation.</p><p>Arguably the core feature of an amplifier — <strong>CMRR </strong>— is the ability to<strong> </strong>drown out the voltage that is constant for both the positive and the negative inputs of the amplifier (the common-mode voltage or VCM) while amplifying the voltage difference between the positive and the negative inputs (the differential mode voltage or VDM).</p><p>In other words, CMRR lets the amplifier emphasize the gist of the input it gets while fading out the unwanted background. It works similarly to a blurred-background filter on Zoom: highlights what’s important and blurs the rest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*4eHl012C3pJLk1QwR7f34w.jpeg" /></figure><blockquote>Better CMRR → more effective amplifier</blockquote><p>Finally, an amplifier needs to monitor its<strong> input impedance</strong>. It is the constant impedance of the input circuit. There is also<em> electrode impedance</em>, which refers to the impedance between the electrode and skin.</p><p>EEG amplifiers receive high impedance signals, therefore it is important to minimize any attenuation of the already-very-weak signal amplitude. The only way to keep the signal amplitude, without decreasing the electrode impedance, is to have an amplifier with high input impedance.</p><blockquote>Higher input impedance → better response against high electrode impedance</blockquote><p>To monitor the signal quality of every channel, it is important to also take into account <strong>electrode impedance</strong> and track it using an impedance monitor. There are two types of these monitors: the ones that work during set-up only, and the ones that work during set-up and recording.</p><p>The impedance monitor works by injecting an artificial signal that is measured by the EEG electrodes. If the signal is within bandwidth and used during recording, the EEG data can be contaminated. This can become problematic when the impedance monitoring signal is used in low frequencies, as they will become impossible to analyze later on. For this reason, impedance monitoring during the recording must be at higher frequencies than the amplifier’s bandwidth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*gSVp63W_7ETxnGO-2Rj3Rg.png" /><figcaption>- processing stages</figcaption></figure><p>Now that we know what brain signals go through to transform into data that can be read by a computer, let’s see how we extract features from that data.</p><h3>Segmentation</h3><p><strong>Segmentation </strong>is the process of dividing the continuous neural data into smaller, discrete segments or epochs usually lasting several seconds. It is often done to prepare the gathered data for feature extraction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*H1_ahNnegtqcbYURUQltnQ.png" /><figcaption>- segmentation using fixed sliding windows with a length of one second and an overlap of 50% is used to capture the dynamics of the signal that occurs between two windows</figcaption></figure><p>Although there are several specific types of segmentation, the most commonly used one is <strong>Fixed-Length Segmentation.</strong> In this approach, the continuous EEG signal is divided into fixed-length epochs. Each epoch covers a specific time duration. This method is easy to implement compared to others like adaptive or time-frequency segmentation.</p><h3>Feature Extraction</h3><p>The data from brain signals has been amplified and divided into time segments, now we need to learn to distinguish between different patterns of brain signals.</p><p>In BCIs, a <strong>feature</strong> refers to a specific property of the recorded neural signals that are relevant for the intended application, such as classifying brain states or controlling a device.</p><p><strong>Feature extraction</strong> is the process of distinguishing between different features and representing them in a form that a computer can understand. Relevant features are extracted from the preprocessed neural signals. These features capture distinctive patterns associated with different mental states or tasks. Common types of features include time-domain, frequency-domain, spatial, and time-frequency features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Ydz-Pv39DZY-ACfA" /></figure><p>To extract features from all the noise that comes with brain signals, we need to analyze the brain signal energy and make it into a function of time and frequency. There are several methods for analysis, such as frequency analysis (FFT), time-frequency analysis (STFT), and space-time-frequency analysis (STFT).</p><p>For example, the discrete STFT equation is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*5XcavkK-ThcmISsg" /></figure><p>In STFT, the signal is divided into small sequential or overlapping data frames. The output of successive STFTs can provide a time-frequency representation of the signal. The signal is framed into short data frames by multiplying it by a window so that the edified signal is zero outside the data frame. To analyze the whole signal, the window is translated in time and then FT is reapplied to each one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*YY401exNEWae_qRc" /></figure><p>This figure illustrates the process of feature extraction. Signals are recorded, windows are established, graphs are built and that helps to extract features from the input collected.</p><p>Feature extraction is important for processing in BCIs because it takes the high dimensionality of neural signals and picks it apart emphasizing only the features that we choose. For example, if we only want to pay attention to the change in frequency we can use FFT to track it.</p><h3>Classification</h3><p>Finally, we need to interpret the user’s intention or mental state based on the features extracted from neural signals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/0*HZFI1o09SSoaqIpB" /></figure><p><strong>Classification </strong>is a key component in Brain-Computer Interfaces (BCIs) and involves the use of machine learning algorithms to categorize neural activity into different classes or states. The fascinating thing about this step is that it lies at the intersection of artificial intelligence and brain-computer interfaces, combining two of the most promising innovative technologies of our time.</p><p>The features extracted earlier are used as input to a classification algorithm, such as Support Vector Machines (SVM), k-Nearest Neighbors (k-NN), or neural networks. The classifier is trained on labeled data gathered through feature extraction to learn patterns associated with different mental states.</p><p>For instance, Support Vector Machines (SVMs) are popular because they can effectively handle high-dimensional data and are capable of achieving good generalization performance. The features extracted from neural signals define points in a high-dimensional space. Each feature corresponds to a dimension, and each sample in the training dataset is a point in this feature space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Fjj7EblDs2J88GgJmyKL8w.png" /><figcaption>Support Vector Machine Algorithm</figcaption></figure><ol><li>The SVM algorithm aims to find a <strong>hyperplane </strong>that best separates the samples from different classes in the feature space. The hyperplane is the decision boundary that maximizes the margin between the two classes.</li><li><strong>Support vectors</strong> are the data points from the training set that lie closest to the decision boundary (the hyperplane). These are the critical points that influence the positioning and orientation of the hyperplane.</li><li>The <strong>margin </strong>is the distance between the hyperplane and the nearest support vectors. SVM seeks to maximize this margin because a larger margin is associated with better generalization performance on new, unseen data.</li><li>SVMs can use a <strong>kernel function </strong>(a technique that allows you to apply linear models to nonlinear problems)<strong> </strong>to implicitly map the input features into a higher-dimensional space. This allows the SVM to find a nonlinear decision boundary in the original feature space.</li><li>The SVM <strong>training process</strong> involves optimizing the hyperplane parameters to maximize the margin and minimize classification errors on the training data. This is typically done using optimization techniques.</li><li>Once trained, the SVM defines a <strong>decision function</strong>. For a new, unseen sample, the decision function evaluates which side of the hyperplane the sample falls on, and the sample is classified accordingly.</li></ol><h3>What’s then?</h3><p>After this part of the processing is done, the classification output is translated into control signals. These signals can be used to guide the movement of a cursor on a screen, control a robotic device, or perform other tasks.</p><p>If we build a device described in the beginning, we can finally <strong>use the power of thought to communicate with our devices</strong>! Specific brain signals associated with commands on our gadgets will trigger these commands and we will reach a kind of telekinesis that is backed by science. Although the process seems complicated, the good thing is that we already know how it works and can adapt it to supercharge the efficiency of our devices.</p><p>BCIs are the perfect tool for revolutionizing how we interact with technology and making our everyday lives more comfortable!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFtSR9zbNClzzrcHUTJudQ.png" /></figure><h3>Author</h3><p>Amina Kalandarova is a young innovator passionate about computational neuroscience and sustainability. She lives in New York and climbs her way up the marketing industry while doing BCI research in <a href="https://www.tks.world/">The Knowledge Society</a>. Among other interests, Amina loves meeting new people and learning about them and their passions! Reach out to her through one of the methods listed below to schedule a meeting:</p><p><a href="http://www.linkedin.com/in/amina-kalandarova-74a384292">LinkedIn</a></p><p><a href="https://www.instagram.com/mimika_ny/">Instagram</a></p><p><a href="https://twitter.com/Amina_explore">JavaScript is not available.</a></p><h3>Sources:</h3><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//arxiv.org/pdf/2201.04229.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ef41f237a03fa370427cb96dfbf0cb6/href">https://medium.com/media/2ef41f237a03fa370427cb96dfbf0cb6/href</a></iframe><p><a href="https://www.bitbrain.com/blog/eeg-amplifier">Main features of the EEG amplifier explained | Bitbrain</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7ExYVjAROq0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7ExYVjAROq0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7ExYVjAROq0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9562eccdf860e58bb2215b080153d67/href">https://medium.com/media/d9562eccdf860e58bb2215b080153d67/href</a></iframe><ul><li><a href="https://www.technologyreview.com/2022/03/22/1047664/locked-in-patient-bci-communicate-in-sentences/">A locked-in man has been able to communicate in sentences by thought alone</a></li><li><a href="https://www.emotiv.com/">EMOTIV | Advanced Brain Data &amp; Wireless EEG Solutions</a></li></ul><p><a href="https://www.researchgate.net/profile/Toka-A-Fathi/publication/332606126_FEATURES_EXTRACTION_TECHNIQES_OF_EEG_SIGNAL_FOR_BCI_APPLICATIONS_FEATURES_EXTRACTION_TECHNIQES_OF_EEG_SIGNAL_FOR_BCI_APPLICATIONS/links/5cc01e5492851c8d2200a05b/FEATURES-EXTRACTION-TECHNIQES-OF-EEG-SIGNAL-FOR-BCI-APPLICATIONS-FEATURES-EXTRACTION-TECHNIQES-OF-EEG-SIGNAL-FOR-BCI-APPLICATIONS.pdf">https://www.researchgate.net/profile/Toka-A-Fathi/publication/332606126_FEATURES_EXTRACTION_TECHNIQES_OF_EEG_SIGNAL_FOR_BCI_APPLICATIONS_FEATURES_EXTRACTION_TECHNIQES_OF_EEG_SIGNAL_FOR_BCI_APPLICATIONS/links/5cc01e5492851c8d2200a05b/FEATURES-EXTRACTION-TECHNIQES-OF-EEG-SIGNAL-FOR-BCI-APPLICATIONS-FEATURES-EXTRACTION-TECHNIQES-OF-EEG-SIGNAL-FOR-BCI-APPLICATIONS.pdf</a></p><p><a href="https://www.researchgate.net/figure/Segmentation-using-fixed-sliding-windows-with-a-length-of-one-second-and-an-overlap-of_fig5_339468635">https://www.researchgate.net/figure/Segmentation-using-fixed-sliding-windows-with-a-length-of-one-second-and-an-overlap-of_fig5_339468635</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=842e96c2eca0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>