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')

Out:

Downloading pitch_sub010_ft_ses01_1017-1706_kp-snf-hbm.snirf

Downloading...
From: https://drive.google.com/uc?id=1BcZHsmDWgxhppg_j4yqBLj2MBM20kzM_
To: /home/runner/work/kernel-flow-tools/kernel-flow-tools/examples/pitch_sub010_ft_ses01_1017-1706_kp-snf-hbm.snirf

  0%|          | 0.00/237M [00:00<?, ?B/s]
  2%|1         | 4.72M/237M [00:00<00:05, 39.7MB/s]
  5%|4         | 11.5M/237M [00:00<00:05, 39.9MB/s]
  8%|7         | 18.4M/237M [00:00<00:05, 40.4MB/s]
 11%|#         | 25.7M/237M [00:00<00:05, 40.1MB/s]
 14%|#4        | 34.1M/237M [00:00<00:04, 42.7MB/s]
 18%|#7        | 42.5M/237M [00:01<00:04, 42.4MB/s]
 21%|##1       | 50.9M/237M [00:01<00:04, 45.5MB/s]
 25%|##4       | 59.2M/237M [00:01<00:03, 50.2MB/s]
 28%|##8       | 67.6M/237M [00:01<00:03, 48.6MB/s]
 32%|###2      | 76.0M/237M [00:01<00:03, 53.0MB/s]
 36%|###5      | 84.4M/237M [00:01<00:02, 54.1MB/s]
 39%|###9      | 92.8M/237M [00:01<00:02, 52.8MB/s]
 43%|####2     | 101M/237M [00:02<00:02, 58.2MB/s]
 46%|####6     | 110M/237M [00:02<00:02, 54.5MB/s]
 50%|####9     | 118M/237M [00:02<00:02, 53.8MB/s]
 53%|#####3    | 126M/237M [00:02<00:01, 58.7MB/s]
 57%|#####6    | 135M/237M [00:02<00:01, 60.3MB/s]
 61%|######    | 144M/237M [00:02<00:01, 67.8MB/s]
 64%|######3   | 152M/237M [00:02<00:01, 67.9MB/s]
 67%|######7   | 160M/237M [00:03<00:01, 61.8MB/s]
 71%|#######   | 168M/237M [00:03<00:01, 51.9MB/s]
 74%|#######4  | 177M/237M [00:03<00:01, 50.6MB/s]
 79%|#######8  | 187M/237M [00:03<00:00, 60.4MB/s]
 82%|########1 | 193M/237M [00:03<00:01, 41.6MB/s]
 86%|########6 | 204M/237M [00:03<00:00, 53.7MB/s]
 89%|########9 | 212M/237M [00:04<00:00, 54.9MB/s]
 93%|#########3| 221M/237M [00:04<00:00, 61.4MB/s]
 99%|#########9| 235M/237M [00:04<00:00, 79.5MB/s]
100%|##########| 237M/237M [00:04<00:00, 55.5MB/s]

Specify and run the GLM model

f = 'pitch_sub010_ft_ses01_1017-1706_kp-snf-hbm.snirf'

res_hbo = snirf_task_ana(f,chromo='hbo')
res_hbr = snirf_task_ana(f, chromo='hbr')

res_hbo.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')
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_hbo['glm_est']
con = res_hbo['contrast_LgtR'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbo',
                                 vmin=0,vmax=0.5,sig_thr=0.00001)
disp.show()
Oxyhaemoglobin

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_hbo['glm_est']
con = res_hbo['contrast_RgtL'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbo',
                                 vmin=0,vmax=0.5,sig_thr=0.00001)
disp.show()
Oxyhaemoglobin

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_hbr['glm_est']
con = res_hbr['contrast_LgtR'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbr',
                                 vmin=0,vmax=0.3,sig_thr=0.0001)
disp.show()
Deoxyhaemoglobin

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_hbr['glm_est']
con = res_hbr['contrast_RgtL'].data
disp = kf_plot_glm_contrast_topo(glmest, con, chromo='hbr',
                                 vmin=0,vmax=0.5,sig_thr=0.0001)
disp.show()
Deoxyhaemoglobin

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: ( 2 minutes 29.672 seconds)

Gallery generated by Sphinx-Gallery