다중 데이터 스트림을 동기화하기 위한 Lab Streaming Layer (LSL)

로시니 랜데니야

2025. 10. 1.

공유:

로시니 랜데니야루카스 클라인

작동:
명령줄에서 실행하면 이 스크립트가 즉시 LSL 스트림을 시작합니다. 'Enter' 키가 눌리면 트리거를 전송하고 오디오 파일을 재생합니다."""

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 데이터를 가져오고 주석을 다는 몇 가지 기본 기능을 보여줍니다. MNE를 사용하여 XDF 파일을 로드하고, 기본 메타데이터를 출력하고, info 객체를 생성하고 전력 스펙트럼을 플로팅합니다."""

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 객체 생성

info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # 데이터는 전치되어야 합니다: 채널 x 샘플
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # 간단한 스펙트로그램 (전력 스펙트럼 밀도) 플로팅추가 자료이 튜토리얼을 Jupyter 노트북 형식으로 EMOTIV GitHub에서 다운로드하세요.LSL 온라인 문서를 확인하세요. 공식 README 파일을 GitHub에서 확인하세요.데이터 수집을 위해 하나 이상의 지원되는 데이터 수집 장치가 필요합니다. 모든 EMOTIV의 뇌 관련 장치는 EmotivPRO 소프트웨어에 연결됩니다. 이는 데이터 스트림을 전송하고 수신하기 위한 LSL 내장 기능을 제공합니다.추가 자료: Emotiv의 장치를 사용하여 LSL을 실행하는 코드와 예제 스크립트, YouTube의 유용한 LSL 데모, 관련 라이브러리에 대한 SCCN LSL GitHub 리포지토리, 하위 모듈과 앱의 모음을 위한 GitHub 리포지토리, 하이퍼 스캐닝 연구를 위한 HyPyP 분석 파이프라인

로시니 랜데니야루카스 클라인

작동:
명령줄에서 실행하면 이 스크립트가 즉시 LSL 스트림을 시작합니다. 'Enter' 키가 눌리면 트리거를 전송하고 오디오 파일을 재생합니다."""

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 데이터를 가져오고 주석을 다는 몇 가지 기본 기능을 보여줍니다. MNE를 사용하여 XDF 파일을 로드하고, 기본 메타데이터를 출력하고, info 객체를 생성하고 전력 스펙트럼을 플로팅합니다."""

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 객체 생성

info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # 데이터는 전치되어야 합니다: 채널 x 샘플
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # 간단한 스펙트로그램 (전력 스펙트럼 밀도) 플로팅추가 자료이 튜토리얼을 Jupyter 노트북 형식으로 EMOTIV GitHub에서 다운로드하세요.LSL 온라인 문서를 확인하세요. 공식 README 파일을 GitHub에서 확인하세요.데이터 수집을 위해 하나 이상의 지원되는 데이터 수집 장치가 필요합니다. 모든 EMOTIV의 뇌 관련 장치는 EmotivPRO 소프트웨어에 연결됩니다. 이는 데이터 스트림을 전송하고 수신하기 위한 LSL 내장 기능을 제공합니다.추가 자료: Emotiv의 장치를 사용하여 LSL을 실행하는 코드와 예제 스크립트, YouTube의 유용한 LSL 데모, 관련 라이브러리에 대한 SCCN LSL GitHub 리포지토리, 하위 모듈과 앱의 모음을 위한 GitHub 리포지토리, 하이퍼 스캐닝 연구를 위한 HyPyP 분석 파이프라인

로시니 랜데니야루카스 클라인

작동:
명령줄에서 실행하면 이 스크립트가 즉시 LSL 스트림을 시작합니다. 'Enter' 키가 눌리면 트리거를 전송하고 오디오 파일을 재생합니다."""

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 데이터를 가져오고 주석을 다는 몇 가지 기본 기능을 보여줍니다. MNE를 사용하여 XDF 파일을 로드하고, 기본 메타데이터를 출력하고, info 객체를 생성하고 전력 스펙트럼을 플로팅합니다."""

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 객체 생성

info = mne.create_info(channel_names, sfreq, channel_types)
data = np.array(stream['time_series']).T # 데이터는 전치되어야 합니다: 채널 x 샘플
raw = mne.io.RawArray(data, info)
raw.plot_psd(fmax=50) # 간단한 스펙트로그램 (전력 스펙트럼 밀도) 플로팅추가 자료이 튜토리얼을 Jupyter 노트북 형식으로 EMOTIV GitHub에서 다운로드하세요.LSL 온라인 문서를 확인하세요. 공식 README 파일을 GitHub에서 확인하세요.데이터 수집을 위해 하나 이상의 지원되는 데이터 수집 장치가 필요합니다. 모든 EMOTIV의 뇌 관련 장치는 EmotivPRO 소프트웨어에 연결됩니다. 이는 데이터 스트림을 전송하고 수신하기 위한 LSL 내장 기능을 제공합니다.추가 자료: Emotiv의 장치를 사용하여 LSL을 실행하는 코드와 예제 스크립트, YouTube의 유용한 LSL 데모, 관련 라이브러리에 대한 SCCN LSL GitHub 리포지토리, 하위 모듈과 앱의 모음을 위한 GitHub 리포지토리, 하이퍼 스캐닝 연구를 위한 HyPyP 분석 파이프라인

계속 읽기

신경 진동의 기초

© 2025 EMOTIV, 모든 권리 보유.

Consent

귀하의 개인 정보 선택 (쿠키 설정)

*면책 조항 – EMOTIV 제품은 연구 응용 프로그램 및 개인 용도로만 사용하도록 설계되었습니다. 우리의 제품은 EU 지침 93/42/EEC에 정의된 의료 기기로 판매되지 않습니다. 우리의 제품은 질병의 진단이나 치료를 위해 설계되거나 사용될 의도가 없습니다.

번역에 대한 주의 사항: 이 웹사이트의 비영어 버전은 귀하의 편의를 위해 인공지능을 사용하여 번역되었습니다. 우리는 정확성을 위해 노력하고 있지만, 자동 번역에는 오류나 원본 텍스트와 다른 뉘앙스가 포함될 수 있습니다. 가장 정확한 정보는 이 사이트의 영어 버전을 참조하십시오.

© 2025 EMOTIV, 모든 권리 보유.

Consent

귀하의 개인 정보 선택 (쿠키 설정)

*면책 조항 – EMOTIV 제품은 연구 응용 프로그램 및 개인 용도로만 사용하도록 설계되었습니다. 우리의 제품은 EU 지침 93/42/EEC에 정의된 의료 기기로 판매되지 않습니다. 우리의 제품은 질병의 진단이나 치료를 위해 설계되거나 사용될 의도가 없습니다.

번역에 대한 주의 사항: 이 웹사이트의 비영어 버전은 귀하의 편의를 위해 인공지능을 사용하여 번역되었습니다. 우리는 정확성을 위해 노력하고 있지만, 자동 번역에는 오류나 원본 텍스트와 다른 뉘앙스가 포함될 수 있습니다. 가장 정확한 정보는 이 사이트의 영어 버전을 참조하십시오.

© 2025 EMOTIV, 모든 권리 보유.

Consent

귀하의 개인 정보 선택 (쿠키 설정)

*면책 조항 – EMOTIV 제품은 연구 응용 프로그램 및 개인 용도로만 사용하도록 설계되었습니다. 우리의 제품은 EU 지침 93/42/EEC에 정의된 의료 기기로 판매되지 않습니다. 우리의 제품은 질병의 진단이나 치료를 위해 설계되거나 사용될 의도가 없습니다.

번역에 대한 주의 사항: 이 웹사이트의 비영어 버전은 귀하의 편의를 위해 인공지능을 사용하여 번역되었습니다. 우리는 정확성을 위해 노력하고 있지만, 자동 번역에는 오류나 원본 텍스트와 다른 뉘앙스가 포함될 수 있습니다. 가장 정확한 정보는 이 사이트의 영어 버전을 참조하십시오.