본문 바로가기
Brain Engineering/MNE

[MNE-Python] fNIRS 장치에서 데이터 가져오기 (2)

by goatlab 2022. 4. 4.
728x90
반응형
SMALL

Loading legacy data in CSV or TSV format

 

fNIRS 측정값은 MNE-Python에서 지원하지 않고 SNIRF로 쉽게 변환할 수 없는 비표준 형식으로 저장될 수 있다. 이 레거시 데이터는 CSV 또는 TSV 형식인 경우가 많으며 파일 형식 (채널의 이름 지정 및 순서, 형식 및 데이터 스케일링, 센서 위치 사양은 벤더마다 다름) CSV가 시작된 시스템에 따라 이를 조정해야 할 수 있다.

 

import os.path as op
import numpy as np
import pandas as pd
import mne

pd.DataFrame(np.random.normal(size=(16, 100))).to_csv("fnirs.csv")

 

MNE-Python에 로드될 예제 CSV 파일을 생성한다. 로드하려는 실제 데이터가 있는 경우 이 단계를 건너뛴다. 100개의 데이터 샘플로 16개 채널을 시뮬레이션하고 이를 fnirs.csv라는 파일에 저장한다.

 

data = pd.read_csv('fnirs.csv')

 

CSV 파일에 채널 이름, 유형, 샘플 속도 등에 대한 정보가 포함되어 있지 않으므로 메타데이터를 수동으로 지정해야 한다.

 

ch_names = ['S1_D1 hbo', 'S1_D1 hbr', 'S2_D1 hbo', 'S2_D1 hbr',
            'S3_D1 hbo', 'S3_D1 hbr', 'S4_D1 hbo', 'S4_D1 hbr',
            'S5_D2 hbo', 'S5_D2 hbr', 'S6_D2 hbo', 'S6_D2 hbr',
            'S7_D2 hbo', 'S7_D2 hbr', 'S8_D2 hbo', 'S8_D2 hbr']
ch_types = ['hbo', 'hbr', 'hbo', 'hbr',
            'hbo', 'hbr', 'hbo', 'hbr',
            'hbo', 'hbr', 'hbo', 'hbr',
            'hbo', 'hbr', 'hbo', 'hbr']
sfreq = 10.  # in Hz

 

데이터를 MNE-Python 데이터 구조로 변환할 수 있다. 위의 메타데이터는 mne.Info데이터 구조를 생성하는 데 사용되며, 이를 데이터와 결합하여 MNE-Python Raw 객체를 생성한다.

 

info = mne.create_info(ch_names=ch_names, ch_types=ch_types, sfreq=sfreq)
raw = mne.io.RawArray(data, info, verbose=True)
---
Creating RawArray with float64 data, n_channels=16, n_times=101
    Range : 0 ... 100 =      0.000 ...    10.000 secs
Ready.

 

Applying standard sensor locations to imported data

 

optode 위치에 대한 정보가 있으면 분석에 도움이 될 수 있다. 이것이 제공하는 일반적인 이점 (ex. 관심 영역 생성 등) 외에도 광학 밀도 데이터를 헤모글로빈 농도 추정치로 변환하는 데 광극 위치에 대한 정보가 필요하기 때문에 fNIRS에 특히 중요할 수 있다. MNE-Python은 일부 공급업체의 표준 센서 구성(몽타주)을 로드하는 방법을 제공하며 이는 아래에 설명되어 있다. 센서 위치, 좌표계, MNE-Python에서 이 정보를 저장하고 보는 방법을 이해하기 위한 몇 가지 편리한 자습서는 다음과 같다.

 

- Working with sensor locations
- Source alignment and coordinate frames
- Plotting EEG sensors on the scalp
montage = mne.channels.make_standard_montage('artinis-octamon')
raw.set_montage(montage)

# View the position of optodes in 2D to confirm the positions are correct.
raw.plot_sensors()

 

위치가 올바르게 로드되었는지 확인하기 위해 3D 표현에서 소스 (빨간색), 감지기 (검은색) 및 채널 (흰색 선 및 주황색 점)의 위치를 ​​볼 수도 있다. 기준점은 파란색, 녹색 및 빨간색으로 표시된다. 자세한 내용은 소스 정렬 및 좌표 프레임을 참조하면 된다.

 

subjects_dir = op.join(mne.datasets.sample.data_path(), 'subjects')
mne.datasets.fetch_fsaverage(subjects_dir=subjects_dir)

brain = mne.viz.Brain('fsaverage', subjects_dir=subjects_dir,
                      alpha=0.5, cortex='low_contrast')
brain.add_head()
brain.add_sensors(raw.info, trans='fsaverage')
brain.show_view(azimuth=90, elevation=90, distance=500)

 

https://mne.tools/stable/auto_tutorials/io/30_reading_fnirs_data.html

 

Importing data from fNIRS devices — MNE 1.0.0 documentation

fNIRS devices consist of two kinds of optodes: light sources (AKA “emitters” or “transmitters”) and light detectors (AKA “receivers”). Channels are defined as source-detector pairs, and channel locations are defined as the midpoint between sour

mne.tools

 

728x90
반응형
LIST