Note
Click here to download the full example code
SNIRF HbM GLM Analysis¶
Importage¶
# KF Tools and related imports
from kftools.data import fetch_file
from kftools.snirf import snirf_task_ana,kf_plot_glm_contrast_topo
Grab the data¶
data_dir='.'
fetch_file(data_dir=data_dir, filetype='kp-snf-hbm',
site='pitch', task='ft', subid='sub010', sesid='ses01')
Specify and run the GLM model¶
f = 'pitch_sub010_ft_ses01_1017-1706_kp-snf-hbm.snirf'
res = snirf_task_ana(f)
res.keys()
Out:
Loading /home/runner/work/kernel-flow-tools/kernel-flow-tools/examples/pitch_sub010_ft_ses01_1017-1706_kp-snf-hbm.snirf
Reading 0 ... 6435 = 0.000 ... 779.279 secs...
Used Annotations descriptions: ['Rest', 'Tapping/L', 'Tapping/R']
Multiple event values for single event times found. Creating new event value to reflect simultaneous events.
Not setting metadata
280 matching events found
Applying baseline correction (mode: mean)
Using data from preloaded Raw for 280 events and 26 original time points ...
3 bad epochs dropped
Used Annotations descriptions: ['Rest', 'Tapping/L', 'Tapping/R']
/home/runner/work/kernel-flow-tools/kernel-flow-tools/kftools/snirf/mne.py:106: RuntimeWarning: (X, Y) fit (-0.0, -20.4) more than 20 mm from head frame origin
sphere_params = _check_sphere('auto', info=hbm.info, sphere_units='m')
dict_keys(['df_evs', 'ev', 'ev_d', 'hbm', 'hbm_ep', 'hbm_ev_LgtR', 'hbm_ev_RgtL', 's', 'design_matrix', 'data_subset', 'sphere_params', 'glm_est', 'contrast_LgtR', 'contrast_vec_LgtR', 'contrast_RgtL', 'estmrg_LgtR', 'estmrg_RgtL', 'contrast_LgtRest', 'contrast_vec_LgtRest', 'contrast_RgtRest', 'estmrg_LgtRest', 'estmrg_RgtRest', 'pos_LgtR', 'pos_RgtL', 'chs_LgtR', 'chs_RgtL', 'sphere_LgtR', 'sphere_RgtL', 'chromo'])
Look at GLM results¶
HbO, Left > Right contrast
glmest = res['glm_est']
con = res['contrast_LgtR'].data
disp = kf_plot_glm_contrast_topo(glmest, con,
vmin=0,vmax=0.5,sig_thr=0.00001)

Out:
/home/runner/work/kernel-flow-tools/kernel-flow-tools/kftools/snirf/mne.py:245: RuntimeWarning: (X, Y) fit (-0.0, -20.4) more than 20 mm from head frame origin
estmrg, pos, chs, sphere = _handle_overlaps(info, t, sphere, estimates)
HbO, Right > Left contrast
glmest = res['glm_est']
con = res['contrast_RgtL'].data
disp = kf_plot_glm_contrast_topo(glmest, con,
vmin=0,vmax=0.5,sig_thr=0.00001)

Out:
/home/runner/work/kernel-flow-tools/kernel-flow-tools/kftools/snirf/mne.py:245: RuntimeWarning: (X, Y) fit (-0.0, -20.4) more than 20 mm from head frame origin
estmrg, pos, chs, sphere = _handle_overlaps(info, t, sphere, estimates)
HbR, Left > Right contrast
glmest = res['glm_est']
con = res['contrast_LgtR'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbr',
vmin=0,vmax=0.3,sig_thr=0.0001)

Out:
/home/runner/work/kernel-flow-tools/kernel-flow-tools/kftools/snirf/mne.py:245: RuntimeWarning: (X, Y) fit (-0.0, -20.4) more than 20 mm from head frame origin
estmrg, pos, chs, sphere = _handle_overlaps(info, t, sphere, estimates)
HbR, Right > Left contrast
glmest = res['glm_est']
con = res['contrast_RgtL'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbr',
vmin=0,vmax=0.5,sig_thr=0.0001)

Out:
/home/runner/work/kernel-flow-tools/kernel-flow-tools/kftools/snirf/mne.py:245: RuntimeWarning: (X, Y) fit (-0.0, -20.4) more than 20 mm from head frame origin
estmrg, pos, chs, sphere = _handle_overlaps(info, t, sphere, estimates)
Total running time of the script: ( 1 minutes 18.276 seconds)