Note
Click here to download the full example code
Getting events from .snirf files¶
Importage¶
# KF Tools and related imports
from kftools.data import fetch_file
from kftools.snirf import get_events_from_snirf
from mne.io import read_raw_snirf
Grab the data¶
data_dir='.'
fetch_file(data_dir=data_dir, filetype='kp-snf-hbm',
site='snic', task='ft', subid='sub001', sesid='ses02')
Out:
Downloading snic_sub001_ft_ses02_0917-1313_kp-snf-hbm.snirf
Downloading...
From: https://drive.google.com/uc?id=1IOB4DZFDIkWzj9AtxygV8mQE1Ee2mtHt
To: /home/runner/work/kernel-flow-tools/kernel-flow-tools/examples/snic_sub001_ft_ses02_0917-1313_kp-snf-hbm.snirf
0%| | 0.00/431M [00:00<?, ?B/s]
0%| | 1.05M/431M [00:00<00:47, 9.03MB/s]
3%|2 | 11.5M/431M [00:00<00:10, 41.5MB/s]
4%|4 | 18.4M/431M [00:00<00:09, 44.5MB/s]
6%|5 | 25.7M/431M [00:00<00:08, 49.8MB/s]
8%|7 | 34.1M/431M [00:00<00:07, 54.3MB/s]
10%|9 | 42.5M/431M [00:00<00:07, 54.7MB/s]
12%|#1 | 50.9M/431M [00:00<00:06, 57.2MB/s]
14%|#3 | 59.2M/431M [00:01<00:06, 58.4MB/s]
16%|#5 | 67.6M/431M [00:01<00:06, 55.8MB/s]
18%|#7 | 76.0M/431M [00:01<00:05, 62.0MB/s]
20%|#9 | 84.4M/431M [00:01<00:07, 48.2MB/s]
22%|##1 | 92.8M/431M [00:01<00:06, 52.2MB/s]
23%|##3 | 101M/431M [00:01<00:05, 58.7MB/s]
26%|##5 | 111M/431M [00:01<00:04, 66.9MB/s]
27%|##7 | 118M/431M [00:02<00:04, 69.3MB/s]
30%|### | 131M/431M [00:02<00:03, 84.1MB/s]
33%|###2 | 141M/431M [00:02<00:03, 80.6MB/s]
35%|###5 | 152M/431M [00:02<00:03, 73.0MB/s]
39%|###9 | 168M/431M [00:02<00:02, 90.6MB/s]
42%|####2 | 182M/431M [00:02<00:02, 102MB/s]
45%|####4 | 193M/431M [00:02<00:02, 101MB/s]
49%|####8 | 210M/431M [00:03<00:02, 96.6MB/s]
53%|#####2 | 227M/431M [00:03<00:02, 85.2MB/s]
57%|#####6 | 244M/431M [00:03<00:01, 96.8MB/s]
60%|###### | 261M/431M [00:03<00:01, 110MB/s]
64%|######4 | 277M/431M [00:03<00:01, 116MB/s]
70%|######9 | 300M/431M [00:03<00:00, 142MB/s]
73%|#######3 | 316M/431M [00:03<00:00, 139MB/s]
77%|#######6 | 330M/431M [00:03<00:00, 138MB/s]
80%|######## | 345M/431M [00:04<00:00, 118MB/s]
85%|########5 | 368M/431M [00:04<00:00, 144MB/s]
89%|########8 | 383M/431M [00:04<00:00, 146MB/s]
94%|#########3| 403M/431M [00:04<00:00, 151MB/s]
99%|#########8| 425M/431M [00:04<00:00, 169MB/s]
100%|##########| 431M/431M [00:04<00:00, 94.2MB/s]
Get the events¶
f = 'snic_sub001_ft_ses02_0917-1313_kp-snf-hbm.snirf'
evs = get_events_from_snirf(f)
evs
Timestamp | Event | Duration | Value | Block | Trial | TrialType | BlockType | |
---|---|---|---|---|---|---|---|---|
0 | 15.168075 | StartBlock | 20.993202 | 1.0 | 1.0 | NaN | NaN | Left |
1 | 15.184670 | StartIti | 0.691229 | 1.0 | 1.0 | NaN | NaN | Left |
2 | 15.875989 | StartTrial | 0.759476 | 1.0 | 1.0 | 1.0 | Index | Left |
3 | 16.651278 | StartIti | 0.764339 | 1.0 | 1.0 | NaN | NaN | Left |
4 | 17.415692 | StartTrial | 0.769651 | 1.0 | 1.0 | 2.0 | Middle | Left |
... | ... | ... | ... | ... | ... | ... | ... | ... |
653 | 797.449479 | StartTrial | 0.769480 | 1.0 | 20.0 | 299.0 | Middle | Right |
654 | 798.234787 | StartIti | 0.405636 | 1.0 | 20.0 | NaN | NaN | Right |
655 | 798.640504 | StartTrial | 0.762039 | 1.0 | 20.0 | 300.0 | Ring | Right |
656 | 799.418014 | StartIti | 0.524964 | 1.0 | 20.0 | NaN | NaN | Right |
657 | 799.968801 | StartRest | 20.019163 | 1.0 | NaN | NaN | NaN | NaN |
658 rows × 8 columns
Total running time of the script: ( 0 minutes 5.496 seconds)