लैब स्ट्रीमिंग लेयर (एलएसएल) कई डेटा स्ट्रीमों को समन्वयित करने के लिए
रोशिनी रंडेनिया
1 अक्तू॰ 2025
साझा करें:


रोशिनी रंदेनिया और लुकास क्लाइन
ऑपरेशन:
जब कमांड लाइन में चलाया जाता है, तो यह स्क्रिप्ट तुरंत एक LSL स्ट्रीम शुरू करता है। जब भी 'एंटर' कुंजी दबाई जाती है, यह एक ट्रिगर भेजता है और एक ऑडियो फ़ाइल चलाता है।"""
import sounddevice as sd
import soundfile as sf
from pylsl import StreamInfo, StreamOutlet
def wait_for_keypress():
print("ऑडियो प्लेबैक शुरू करने और LSL मार्कर भेजने के लिए ENTER दबाएं।")
while True: # This loop waits for a keyboard input input_str = input() # Wait for input from the terminal if input_str == "": # If the enter key is pressed, proceed break
def AudioMarker(audio_file, outlet): # ऑडियो चलाने और मार्कर भेजने के लिए फ़ंक्शन
data, fs = sf.read(audio_file) # ऑडियो फ़ाइल लोड करें
print("Playing audio and sending LSL marker...") marker_val = [1] outlet.push_sample(marker_val) # Send marker indicating the start of audio playback sd.play(data, fs) # play the audio sd.wait() # Wait until audio is done playing print("Audio playback finished.")
if name == "main": # मुख्य लूप
# मार्कर्स के लिए LSL स्ट्रीम सेटअप
stream_name = 'AudioMarkers'
stream_type = 'Markers'
n_chans = 1
sr = 0 # मार्कर अनियमित हैं, इसलिए सैंपलिंग दर 0 पर सेट करें
chan_format = 'int32'
marker_id = 'uniqueMarkerID12345'
info = StreamInfo(stream_name, stream_type, n_chans, sr, chan_format, marker_id) outlet = StreamOutlet(info) # create LSL outlet # Keep the script running and wait for ENTER key to play audio and send marker while True: wait_for_keypress() audio_filepath = "/path/to/your/audio_file.wav" # replace with correct path to your audio file AudioMarker(audio_filepath, outlet) # After playing audio and sending a marker, the script goes back to waiting for the next keypress</code></pre><p><em><strong>**By running this file (even before playing the audio), you've initiated an LSL stream through an outlet</strong></em><strong>. Now we'll view that stream in LabRecorder</strong></p><p><strong>STEP 5 - Use LabRecorder to view and save all LSL streams</strong></p><ol><li data-preset-tag="p"><p>Open LabRecorder</p></li><li data-preset-tag="p"><p>Press <em><strong>Update</strong></em>. The available LSL streams should be visible in the stream list<br> • You should be able to see streams from both EmotivPROs (usually called "EmotivDataStream") and the marker stream (called "AudioMarkers")</p></li><li data-preset-tag="p"><p>Click <em><strong>Browse</strong></em> to select a location to store data (and set other parameters)</p></li><li data-preset-tag="p"><p>Select all streams and press <em><strong>Record</strong></em> to start recording</p></li><li data-preset-tag="p"><p>Click Stop when you want to end the recording</p></li></ol><p><br></p><img alt="" src="https://framerusercontent.com/images/HFGuJF9ErVu2Jxrgtqt11tl0No.jpg"><h2><strong>Working with the data</strong></h2><p><strong>LabRecorder outputs an XDF file (Extensible Data Format) that contains data from all the streams. XDF files are structured into, </strong><em><strong>streams</strong></em><strong>, each with a different </strong><em><strong>header</strong></em><strong> that describes what it contains (device name, data type, sampling rate, channels, and more). You can use the below codeblock to open your XDF file and display some basic information.</strong></p><pre data-language="JSX"><code>
यह उदाहरण स्क्रिप्ट EmotivPRO सॉफ़्टवेयर से एकत्रित EEG डेटा को आयात और एनोटेट करने के लिए कुछ बुनियादी कार्यों का प्रदर्शन करती है। यह एक XDF फ़ाइल लोड करने, कुछ बुनियादी मेटाडेटा प्रिंट करने, एक info वस्तु बनाने और शक्ति स्पेक्ट्रम को प्लॉट करने के लिए MNE का उपयोग करती है।"""
import pyxdf
import mne
import matplotlib.pyplot as plt
import numpy as np
आपके XDF फ़ाइल का पथ
data_path = '/path/to/your/xdf_file.xdf'
XDF फ़ाइल लोड करें
streams, fileheader = pyxdf.load_xdf(data_path)
print("XDF फ़ाइल हैडर:", fileheader)
print("पाई गई स्ट्रीम की संख्या:", len(streams))
for i, stream in enumerate(streams):
print("\nस्ट्रीम", i + 1)
print("स्ट्रीम नाम:", stream['info']['name'][0])
print("स्ट्रीम प्रकार:", stream['info']['type'][0])
print("चैनलों की संख्या:", stream['info']['channel_count'][0])
sfreq = float(stream['info']['nominal_srate'][0])
print("नमूना दर:", sfreq)
print("नमूना की संख्या:", len(stream['time_series']))
print("पहले 5 डेटा पॉइंट्स प्रिंट करें:", stream['time_series'][:5])
channel_names = [chan['label'][0] for chan in stream['info']['desc'][0]['channels'][0]['channel']] print("Channel Names:", channel_names) channel_types = 'eeg'
MNE जानकारी वस्तु बनाएं
info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # डेटा को ट्रांसपोज़ किया जाना चाहिए: चैनल एक्स नमूने
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # एक साधारण स्पेक्ट्रोग्राम (शक्ति स्पेक्ट्रल घनत्व) को प्लॉट करें अतिरिक्त संसाधन इस ट्यूटोरियल को EMOTIV गिटहब से जुपिटर नोटबुक के रूप में डाउनलोड करें LSL ऑनलाइन दस्तावेज़ीकरण की जांच करें, जिसमें GitHub पर आधिकारिक README फ़ाइल शामिल है आपको डेटा एकत्र करने के लिए एक या अधिक समर्थित डेटा अधिग्रहण उपकरणों की आवश्यकता होगी EMOTIV के सभी ब्रेनवेयर उपकरण EmotivPRO सॉफ़्टवेयर से जुड़े होते हैं, जिसमें डेटा स्ट्रीम भेजने और प्राप्त करने के लिए LSL अंतर्निर्मित क्षमताएँ होती हैं अतिरिक्त संसाधन: Emotiv के उपकरणों का उपयोग करके LSL चलाने के लिए कोड, उदाहरण स्क्रिप्ट यूट्यूब पर उपयोगी LSL डेमो SCCN LSL गिटहब रिपॉजिटरी सभी संबंधित पुस्तकालयों के लिए गिटहब रिपॉजिटरी उप-मॉड्यूल और ऐप्स का संग्रह HyPyP विश्लेषण पाइपलाइन हाइपरस्कैनिंग अध्ययनों के लिए
रोशिनी रंदेनिया और लुकास क्लाइन
ऑपरेशन:
जब कमांड लाइन में चलाया जाता है, तो यह स्क्रिप्ट तुरंत एक LSL स्ट्रीम शुरू करता है। जब भी 'एंटर' कुंजी दबाई जाती है, यह एक ट्रिगर भेजता है और एक ऑडियो फ़ाइल चलाता है।"""
import sounddevice as sd
import soundfile as sf
from pylsl import StreamInfo, StreamOutlet
def wait_for_keypress():
print("ऑडियो प्लेबैक शुरू करने और LSL मार्कर भेजने के लिए ENTER दबाएं।")
while True: # This loop waits for a keyboard input input_str = input() # Wait for input from the terminal if input_str == "": # If the enter key is pressed, proceed break
def AudioMarker(audio_file, outlet): # ऑडियो चलाने और मार्कर भेजने के लिए फ़ंक्शन
data, fs = sf.read(audio_file) # ऑडियो फ़ाइल लोड करें
print("Playing audio and sending LSL marker...") marker_val = [1] outlet.push_sample(marker_val) # Send marker indicating the start of audio playback sd.play(data, fs) # play the audio sd.wait() # Wait until audio is done playing print("Audio playback finished.")
if name == "main": # मुख्य लूप
# मार्कर्स के लिए LSL स्ट्रीम सेटअप
stream_name = 'AudioMarkers'
stream_type = 'Markers'
n_chans = 1
sr = 0 # मार्कर अनियमित हैं, इसलिए सैंपलिंग दर 0 पर सेट करें
chan_format = 'int32'
marker_id = 'uniqueMarkerID12345'
info = StreamInfo(stream_name, stream_type, n_chans, sr, chan_format, marker_id) outlet = StreamOutlet(info) # create LSL outlet # Keep the script running and wait for ENTER key to play audio and send marker while True: wait_for_keypress() audio_filepath = "/path/to/your/audio_file.wav" # replace with correct path to your audio file AudioMarker(audio_filepath, outlet) # After playing audio and sending a marker, the script goes back to waiting for the next keypress</code></pre><p><em><strong>**By running this file (even before playing the audio), you've initiated an LSL stream through an outlet</strong></em><strong>. Now we'll view that stream in LabRecorder</strong></p><p><strong>STEP 5 - Use LabRecorder to view and save all LSL streams</strong></p><ol><li data-preset-tag="p"><p>Open LabRecorder</p></li><li data-preset-tag="p"><p>Press <em><strong>Update</strong></em>. The available LSL streams should be visible in the stream list<br> • You should be able to see streams from both EmotivPROs (usually called "EmotivDataStream") and the marker stream (called "AudioMarkers")</p></li><li data-preset-tag="p"><p>Click <em><strong>Browse</strong></em> to select a location to store data (and set other parameters)</p></li><li data-preset-tag="p"><p>Select all streams and press <em><strong>Record</strong></em> to start recording</p></li><li data-preset-tag="p"><p>Click Stop when you want to end the recording</p></li></ol><p><br></p><img alt="" src="https://framerusercontent.com/images/HFGuJF9ErVu2Jxrgtqt11tl0No.jpg"><h2><strong>Working with the data</strong></h2><p><strong>LabRecorder outputs an XDF file (Extensible Data Format) that contains data from all the streams. XDF files are structured into, </strong><em><strong>streams</strong></em><strong>, each with a different </strong><em><strong>header</strong></em><strong> that describes what it contains (device name, data type, sampling rate, channels, and more). You can use the below codeblock to open your XDF file and display some basic information.</strong></p><pre data-language="JSX"><code>
यह उदाहरण स्क्रिप्ट EmotivPRO सॉफ़्टवेयर से एकत्रित EEG डेटा को आयात और एनोटेट करने के लिए कुछ बुनियादी कार्यों का प्रदर्शन करती है। यह एक XDF फ़ाइल लोड करने, कुछ बुनियादी मेटाडेटा प्रिंट करने, एक info वस्तु बनाने और शक्ति स्पेक्ट्रम को प्लॉट करने के लिए MNE का उपयोग करती है।"""
import pyxdf
import mne
import matplotlib.pyplot as plt
import numpy as np
आपके XDF फ़ाइल का पथ
data_path = '/path/to/your/xdf_file.xdf'
XDF फ़ाइल लोड करें
streams, fileheader = pyxdf.load_xdf(data_path)
print("XDF फ़ाइल हैडर:", fileheader)
print("पाई गई स्ट्रीम की संख्या:", len(streams))
for i, stream in enumerate(streams):
print("\nस्ट्रीम", i + 1)
print("स्ट्रीम नाम:", stream['info']['name'][0])
print("स्ट्रीम प्रकार:", stream['info']['type'][0])
print("चैनलों की संख्या:", stream['info']['channel_count'][0])
sfreq = float(stream['info']['nominal_srate'][0])
print("नमूना दर:", sfreq)
print("नमूना की संख्या:", len(stream['time_series']))
print("पहले 5 डेटा पॉइंट्स प्रिंट करें:", stream['time_series'][:5])
channel_names = [chan['label'][0] for chan in stream['info']['desc'][0]['channels'][0]['channel']] print("Channel Names:", channel_names) channel_types = 'eeg'
MNE जानकारी वस्तु बनाएं
info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # डेटा को ट्रांसपोज़ किया जाना चाहिए: चैनल एक्स नमूने
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # एक साधारण स्पेक्ट्रोग्राम (शक्ति स्पेक्ट्रल घनत्व) को प्लॉट करें अतिरिक्त संसाधन इस ट्यूटोरियल को EMOTIV गिटहब से जुपिटर नोटबुक के रूप में डाउनलोड करें LSL ऑनलाइन दस्तावेज़ीकरण की जांच करें, जिसमें GitHub पर आधिकारिक README फ़ाइल शामिल है आपको डेटा एकत्र करने के लिए एक या अधिक समर्थित डेटा अधिग्रहण उपकरणों की आवश्यकता होगी EMOTIV के सभी ब्रेनवेयर उपकरण EmotivPRO सॉफ़्टवेयर से जुड़े होते हैं, जिसमें डेटा स्ट्रीम भेजने और प्राप्त करने के लिए LSL अंतर्निर्मित क्षमताएँ होती हैं अतिरिक्त संसाधन: Emotiv के उपकरणों का उपयोग करके LSL चलाने के लिए कोड, उदाहरण स्क्रिप्ट यूट्यूब पर उपयोगी LSL डेमो SCCN LSL गिटहब रिपॉजिटरी सभी संबंधित पुस्तकालयों के लिए गिटहब रिपॉजिटरी उप-मॉड्यूल और ऐप्स का संग्रह HyPyP विश्लेषण पाइपलाइन हाइपरस्कैनिंग अध्ययनों के लिए
रोशिनी रंदेनिया और लुकास क्लाइन
ऑपरेशन:
जब कमांड लाइन में चलाया जाता है, तो यह स्क्रिप्ट तुरंत एक LSL स्ट्रीम शुरू करता है। जब भी 'एंटर' कुंजी दबाई जाती है, यह एक ट्रिगर भेजता है और एक ऑडियो फ़ाइल चलाता है।"""
import sounddevice as sd
import soundfile as sf
from pylsl import StreamInfo, StreamOutlet
def wait_for_keypress():
print("ऑडियो प्लेबैक शुरू करने और LSL मार्कर भेजने के लिए ENTER दबाएं।")
while True: # This loop waits for a keyboard input input_str = input() # Wait for input from the terminal if input_str == "": # If the enter key is pressed, proceed break
def AudioMarker(audio_file, outlet): # ऑडियो चलाने और मार्कर भेजने के लिए फ़ंक्शन
data, fs = sf.read(audio_file) # ऑडियो फ़ाइल लोड करें
print("Playing audio and sending LSL marker...") marker_val = [1] outlet.push_sample(marker_val) # Send marker indicating the start of audio playback sd.play(data, fs) # play the audio sd.wait() # Wait until audio is done playing print("Audio playback finished.")
if name == "main": # मुख्य लूप
# मार्कर्स के लिए LSL स्ट्रीम सेटअप
stream_name = 'AudioMarkers'
stream_type = 'Markers'
n_chans = 1
sr = 0 # मार्कर अनियमित हैं, इसलिए सैंपलिंग दर 0 पर सेट करें
chan_format = 'int32'
marker_id = 'uniqueMarkerID12345'
info = StreamInfo(stream_name, stream_type, n_chans, sr, chan_format, marker_id) outlet = StreamOutlet(info) # create LSL outlet # Keep the script running and wait for ENTER key to play audio and send marker while True: wait_for_keypress() audio_filepath = "/path/to/your/audio_file.wav" # replace with correct path to your audio file AudioMarker(audio_filepath, outlet) # After playing audio and sending a marker, the script goes back to waiting for the next keypress</code></pre><p><em><strong>**By running this file (even before playing the audio), you've initiated an LSL stream through an outlet</strong></em><strong>. Now we'll view that stream in LabRecorder</strong></p><p><strong>STEP 5 - Use LabRecorder to view and save all LSL streams</strong></p><ol><li data-preset-tag="p"><p>Open LabRecorder</p></li><li data-preset-tag="p"><p>Press <em><strong>Update</strong></em>. The available LSL streams should be visible in the stream list<br> • You should be able to see streams from both EmotivPROs (usually called "EmotivDataStream") and the marker stream (called "AudioMarkers")</p></li><li data-preset-tag="p"><p>Click <em><strong>Browse</strong></em> to select a location to store data (and set other parameters)</p></li><li data-preset-tag="p"><p>Select all streams and press <em><strong>Record</strong></em> to start recording</p></li><li data-preset-tag="p"><p>Click Stop when you want to end the recording</p></li></ol><p><br></p><img alt="" src="https://framerusercontent.com/images/HFGuJF9ErVu2Jxrgtqt11tl0No.jpg"><h2><strong>Working with the data</strong></h2><p><strong>LabRecorder outputs an XDF file (Extensible Data Format) that contains data from all the streams. XDF files are structured into, </strong><em><strong>streams</strong></em><strong>, each with a different </strong><em><strong>header</strong></em><strong> that describes what it contains (device name, data type, sampling rate, channels, and more). You can use the below codeblock to open your XDF file and display some basic information.</strong></p><pre data-language="JSX"><code>
यह उदाहरण स्क्रिप्ट EmotivPRO सॉफ़्टवेयर से एकत्रित EEG डेटा को आयात और एनोटेट करने के लिए कुछ बुनियादी कार्यों का प्रदर्शन करती है। यह एक XDF फ़ाइल लोड करने, कुछ बुनियादी मेटाडेटा प्रिंट करने, एक info वस्तु बनाने और शक्ति स्पेक्ट्रम को प्लॉट करने के लिए MNE का उपयोग करती है।"""
import pyxdf
import mne
import matplotlib.pyplot as plt
import numpy as np
आपके XDF फ़ाइल का पथ
data_path = '/path/to/your/xdf_file.xdf'
XDF फ़ाइल लोड करें
streams, fileheader = pyxdf.load_xdf(data_path)
print("XDF फ़ाइल हैडर:", fileheader)
print("पाई गई स्ट्रीम की संख्या:", len(streams))
for i, stream in enumerate(streams):
print("\nस्ट्रीम", i + 1)
print("स्ट्रीम नाम:", stream['info']['name'][0])
print("स्ट्रीम प्रकार:", stream['info']['type'][0])
print("चैनलों की संख्या:", stream['info']['channel_count'][0])
sfreq = float(stream['info']['nominal_srate'][0])
print("नमूना दर:", sfreq)
print("नमूना की संख्या:", len(stream['time_series']))
print("पहले 5 डेटा पॉइंट्स प्रिंट करें:", stream['time_series'][:5])
channel_names = [chan['label'][0] for chan in stream['info']['desc'][0]['channels'][0]['channel']] print("Channel Names:", channel_names) channel_types = 'eeg'
MNE जानकारी वस्तु बनाएं
info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # डेटा को ट्रांसपोज़ किया जाना चाहिए: चैनल एक्स नमूने
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # एक साधारण स्पेक्ट्रोग्राम (शक्ति स्पेक्ट्रल घनत्व) को प्लॉट करें अतिरिक्त संसाधन इस ट्यूटोरियल को EMOTIV गिटहब से जुपिटर नोटबुक के रूप में डाउनलोड करें LSL ऑनलाइन दस्तावेज़ीकरण की जांच करें, जिसमें GitHub पर आधिकारिक README फ़ाइल शामिल है आपको डेटा एकत्र करने के लिए एक या अधिक समर्थित डेटा अधिग्रहण उपकरणों की आवश्यकता होगी EMOTIV के सभी ब्रेनवेयर उपकरण EmotivPRO सॉफ़्टवेयर से जुड़े होते हैं, जिसमें डेटा स्ट्रीम भेजने और प्राप्त करने के लिए LSL अंतर्निर्मित क्षमताएँ होती हैं अतिरिक्त संसाधन: Emotiv के उपकरणों का उपयोग करके LSL चलाने के लिए कोड, उदाहरण स्क्रिप्ट यूट्यूब पर उपयोगी LSL डेमो SCCN LSL गिटहब रिपॉजिटरी सभी संबंधित पुस्तकालयों के लिए गिटहब रिपॉजिटरी उप-मॉड्यूल और ऐप्स का संग्रह HyPyP विश्लेषण पाइपलाइन हाइपरस्कैनिंग अध्ययनों के लिए
