Volume Source Example

Estimate NCRFs for frequent and infrequent (oddball) tones.

For this tutorial, we use the auditory Brainstorm tutorial dataset [Tadel et al., 2011] that is available as a part of the Brainstorm software.

Note

Downloading the dataset requires answering an interactive prompt (see mne.datasets.brainstorm.bst_auditory.data_path()).

# Authors: Proloy Das <proloy@umd.edu>
#          Christian Brodbeck <brodbecc@mcmaster.ca>
#
# sphinx_gallery_thumbnail_number = 8

import eelbrain
import mne
from ncrf import fit_ncrf
import numpy as np
import pandas as pd

Preprocessing

We broadly follow this mne-python tutorial.

data_path = mne.datasets.brainstorm.bst_auditory.data_path()
raw_fname = data_path / 'MEG' / 'bst_auditory' / 'S01_AEF_20131218_01.ds'
raw = mne.io.read_raw_ctf(raw_fname, preload=False)

eog_proj_fname = data_path / 'MEG' / 'bst_auditory' / 'bst_auditory-eog-proj.fif'
eog_proj = mne.read_proj(eog_proj_fname)

# We mark a set of bad channels that seem noisier than others.
raw.info['bads'] = ['MLO52-4408', 'MRT51-4408', 'MLO42-4408', 'MLO43-4408']

# For noise reduction, a set of bad segments have been identified and stored in
# csv files. The bad segments are later used to reject epochs that overlap with
# them. We use pandas to read the data from the csv files.

csv_fname = data_path / 'MEG' / 'bst_auditory' / 'events_bad_01.csv'
annotations_df = pd.read_csv(csv_fname, header=None,
                    names=['onset', 'duration', 'id', 'label'])
print('Events from run 1:')
print(annotations_df)

# Conversion from samples to times:
onsets = annotations_df['onset'].values / raw.info['sfreq']
durations = annotations_df['duration'].values / raw.info['sfreq']
descriptions = annotations_df['label'].values

annotations = mne.Annotations(onsets, durations, descriptions)
raw.set_annotations(annotations)
License
-------
This tutorial dataset (EEG and MRI data) remains a property of the MEG Lab,
McConnell Brain Imaging Center, Montreal Neurological Institute,
McGill University, Canada. Its use and transfer outside the Brainstorm
tutorial, e.g. for research purposes, is prohibited without written consent
from the MEG Lab.

If you reference this dataset in your publications, please:

    1) acknowledge its authors: Elizabeth Bock, Esther Florin, Francois Tadel
       and Sylvain Baillet, and
    2) cite Brainstorm as indicated on the website:
       http://neuroimage.usc.edu/brainstorm

For questions, please contact Francois Tadel (francois.tadel@mcgill.ca).
Agree (y/[n])? Downloading file 'bst_auditory.tar.gz' from 'https://osf.io/download/5t9n8?version=1' to '/home/runner/mne_data'.

  0%|                                              | 0.00/1.64G [00:00<?, ?B/s]
  0%|                                    | 48.1k/1.64G [00:00<1:00:35, 450kB/s]
  0%|                                       | 139k/1.64G [00:00<38:17, 712kB/s]
  0%|                                      | 347k/1.64G [00:00<20:33, 1.33MB/s]
  0%|                                      | 998k/1.64G [00:00<08:08, 3.34MB/s]
  0%|                                     | 3.11M/1.64G [00:00<02:48, 9.71MB/s]
  1%|▏                                    | 8.91M/1.64G [00:00<01:02, 26.0MB/s]
  1%|▎                                    | 14.7M/1.64G [00:00<00:44, 36.4MB/s]
  1%|▍                                    | 21.0M/1.64G [00:00<00:39, 41.2MB/s]
  2%|▋                                    | 28.7M/1.64G [00:00<00:32, 49.5MB/s]
  2%|▊                                    | 35.5M/1.64G [00:01<00:29, 54.2MB/s]
  3%|▉                                    | 40.9M/1.64G [00:01<00:35, 45.3MB/s]
  3%|█                                    | 45.6M/1.64G [00:01<00:38, 41.7MB/s]
  3%|█▏                                   | 51.8M/1.64G [00:01<00:34, 45.8MB/s]
  3%|█▎                                   | 56.6M/1.64G [00:01<00:35, 44.3MB/s]
  4%|█▍                                   | 61.1M/1.64G [00:01<00:37, 41.8MB/s]
  4%|█▌                                   | 68.0M/1.64G [00:01<00:32, 48.8MB/s]
  4%|█▋                                   | 73.0M/1.64G [00:01<00:34, 45.1MB/s]
  5%|█▊                                   | 77.7M/1.64G [00:02<00:35, 44.4MB/s]
  5%|█▉                                   | 83.2M/1.64G [00:02<00:33, 47.0MB/s]
  6%|██                                   | 90.9M/1.64G [00:02<00:29, 53.0MB/s]
  6%|██▏                                  | 98.6M/1.64G [00:02<00:27, 56.6MB/s]
  6%|██▍                                   | 104M/1.64G [00:02<00:30, 50.6MB/s]
  7%|██▌                                   | 109M/1.64G [00:02<00:30, 50.4MB/s]
  7%|██▋                                   | 117M/1.64G [00:02<00:28, 54.2MB/s]
  7%|██▊                                   | 122M/1.64G [00:02<00:29, 51.9MB/s]
  8%|██▉                                   | 127M/1.64G [00:02<00:29, 51.0MB/s]
  8%|███                                   | 134M/1.64G [00:03<00:30, 50.0MB/s]
  9%|███▎                                  | 142M/1.64G [00:03<00:27, 54.8MB/s]
  9%|███▍                                  | 150M/1.64G [00:03<00:25, 58.3MB/s]
 10%|███▋                                  | 157M/1.64G [00:03<00:24, 60.8MB/s]
 10%|███▊                                  | 165M/1.64G [00:03<00:23, 62.5MB/s]
 11%|████                                  | 173M/1.64G [00:03<00:22, 63.7MB/s]
 11%|████▏                                 | 180M/1.64G [00:03<00:23, 61.4MB/s]
 11%|████▎                                 | 188M/1.64G [00:03<00:22, 63.1MB/s]
 12%|████▌                                 | 196M/1.64G [00:04<00:22, 64.1MB/s]
 12%|████▋                                 | 203M/1.64G [00:04<00:22, 64.8MB/s]
 13%|████▉                                 | 211M/1.64G [00:04<00:21, 65.3MB/s]
 13%|█████                                 | 219M/1.64G [00:04<00:21, 65.3MB/s]
 14%|█████▎                                | 226M/1.64G [00:04<00:21, 65.6MB/s]
 14%|█████▍                                | 234M/1.64G [00:04<00:21, 65.9MB/s]
 15%|█████▌                                | 241M/1.64G [00:04<00:22, 61.0MB/s]
 15%|█████▋                                | 247M/1.64G [00:04<00:24, 56.9MB/s]
 15%|█████▊                                | 253M/1.64G [00:05<00:26, 53.0MB/s]
 16%|██████                                | 261M/1.64G [00:05<00:23, 57.4MB/s]
 16%|██████▏                               | 267M/1.64G [00:05<00:26, 52.2MB/s]
 17%|██████▎                               | 272M/1.64G [00:05<00:32, 41.6MB/s]
 17%|██████▍                               | 276M/1.64G [00:05<00:32, 42.4MB/s]
 17%|██████▌                               | 284M/1.64G [00:05<00:27, 48.6MB/s]
 18%|██████▊                               | 292M/1.64G [00:05<00:25, 53.6MB/s]
 18%|██████▉                               | 299M/1.64G [00:05<00:27, 49.2MB/s]
 19%|███████                               | 307M/1.64G [00:06<00:24, 53.8MB/s]
 19%|███████▎                              | 313M/1.64G [00:06<00:23, 57.3MB/s]
 20%|███████▍                              | 319M/1.64G [00:06<00:23, 57.0MB/s]
 20%|███████▌                              | 326M/1.64G [00:06<00:22, 57.7MB/s]
 20%|███████▊                              | 334M/1.64G [00:06<00:21, 60.3MB/s]
 21%|███████▉                              | 341M/1.64G [00:06<00:20, 62.3MB/s]
 21%|████████                              | 349M/1.64G [00:06<00:20, 63.3MB/s]
 22%|████████▎                             | 356M/1.64G [00:06<00:21, 59.6MB/s]
 22%|████████▍                             | 362M/1.64G [00:07<00:21, 60.4MB/s]
 23%|████████▌                             | 370M/1.64G [00:07<00:20, 62.3MB/s]
 23%|████████▊                             | 378M/1.64G [00:07<00:19, 63.6MB/s]
 24%|████████▉                             | 386M/1.64G [00:07<00:19, 64.4MB/s]
 24%|█████████▏                            | 393M/1.64G [00:07<00:19, 65.0MB/s]
 25%|█████████▎                            | 401M/1.64G [00:07<00:18, 65.4MB/s]
 25%|█████████▍                            | 409M/1.64G [00:07<00:18, 65.6MB/s]
 25%|█████████▋                            | 416M/1.64G [00:07<00:18, 65.8MB/s]
 26%|█████████▊                            | 424M/1.64G [00:07<00:18, 65.7MB/s]
 26%|██████████                            | 432M/1.64G [00:08<00:18, 65.8MB/s]
 27%|██████████▏                           | 439M/1.64G [00:08<00:18, 66.1MB/s]
 27%|██████████▎                           | 447M/1.64G [00:08<00:17, 67.7MB/s]
 28%|██████████▌                           | 453M/1.64G [00:08<00:17, 66.0MB/s]
 28%|██████████▋                           | 460M/1.64G [00:08<00:17, 66.5MB/s]
 29%|██████████▊                           | 467M/1.64G [00:08<00:17, 66.3MB/s]
 29%|███████████                           | 474M/1.64G [00:08<00:17, 66.0MB/s]
 29%|███████████▏                          | 481M/1.64G [00:08<00:17, 66.1MB/s]
 30%|███████████▎                          | 488M/1.64G [00:08<00:17, 66.1MB/s]
 30%|███████████▌                          | 495M/1.64G [00:09<00:16, 67.2MB/s]
 31%|███████████▋                          | 502M/1.64G [00:09<00:20, 55.4MB/s]
 31%|███████████▊                          | 509M/1.64G [00:09<00:19, 57.3MB/s]
 32%|███████████▉                          | 516M/1.64G [00:09<00:18, 60.0MB/s]
 32%|████████████▏                         | 524M/1.64G [00:09<00:17, 62.0MB/s]
 32%|████████████▎                         | 530M/1.64G [00:09<00:20, 54.6MB/s]
 33%|████████████▍                         | 537M/1.64G [00:09<00:18, 58.3MB/s]
 33%|████████████▋                         | 543M/1.64G [00:09<00:18, 57.9MB/s]
 34%|████████████▊                         | 551M/1.64G [00:10<00:17, 60.5MB/s]
 34%|████████████▉                         | 559M/1.64G [00:10<00:17, 62.3MB/s]
 35%|█████████████▏                        | 567M/1.64G [00:10<00:16, 63.6MB/s]
 35%|█████████████▎                        | 574M/1.64G [00:10<00:16, 64.5MB/s]
 36%|█████████████▌                        | 582M/1.64G [00:10<00:15, 67.0MB/s]
 36%|█████████████▋                        | 589M/1.64G [00:10<00:16, 62.2MB/s]
 36%|█████████████▊                        | 595M/1.64G [00:10<00:17, 60.4MB/s]
 37%|█████████████▉                        | 601M/1.64G [00:10<00:25, 39.8MB/s]
 37%|██████████████▏                       | 609M/1.64G [00:11<00:22, 45.7MB/s]
 38%|██████████████▎                       | 617M/1.64G [00:11<00:20, 50.8MB/s]
 38%|██████████████▍                       | 624M/1.64G [00:11<00:20, 50.5MB/s]
 39%|██████████████▋                       | 632M/1.64G [00:11<00:18, 55.1MB/s]
 39%|██████████████▊                       | 640M/1.64G [00:11<00:17, 58.2MB/s]
 40%|███████████████                       | 647M/1.64G [00:11<00:16, 60.6MB/s]
 40%|███████████████▏                      | 655M/1.64G [00:11<00:15, 62.2MB/s]
 41%|███████████████▍                      | 663M/1.64G [00:11<00:15, 63.1MB/s]
 41%|███████████████▌                      | 669M/1.64G [00:12<00:16, 58.5MB/s]
 41%|███████████████▋                      | 675M/1.64G [00:12<00:19, 49.8MB/s]
 42%|███████████████▊                      | 683M/1.64G [00:12<00:17, 54.4MB/s]
 42%|████████████████                      | 691M/1.64G [00:12<00:16, 57.6MB/s]
 43%|████████████████▏                     | 698M/1.64G [00:12<00:15, 60.1MB/s]
 43%|████████████████▎                     | 705M/1.64G [00:12<00:18, 51.1MB/s]
 44%|████████████████▌                     | 712M/1.64G [00:12<00:16, 54.9MB/s]
 44%|████████████████▋                     | 720M/1.64G [00:13<00:15, 58.2MB/s]
 44%|████████████████▉                     | 728M/1.64G [00:13<00:15, 60.5MB/s]
 45%|█████████████████                     | 735M/1.64G [00:13<00:14, 62.2MB/s]
 45%|█████████████████▎                    | 743M/1.64G [00:13<00:14, 63.5MB/s]
 46%|█████████████████▍                    | 751M/1.64G [00:13<00:13, 64.5MB/s]
 46%|█████████████████▌                    | 759M/1.64G [00:13<00:13, 65.3MB/s]
 47%|█████████████████▊                    | 766M/1.64G [00:13<00:12, 68.2MB/s]
 47%|█████████████████▉                    | 773M/1.64G [00:13<00:12, 66.6MB/s]
 48%|██████████████████▏                   | 780M/1.64G [00:13<00:12, 67.6MB/s]
 48%|██████████████████▎                   | 787M/1.64G [00:14<00:12, 66.6MB/s]
 49%|██████████████████▍                   | 794M/1.64G [00:14<00:12, 65.1MB/s]
 49%|██████████████████▌                   | 801M/1.64G [00:14<00:12, 65.0MB/s]
 49%|██████████████████▊                   | 807M/1.64G [00:14<00:15, 52.0MB/s]
 50%|██████████████████▉                   | 815M/1.64G [00:14<00:14, 56.3MB/s]
 50%|███████████████████                   | 821M/1.64G [00:14<00:17, 45.5MB/s]
 51%|███████████████████▏                  | 828M/1.64G [00:14<00:15, 50.6MB/s]
 51%|███████████████████▍                  | 835M/1.64G [00:14<00:15, 53.1MB/s]
 51%|███████████████████▌                  | 840M/1.64G [00:15<00:15, 51.3MB/s]
 52%|███████████████████▋                  | 846M/1.64G [00:15<00:15, 52.4MB/s]
 52%|███████████████████▊                  | 854M/1.64G [00:15<00:13, 56.7MB/s]
 53%|████████████████████                  | 862M/1.64G [00:15<00:13, 59.5MB/s]
 53%|████████████████████▏                 | 869M/1.64G [00:15<00:12, 61.5MB/s]
 54%|████████████████████▍                 | 877M/1.64G [00:15<00:12, 63.0MB/s]
 54%|████████████████████▌                 | 885M/1.64G [00:15<00:11, 64.1MB/s]
 54%|████████████████████▋                 | 891M/1.64G [00:15<00:13, 53.7MB/s]
 55%|████████████████████▊                 | 897M/1.64G [00:16<00:14, 51.8MB/s]
 55%|████████████████████▉                 | 902M/1.64G [00:16<00:14, 51.0MB/s]
 55%|█████████████████████                 | 907M/1.64G [00:16<00:16, 44.0MB/s]
 56%|█████████████████████▏                | 913M/1.64G [00:16<00:16, 44.4MB/s]
 56%|█████████████████████▍                | 921M/1.64G [00:16<00:14, 50.6MB/s]
 57%|█████████████████████▌                | 929M/1.64G [00:16<00:12, 55.1MB/s]
 57%|█████████████████████▋                | 935M/1.64G [00:16<00:14, 46.9MB/s]
 58%|█████████████████████▉                | 943M/1.64G [00:16<00:13, 52.4MB/s]
 58%|██████████████████████                | 951M/1.64G [00:17<00:12, 55.9MB/s]
 59%|██████████████████████▎               | 959M/1.64G [00:17<00:11, 58.9MB/s]
 59%|██████████████████████▍               | 966M/1.64G [00:17<00:10, 61.1MB/s]
 60%|██████████████████████▋               | 974M/1.64G [00:17<00:10, 62.7MB/s]
 60%|██████████████████████▊               | 982M/1.64G [00:17<00:10, 63.7MB/s]
 60%|██████████████████████▉               | 988M/1.64G [00:17<00:10, 59.7MB/s]
 61%|███████████████████████               | 995M/1.64G [00:17<00:10, 59.8MB/s]
 61%|██████████████████████▋              | 1.00G/1.64G [00:17<00:10, 61.7MB/s]
 62%|██████████████████████▊              | 1.01G/1.64G [00:18<00:09, 63.1MB/s]
 62%|███████████████████████              | 1.02G/1.64G [00:18<00:09, 64.1MB/s]
 63%|███████████████████████▏             | 1.03G/1.64G [00:18<00:09, 64.5MB/s]
 63%|███████████████████████▎             | 1.03G/1.64G [00:18<00:09, 65.4MB/s]
 64%|███████████████████████▌             | 1.04G/1.64G [00:18<00:09, 65.7MB/s]
 64%|███████████████████████▋             | 1.05G/1.64G [00:18<00:08, 66.0MB/s]
 65%|███████████████████████▉             | 1.06G/1.64G [00:18<00:08, 66.1MB/s]
 65%|████████████████████████             | 1.06G/1.64G [00:18<00:09, 62.8MB/s]
 65%|████████████████████████▏            | 1.07G/1.64G [00:19<00:10, 52.9MB/s]
 66%|████████████████████████▎            | 1.08G/1.64G [00:19<00:10, 52.1MB/s]
 66%|████████████████████████▌            | 1.08G/1.64G [00:19<00:09, 56.1MB/s]
 67%|████████████████████████▋            | 1.09G/1.64G [00:19<00:09, 59.1MB/s]
 67%|████████████████████████▊            | 1.10G/1.64G [00:19<00:08, 61.2MB/s]
 68%|█████████████████████████            | 1.11G/1.64G [00:19<00:08, 62.6MB/s]
 68%|█████████████████████████▏           | 1.11G/1.64G [00:19<00:11, 46.7MB/s]
 69%|█████████████████████████▎           | 1.12G/1.64G [00:19<00:09, 51.8MB/s]
 69%|█████████████████████████▌           | 1.13G/1.64G [00:20<00:09, 55.6MB/s]
 69%|█████████████████████████▋           | 1.14G/1.64G [00:20<00:10, 48.3MB/s]
 70%|█████████████████████████▊           | 1.14G/1.64G [00:20<00:09, 53.0MB/s]
 70%|█████████████████████████▉           | 1.15G/1.64G [00:20<00:11, 40.7MB/s]
 71%|██████████████████████████▏          | 1.16G/1.64G [00:20<00:10, 44.5MB/s]
 71%|██████████████████████████▏          | 1.16G/1.64G [00:20<00:12, 36.7MB/s]
 71%|██████████████████████████▍          | 1.17G/1.64G [00:21<00:11, 42.0MB/s]
 72%|██████████████████████████▌          | 1.17G/1.64G [00:21<00:11, 38.8MB/s]
 72%|██████████████████████████▋          | 1.18G/1.64G [00:21<00:10, 45.4MB/s]
 73%|██████████████████████████▊          | 1.19G/1.64G [00:21<00:08, 50.8MB/s]
 73%|███████████████████████████          | 1.20G/1.64G [00:21<00:07, 55.1MB/s]
 74%|███████████████████████████▏         | 1.20G/1.64G [00:21<00:07, 58.1MB/s]
 74%|███████████████████████████▍         | 1.21G/1.64G [00:21<00:07, 60.5MB/s]
 75%|███████████████████████████▌         | 1.22G/1.64G [00:21<00:06, 62.3MB/s]
 75%|███████████████████████████▋         | 1.23G/1.64G [00:22<00:06, 63.6MB/s]
 75%|███████████████████████████▉         | 1.23G/1.64G [00:22<00:07, 53.4MB/s]
 76%|████████████████████████████         | 1.24G/1.64G [00:22<00:07, 54.8MB/s]
 76%|████████████████████████████▏        | 1.25G/1.64G [00:22<00:09, 39.4MB/s]
 77%|████████████████████████████▎        | 1.25G/1.64G [00:22<00:08, 43.3MB/s]
 77%|████████████████████████████▍        | 1.26G/1.64G [00:22<00:07, 49.2MB/s]
 77%|████████████████████████████▌        | 1.26G/1.64G [00:22<00:08, 44.6MB/s]
 78%|████████████████████████████▊        | 1.27G/1.64G [00:23<00:07, 50.2MB/s]
 78%|████████████████████████████▉        | 1.28G/1.64G [00:23<00:06, 54.6MB/s]
 79%|█████████████████████████████        | 1.29G/1.64G [00:23<00:06, 53.6MB/s]
 79%|█████████████████████████████▏       | 1.29G/1.64G [00:23<00:06, 53.8MB/s]
 79%|█████████████████████████████▍       | 1.30G/1.64G [00:23<00:05, 57.3MB/s]
 80%|█████████████████████████████▌       | 1.31G/1.64G [00:23<00:05, 60.1MB/s]
 80%|█████████████████████████████▋       | 1.31G/1.64G [00:23<00:06, 53.6MB/s]
 81%|█████████████████████████████▊       | 1.32G/1.64G [00:23<00:05, 54.5MB/s]
 81%|█████████████████████████████▉       | 1.32G/1.64G [00:24<00:07, 43.2MB/s]
 81%|██████████████████████████████       | 1.33G/1.64G [00:24<00:06, 48.1MB/s]
 82%|██████████████████████████████▎      | 1.34G/1.64G [00:24<00:05, 55.0MB/s]
 82%|██████████████████████████████▍      | 1.35G/1.64G [00:24<00:05, 57.7MB/s]
 83%|██████████████████████████████▌      | 1.35G/1.64G [00:24<00:04, 62.4MB/s]
 83%|██████████████████████████████▊      | 1.36G/1.64G [00:24<00:04, 57.7MB/s]
 84%|██████████████████████████████▉      | 1.37G/1.64G [00:24<00:05, 49.2MB/s]
 84%|███████████████████████████████      | 1.37G/1.64G [00:24<00:04, 55.2MB/s]
 84%|███████████████████████████████▏     | 1.38G/1.64G [00:25<00:04, 55.3MB/s]
 85%|███████████████████████████████▎     | 1.39G/1.64G [00:25<00:04, 56.3MB/s]
 85%|███████████████████████████████▌     | 1.39G/1.64G [00:25<00:04, 59.5MB/s]
 86%|███████████████████████████████▋     | 1.40G/1.64G [00:25<00:03, 61.7MB/s]
 86%|███████████████████████████████▊     | 1.41G/1.64G [00:25<00:03, 60.7MB/s]
 87%|████████████████████████████████     | 1.42G/1.64G [00:25<00:03, 64.1MB/s]
 87%|████████████████████████████████▏    | 1.42G/1.64G [00:25<00:03, 65.0MB/s]
 87%|████████████████████████████████▎    | 1.43G/1.64G [00:25<00:03, 65.2MB/s]
 88%|████████████████████████████████▌    | 1.44G/1.64G [00:25<00:03, 63.9MB/s]
 88%|████████████████████████████████▋    | 1.44G/1.64G [00:26<00:03, 63.8MB/s]
 89%|████████████████████████████████▊    | 1.45G/1.64G [00:26<00:02, 66.6MB/s]
 89%|████████████████████████████████▉    | 1.46G/1.64G [00:26<00:02, 65.2MB/s]
 90%|█████████████████████████████████▏   | 1.46G/1.64G [00:26<00:02, 64.2MB/s]
 90%|█████████████████████████████████▎   | 1.47G/1.64G [00:26<00:02, 63.7MB/s]
 90%|█████████████████████████████████▍   | 1.48G/1.64G [00:26<00:02, 67.0MB/s]
 91%|█████████████████████████████████▌   | 1.49G/1.64G [00:26<00:02, 66.9MB/s]
 91%|█████████████████████████████████▊   | 1.49G/1.64G [00:26<00:02, 66.4MB/s]
 92%|█████████████████████████████████▉   | 1.50G/1.64G [00:26<00:02, 65.2MB/s]
 92%|██████████████████████████████████   | 1.51G/1.64G [00:26<00:02, 64.3MB/s]
 93%|██████████████████████████████████▏  | 1.51G/1.64G [00:27<00:01, 65.0MB/s]
 93%|██████████████████████████████████▍  | 1.52G/1.64G [00:27<00:01, 65.4MB/s]
 93%|██████████████████████████████████▌  | 1.53G/1.64G [00:27<00:01, 65.6MB/s]
 94%|██████████████████████████████████▊  | 1.54G/1.64G [00:27<00:01, 65.6MB/s]
 94%|██████████████████████████████████▉  | 1.54G/1.64G [00:27<00:01, 65.9MB/s]
 95%|███████████████████████████████████  | 1.55G/1.64G [00:27<00:01, 66.1MB/s]
 95%|███████████████████████████████████▎ | 1.56G/1.64G [00:27<00:01, 68.1MB/s]
 96%|███████████████████████████████████▍ | 1.57G/1.64G [00:27<00:00, 69.4MB/s]
 96%|███████████████████████████████████▌ | 1.57G/1.64G [00:28<00:01, 50.5MB/s]
 97%|███████████████████████████████████▊ | 1.58G/1.64G [00:28<00:00, 54.5MB/s]
 97%|███████████████████████████████████▉ | 1.59G/1.64G [00:28<00:00, 57.8MB/s]
 98%|████████████████████████████████████▏| 1.60G/1.64G [00:28<00:00, 60.2MB/s]
 98%|████████████████████████████████████▎| 1.60G/1.64G [00:28<00:00, 61.9MB/s]
 99%|████████████████████████████████████▍| 1.61G/1.64G [00:28<00:00, 63.0MB/s]
 99%|████████████████████████████████████▋| 1.62G/1.64G [00:28<00:00, 64.4MB/s]
100%|████████████████████████████████████▊| 1.63G/1.64G [00:28<00:00, 65.0MB/s]
100%|████████████████████████████████████▉| 1.64G/1.64G [00:29<00:00, 65.4MB/s]
  0%|                                              | 0.00/1.64G [00:00<?, ?B/s]
100%|█████████████████████████████████████| 1.64G/1.64G [00:00<00:00, 16.7TB/s]
Untarring contents of '/home/runner/mne_data/bst_auditory.tar.gz' to '/home/runner/mne_data/MNE-brainstorm-data'
Events from run 1:
     onset  duration  id label
0     7625      2776   1   BAD
1   142459       892   1   BAD
2   216954       460   1   BAD
3   345135      5816   1   BAD
4   357687      1053   1   BAD
5   409101      3736   1   BAD
6   461110       179   1   BAD
7   479866       426   1   BAD
8   764914     11500   1   BAD
9   798174      6589   1   BAD
10  846880      5383   1   BAD
11  858863      5136   1   BAD
General
Filename(s) S01_AEF_20131218_01.meg4
MNE object type RawCTF
Measurement date 2013-12-18 at 09:43:00 UTC
Participant S01
Experimenter EAB
Acquisition
Duration 00:06:00 (HH:MM:SS)
Sampling frequency 2400.00 Hz
Time points 864,000
Channels
Magnetometers and
EEG
misc
Reference Magnetometers
Stimulus
Head & sensor digitization 263 points
Filters
Highpass 0.00 Hz
Lowpass 1200.00 Hz


Event preprocessing: In this dataset, triggers can be adjusted by using a recording of the audio that was presented.

# Events are the presentation times of the audio stimuli: UPPT001
event_fname = data_path / 'MEG' / 'bst_auditory' / 'S01_AEF_20131218_01-eve.fif'
events = mne.find_events(raw, stim_channel='UPPT001')

# The event timing is adjusted by comparing the trigger times on detected sound onsets on channel UADC001-4408
sound_data = raw[raw.ch_names.index('UADC001-4408')][0][0]
onsets = np.where(np.abs(sound_data) > 2. * np.std(sound_data))[0]
min_diff = int(0.5 * raw.info['sfreq'])
diffs = np.concatenate([[min_diff + 1], np.diff(onsets)])
onsets = onsets[diffs > min_diff]
assert len(onsets) == len(events)
diffs = 1000. * (events[:, 0] - onsets) / raw.info['sfreq']
print(f'Trigger delay removed (μ ± σ): {diffs.mean():.1f} ± {diffs.std():.1f} ms')

# Since event onsets are stored in samples
event_sfreq = raw.info['sfreq']

# DataFrame for sound events
sound_events = pd.DataFrame({
    'onset': onsets,
    'time': onsets / event_sfreq,
    'duration': np.ones(len(onsets)),
    'id': events[:, 2],
    'label': pd.Categorical.from_codes(events[:, 2], ['', 'frequent', 'infrequent']),
})
sound_events
Trigger delay removed (μ ± σ): -13.9 ± 0.3 ms
onset time duration id label
0 13628 5.678333 1.0 1 frequent
1 16961 7.067083 1.0 1 frequent
2 20925 8.718750 1.0 1 frequent
3 24203 10.084583 1.0 1 frequent
4 28159 11.732917 1.0 1 frequent
... ... ... ... ... ...
235 737274 307.197500 1.0 2 infrequent
236 740140 308.391667 1.0 1 frequent
237 744178 310.074167 1.0 2 infrequent
238 746839 311.182917 1.0 1 frequent
239 749740 312.391667 1.0 2 infrequent

240 rows × 5 columns



Visualize the event related fields (ERFs) for the two types of stimuli (frequent and infrequent beeps). This is just to get a quick impression of the data, and to check if the event timing is correct.

events[:, 0] = onsets  # Adjust event onsets
event_id = dict(frequent=1, infrequent=2)
reject = dict(mag=4e-12)
epochs = mne.Epochs(raw.copy().load_data().filter(1, 25.0), events, event_id, reject=reject, picks='mag', reject_by_annotation=True, preload=True)
epochs.add_proj(eog_proj)  # Add EOG projectors to epochs
epochs.apply_proj()  # Apply projectors to epochs
evoked_ndvar = [eelbrain.load.mne.epochs_ndvar(epochs[name], data='mag', name=name).mean('case')
                for name in ('frequent', 'infrequent')]
evoked_ndvar.append((evoked_ndvar[1] - evoked_ndvar[0]).copy('contrast'))
p = eelbrain.plot.TopoButterfly(evoked_ndvar, t=.190, ylabel=False, vmax=300e-15)
00 example vol src

Preprocess MEG Data: low pass filtering, power line attenuation, downsampling, etc.

raw.add_proj(eog_proj).apply_proj()  # Add EOG projectors to raw data
# Notch filter for power line artifact
raw.load_data()
raw.notch_filter(np.arange(60, 181, 60), fir_design='firwin')

# Band pass filtering 1-20 Hz
raw.filter(1.0, 20.0, fir_design='firwin')

# Crop relative to sound events
tmin = sound_events['time'].min() - 0.2
tmax = sound_events['time'].max() + 1.0
raw.crop(tmin, tmax)

# Resample to 100 Hz
raw.resample(100, npad="auto")

# `raw` remembers the original time axis, consistent with events
raw.first_time
5.48

Convert MEG data to eelbrain.NDVar for NCRF estimation.

meg = eelbrain.load.mne.raw_ndvar(raw)
# Time axis is preserved (t_start, t_step, n_samples)
meg.time
UTS(5.48, 0.01, 30791)

Continuous stimulus variable construction

After loading and preprocessing the raw data, we will construct predictor variables for this particular experiment. Here, we construct predictor variables by placing an impulse at every stimulus tone onset. Note that the predictor variable and MEG response should have the same time axis.

In this example, we use two different predictor variables: For the common response to any tone, we put impulses at the presentation times of both the audio stimuli (i.e., frequent and infrequent beeps). To distinguish infrequent from frequent beeps (i.e., contrast), we assign 1 and -1 impulses to infrequent and frequent beeps, respectively (contrast coding).

# Create an all-zero NDVar with time axis matching the MEG data
stim1 = eelbrain.NDVar.zeros(meg.time, 'common')
# Set values at time points for any sound to 1.
stim1[sound_events['time'].values] = 1.  # [Common]

# To contrast infrequent from frequent beeps, we assign 1 and -1 impulses,
# respectively
stim2 = stim1.copy('contrast')
frequent_index = sound_events['label'] == 'frequent'
stim2[sound_events['time'].values[frequent_index]] = -1  # [Contrast]

# Visualize the predictors
p = eelbrain.plot.UTS([stim1, stim2], color='black', stem=True, frame='none',
                      w=10, h=2.5, legend=False)
common, contrast

Noise covariance estimation

Here we estimate the noise covariance from empty room data.

noise_path = data_path / 'MEG' / 'bst_auditory' / 'S01_Noise_20131218_01.ds'
raw_empty_room = mne.io.read_raw_ctf(noise_path, preload=True)

# Apply the same pre-processing steps to empty room data
raw_empty_room.add_proj(eog_proj)

raw_empty_room.notch_filter(np.arange(60, 181, 60), fir_design='firwin')

raw_empty_room.filter(1.0, 20.0, fir_design='firwin')

raw_empty_room.resample(100, npad="auto")

# Compute the noise covariance matrix
noise_cov = mne.compute_raw_covariance(raw_empty_room, tmin=0, tmax=None,
                                       method='shrunk', rank=None)

Forward model (aka lead-field matrix)

Create a volume source space based on a 10 mm voxel grid.

# The paths to FreeSurfer reconstructions
subjects_dir = data_path / 'subjects'
subject = 'bst_auditory'

# The transformation file obtained by coregistration
trans = data_path / 'MEG' / 'bst_auditory' / 'bst_auditory-trans.fif'

# Uncomment for visualization
# mne.viz.plot_alignment(raw.info, trans, subject=subject, dig=True,
#                        meg=['helmet', 'sensors'], subjects_dir=subjects_dir,
#                        surfaces='head')

# Cache/reload the source space for faster execution
srcfile = subjects_dir / 'bst_auditory' / 'bem' / 'bst_auditory-vol-10-src.fif'
if srcfile.is_file():
    src = mne.read_source_spaces(srcfile)
else:
    surface = subjects_dir / subject / "bem" / "inner_skull.surf"
    src = mne.setup_volume_source_space(subject,
                                        subjects_dir=subjects_dir,
                                        surface=surface,
                                        pos=10.0,
                                        add_interpolator=True)
    mne.write_source_spaces(srcfile, src, overwrite=True)  # needed for smoothing

# Visualize the source space
fig = mne.viz.plot_bem(subject,
                       subjects_dir,
                       'coronal',
                       brain_surfaces='white',
                       src=src)
00 example vol src

Compute the forward solution:

fwdfile = subjects_dir / 'bst_auditory' / 'bem' / 'bst_auditory-vol-10-fwd.fif'
if fwdfile.is_file():
    fwd = mne.read_forward_solution(fwdfile)
else:
    conductivity = (0.3,)  # for single layer
    # conductivity = (0.3, 0.006, 0.3)  # for three layers
    model = mne.make_bem_model(subject=subject, ico=4,
                               conductivity=conductivity,
                               subjects_dir=subjects_dir)
    bem = mne.make_bem_solution(model)

    fwd = mne.make_forward_solution(raw.info, trans=trans, src=src, bem=bem,
                                    meg=True, eeg=False, mindist=5.0, n_jobs=2)
    mne.write_forward_solution(fwdfile, fwd)

fwd
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    1.1s finished
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    0.5s finished
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    0.5s finished
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    0.2s finished
[Parallel(n_jobs=2)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=2)]: Done   2 out of   2 | elapsed:    0.1s finished
Forward
Magnetometers and
Source space Volume with 1653 grid points
Source orientation Free


Extract the leadfield matrix as eelbrain.NDVar

NCRF estimation

Now we have all the required data to estimate NCRFs.

Note

This example uses simplified settings to speed up estimation:

1) For this example, we use a fixed regularization parameter (mu). For a real experiment, the optimal mu can be determined by cross-validation (set mu='auto', which is the default). The optimal mu will then be stored in model.mu (this is how the mu used here was determined).

2) The example forces the estimation to stop after fewer iterations than is recommended (n_iter). For stable models, we recommend to use the default setting (n_iter=10).

# To speed up the example, we cache the NCRF
ncrf_file = data_path / 'MEG' / 'bst_auditory' / 'oddball_ncrf_vol.pickle'
if ncrf_file.exists():
    model = eelbrain.load.unpickle(ncrf_file)
else:
    model = fit_ncrf(
        meg, [stim1, stim2], lf, noise_cov, tstart=0, tstop=0.5,
        mu=4.958456130470556e-06, n_iter=5,
        # mu='auto', n_iter=5,
    )
    eelbrain.save.pickle(model, ncrf_file)
model
<[free orientation] cTRFs estimator on <VolumeSourceSpace [1653], 'bst_auditory', 'vol-10', parc=aparc+aseg>>

The learned kernel/filter (the NCRF) can be accessed as an attribute of the model. NCRFs are stored as eelbrain.NDVar. Here, the two NCRFs correspond to the two different predictor variables:

[<NDVar 'common': 1653 source, 3 space, 51 time>, <NDVar 'contrast': 1653 source, 3 space, 51 time>]

Visualization

A butterfly plot shows weights in all sources over time. This is good for forming a quick impression of important time lags, or peaks in the response:

Note

Since the estimates are sparse over cortical locations, smoothing the NCRFs over sources makes the visualization more intuitive.

hs_orig = [h.smooth('source', 0.01, 'gaussian') for h in model.h]
p = eelbrain.plot.Butterfly([h.norm('space') for h in hs_orig],
                            axtitle=['Common', 'Contrast'], rows=1)
Common, Contrast

We can visualize anatomical locations of the peaks with 2D projections of NCRFs using glass-brain plots. The function eelbrain.plot.GlassBrain: visualizes a single time point in that fashion. For brain activations to align with a schematic brain overlay, the plotted image should be in MNI coordinate space. Hence, we will first morph the NCRFs to the fsaverage brain, which is in MNI space.

mne.datasets.fetch_fsaverage(subjects_dir)
fname_src_fsaverage = subjects_dir / "fsaverage" / "bem" / "fsaverage-vol-5-src.fif"
src_fs = mne.read_source_spaces(fname_src_fsaverage)
morph = mne.compute_source_morph(
    fwd["src"],
    subject_from=subject,
    subjects_dir=subjects_dir,
    niter_affine=[10, 10, 5],
    niter_sdr=[10, 10, 5],  # just for speed
    src_to=src_fs,
    verbose=True,
)
def morph_to_fsaverage(h):
    data = h.get_data(('source', 'space', 'time'))
    time = h.get_dim('time')
    stc = mne.VolVectorSourceEstimate(data, [fwd['src'][0]['vertno']],
                                      time.tmin, time.tstep, subject)
    stc_fsaverage = morph.apply(stc)
    return eelbrain.load.mne.stc_ndvar(stc_fsaverage, 'fsaverage', 'vol-5')
hs = [morph_to_fsaverage(h) for h in hs_orig]
Downloading data from 'https://osf.io/download/3bxqt?version=2' to file '/tmp/tmplkeelqec/temp.zip'.

  0%|                                               | 0.00/196M [00:00<?, ?B/s]
  0%|                                       | 48.1k/196M [00:00<08:06, 402kB/s]
  0%|                                        | 130k/196M [00:00<05:15, 619kB/s]
  0%|                                       | 343k/196M [00:00<02:33, 1.27MB/s]
  1%|▏                                      | 982k/196M [00:00<01:00, 3.23MB/s]
  2%|▌                                     | 3.06M/196M [00:00<00:20, 9.40MB/s]
  4%|█▍                                    | 7.48M/196M [00:00<00:08, 21.1MB/s]
  6%|██▎                                   | 11.6M/196M [00:00<00:06, 27.7MB/s]
  8%|███                                   | 16.0M/196M [00:00<00:05, 31.6MB/s]
 11%|████                                  | 20.7M/196M [00:00<00:04, 35.7MB/s]
 13%|████▉                                 | 25.2M/196M [00:01<00:04, 38.6MB/s]
 15%|█████▋                                | 29.3M/196M [00:01<00:04, 39.1MB/s]
 17%|██████▌                               | 33.6M/196M [00:01<00:04, 39.7MB/s]
 20%|███████▍                              | 38.4M/196M [00:01<00:03, 41.3MB/s]
 22%|████████▎                             | 42.6M/196M [00:01<00:03, 41.3MB/s]
 24%|█████████▏                            | 47.0M/196M [00:01<00:03, 42.1MB/s]
 26%|█████████▉                            | 51.3M/196M [00:01<00:03, 41.7MB/s]
 29%|██████████▉                           | 56.1M/196M [00:01<00:03, 43.1MB/s]
 31%|███████████▋                          | 60.4M/196M [00:01<00:03, 42.8MB/s]
 33%|████████████▌                         | 64.7M/196M [00:01<00:03, 41.7MB/s]
 35%|█████████████▍                        | 69.2M/196M [00:02<00:03, 41.2MB/s]
 38%|██████████████▍                       | 74.3M/196M [00:02<00:02, 41.6MB/s]
 40%|███████████████▍                      | 79.2M/196M [00:02<00:02, 43.8MB/s]
 43%|████████████████▏                     | 83.7M/196M [00:02<00:02, 44.1MB/s]
 45%|█████████████████                     | 88.1M/196M [00:02<00:02, 42.3MB/s]
 47%|█████████████████▉                    | 92.4M/196M [00:02<00:02, 41.6MB/s]
 50%|██████████████████▊                   | 96.9M/196M [00:02<00:02, 41.5MB/s]
 52%|████████████████████▎                  | 102M/196M [00:02<00:02, 43.1MB/s]
 54%|█████████████████████▏                 | 106M/196M [00:02<00:02, 42.4MB/s]
 56%|█████████████████████▉                 | 110M/196M [00:03<00:02, 41.0MB/s]
 59%|██████████████████████▉                | 115M/196M [00:03<00:01, 41.2MB/s]
 61%|███████████████████████▊               | 120M/196M [00:03<00:01, 42.6MB/s]
 64%|████████████████████████▊              | 124M/196M [00:03<00:01, 43.6MB/s]
 66%|█████████████████████████▋             | 129M/196M [00:03<00:01, 42.3MB/s]
 68%|██████████████████████████▍            | 133M/196M [00:03<00:01, 41.8MB/s]
 70%|███████████████████████████▍           | 138M/196M [00:03<00:01, 42.3MB/s]
 73%|████████████████████████████▎          | 142M/196M [00:03<00:01, 43.6MB/s]
 75%|█████████████████████████████▏         | 147M/196M [00:03<00:01, 43.6MB/s]
 77%|██████████████████████████████         | 151M/196M [00:04<00:01, 42.9MB/s]
 79%|██████████████████████████████▉        | 155M/196M [00:04<00:00, 42.7MB/s]
 82%|███████████████████████████████▊       | 160M/196M [00:04<00:00, 43.3MB/s]
 84%|████████████████████████████████▋      | 164M/196M [00:04<00:00, 43.1MB/s]
 86%|█████████████████████████████████▌     | 169M/196M [00:04<00:00, 42.4MB/s]
 89%|██████████████████████████████████▌    | 173M/196M [00:04<00:00, 42.6MB/s]
 91%|███████████████████████████████████▍   | 178M/196M [00:04<00:00, 43.2MB/s]
 93%|████████████████████████████████████▎  | 182M/196M [00:04<00:00, 43.2MB/s]
 95%|█████████████████████████████████████▏ | 187M/196M [00:04<00:00, 42.4MB/s]
 98%|██████████████████████████████████████▏| 191M/196M [00:04<00:00, 43.5MB/s]
  0%|                                               | 0.00/196M [00:00<?, ?B/s]
100%|███████████████████████████████████████| 196M/196M [00:00<00:00, 1.11TB/s]
Downloading data from 'https://osf.io/download/7ve8g?version=4' to file '/tmp/tmphytou1br/temp.zip'.

  0%|                                               | 0.00/239M [00:00<?, ?B/s]
  0%|                                       | 48.1k/239M [00:00<09:04, 439kB/s]
  0%|                                        | 133k/239M [00:00<05:56, 670kB/s]
  0%|                                       | 343k/239M [00:00<03:03, 1.30MB/s]
  0%|▏                                      | 998k/239M [00:00<01:11, 3.32MB/s]
  1%|▍                                     | 3.06M/239M [00:00<00:24, 9.45MB/s]
  4%|█▎                                    | 8.37M/239M [00:00<00:09, 24.1MB/s]
  6%|██▏                                   | 14.1M/239M [00:00<00:06, 34.9MB/s]
  8%|███▏                                  | 19.9M/239M [00:00<00:05, 42.2MB/s]
 11%|████                                  | 25.3M/239M [00:00<00:04, 45.8MB/s]
 13%|████▉                                 | 31.1M/239M [00:01<00:04, 49.6MB/s]
 15%|█████▊                                | 36.8M/239M [00:01<00:03, 51.8MB/s]
 18%|██████▊                               | 42.5M/239M [00:01<00:03, 53.4MB/s]
 20%|███████▋                              | 48.2M/239M [00:01<00:03, 54.1MB/s]
 23%|████████▌                             | 53.9M/239M [00:01<00:03, 55.1MB/s]
 25%|█████████▍                            | 59.6M/239M [00:01<00:03, 55.6MB/s]
 27%|██████████▍                           | 65.2M/239M [00:01<00:03, 55.8MB/s]
 30%|███████████▎                          | 70.9M/239M [00:01<00:02, 56.0MB/s]
 32%|████████████▏                         | 76.5M/239M [00:01<00:02, 56.1MB/s]
 34%|█████████████                         | 82.3M/239M [00:01<00:02, 56.5MB/s]
 37%|█████████████▉                        | 87.9M/239M [00:02<00:02, 56.1MB/s]
 39%|██████████████▉                       | 93.6M/239M [00:02<00:02, 56.4MB/s]
 42%|███████████████▊                      | 99.3M/239M [00:02<00:02, 56.3MB/s]
 44%|█████████████████▏                     | 105M/239M [00:02<00:02, 55.7MB/s]
 46%|██████████████████                     | 111M/239M [00:02<00:02, 55.9MB/s]
 49%|██████████████████▉                    | 116M/239M [00:02<00:02, 56.1MB/s]
 51%|███████████████████▉                   | 122M/239M [00:02<00:02, 56.5MB/s]
 54%|████████████████████▊                  | 128M/239M [00:02<00:01, 56.8MB/s]
 56%|█████████████████████▊                 | 133M/239M [00:02<00:01, 56.8MB/s]
 58%|██████████████████████▋                | 139M/239M [00:02<00:01, 56.1MB/s]
 61%|███████████████████████▋               | 145M/239M [00:03<00:01, 54.6MB/s]
 63%|████████████████████████▌              | 150M/239M [00:03<00:01, 55.2MB/s]
 65%|█████████████████████████▍             | 156M/239M [00:03<00:01, 55.7MB/s]
 68%|██████████████████████████▍            | 162M/239M [00:03<00:01, 55.8MB/s]
 70%|███████████████████████████▎           | 167M/239M [00:03<00:01, 56.3MB/s]
 72%|████████████████████████████▎          | 173M/239M [00:03<00:01, 56.3MB/s]
 75%|█████████████████████████████▏         | 179M/239M [00:03<00:01, 56.1MB/s]
 77%|██████████████████████████████▏        | 185M/239M [00:03<00:00, 56.6MB/s]
 80%|███████████████████████████████        | 190M/239M [00:03<00:00, 56.6MB/s]
 82%|███████████████████████████████▉       | 196M/239M [00:03<00:00, 56.0MB/s]
 84%|████████████████████████████████▉      | 202M/239M [00:04<00:00, 56.1MB/s]
 87%|█████████████████████████████████▊     | 207M/239M [00:04<00:00, 56.3MB/s]
 89%|██████████████████████████████████▊    | 213M/239M [00:04<00:00, 54.5MB/s]
 92%|███████████████████████████████████▋   | 219M/239M [00:04<00:00, 55.2MB/s]
 94%|████████████████████████████████████▋  | 224M/239M [00:04<00:00, 56.1MB/s]
 96%|█████████████████████████████████████▌ | 230M/239M [00:04<00:00, 56.2MB/s]
 99%|██████████████████████████████████████▍| 236M/239M [00:04<00:00, 56.4MB/s]
  0%|                                               | 0.00/239M [00:00<?, ?B/s]
100%|███████████████████████████████████████| 239M/239M [00:00<00:00, 2.43TB/s]
[2026-06-13 00:48:29][dipy] INFO: ➞ Running center_of_mass step from affine registration...
[2026-06-13 00:48:29][dipy] INFO: ➞ Running translation step from affine registration...
[2026-06-13 00:48:30][dipy] INFO: ➞ Running rigid step from affine registration...
[2026-06-13 00:48:30][dipy] INFO: ➞ Running affine step from affine registration...
[2026-06-13 00:48:31][dipy] INFO: Creating scale space from the moving image. Levels: 3. Sigma factor: 0.200000.
[2026-06-13 00:48:31][dipy] INFO: Creating scale space from the static image. Levels: 3. Sigma factor: 0.200000.
[2026-06-13 00:48:31][dipy] INFO: Optimizing level 2
[2026-06-13 00:48:31][dipy] INFO: Optimizing level 1
[2026-06-13 00:48:31][dipy] INFO: Optimizing level 0

  0%|          | Ori × Time : 0/153 [00:00<?,       ?it/s]
  1%|          | Ori × Time : 1/153 [00:00<00:07,   20.90it/s]
  1%|▏         | Ori × Time : 2/153 [00:00<00:06,   22.42it/s]
  2%|▏         | Ori × Time : 3/153 [00:00<00:06,   23.06it/s]
  3%|▎         | Ori × Time : 4/153 [00:00<00:06,   23.18it/s]
  3%|▎         | Ori × Time : 5/153 [00:00<00:06,   23.36it/s]
  4%|▍         | Ori × Time : 6/153 [00:00<00:06,   23.41it/s]
  5%|▍         | Ori × Time : 7/153 [00:00<00:06,   23.51it/s]
  5%|▌         | Ori × Time : 8/153 [00:00<00:06,   23.54it/s]
  6%|▌         | Ori × Time : 9/153 [00:00<00:06,   23.70it/s]
  7%|▋         | Ori × Time : 10/153 [00:00<00:06,   23.69it/s]
  7%|▋         | Ori × Time : 11/153 [00:00<00:05,   23.77it/s]
  8%|▊         | Ori × Time : 12/153 [00:00<00:05,   23.90it/s]
  8%|▊         | Ori × Time : 13/153 [00:00<00:05,   24.01it/s]
  9%|▉         | Ori × Time : 14/153 [00:00<00:05,   24.02it/s]
 10%|▉         | Ori × Time : 15/153 [00:00<00:05,   24.13it/s]
 10%|█         | Ori × Time : 16/153 [00:00<00:05,   24.14it/s]
 11%|█         | Ori × Time : 17/153 [00:00<00:05,   24.05it/s]
 12%|█▏        | Ori × Time : 18/153 [00:00<00:05,   24.11it/s]
 12%|█▏        | Ori × Time : 19/153 [00:00<00:05,   24.13it/s]
 13%|█▎        | Ori × Time : 20/153 [00:00<00:05,   24.17it/s]
 14%|█▎        | Ori × Time : 21/153 [00:00<00:05,   24.18it/s]
 14%|█▍        | Ori × Time : 22/153 [00:00<00:05,   24.25it/s]
 15%|█▌        | Ori × Time : 23/153 [00:00<00:05,   24.26it/s]
 16%|█▌        | Ori × Time : 24/153 [00:00<00:05,   24.29it/s]
 16%|█▋        | Ori × Time : 25/153 [00:01<00:05,   24.32it/s]
 17%|█▋        | Ori × Time : 26/153 [00:01<00:05,   24.35it/s]
 18%|█▊        | Ori × Time : 27/153 [00:01<00:05,   24.40it/s]
 18%|█▊        | Ori × Time : 28/153 [00:01<00:05,   24.39it/s]
 19%|█▉        | Ori × Time : 29/153 [00:01<00:05,   24.39it/s]
 20%|█▉        | Ori × Time : 30/153 [00:01<00:05,   24.40it/s]
 20%|██        | Ori × Time : 31/153 [00:01<00:04,   24.44it/s]
 21%|██        | Ori × Time : 32/153 [00:01<00:04,   24.52it/s]
 22%|██▏       | Ori × Time : 33/153 [00:01<00:04,   24.57it/s]
 22%|██▏       | Ori × Time : 34/153 [00:01<00:04,   24.57it/s]
 23%|██▎       | Ori × Time : 35/153 [00:01<00:04,   24.56it/s]
 24%|██▎       | Ori × Time : 36/153 [00:01<00:04,   24.58it/s]
 24%|██▍       | Ori × Time : 37/153 [00:01<00:04,   24.55it/s]
 25%|██▍       | Ori × Time : 38/153 [00:01<00:04,   24.59it/s]
 25%|██▌       | Ori × Time : 39/153 [00:01<00:04,   24.60it/s]
 26%|██▌       | Ori × Time : 40/153 [00:01<00:04,   24.60it/s]
 27%|██▋       | Ori × Time : 41/153 [00:01<00:04,   24.60it/s]
 27%|██▋       | Ori × Time : 42/153 [00:01<00:04,   24.65it/s]
 28%|██▊       | Ori × Time : 43/153 [00:01<00:04,   24.66it/s]
 29%|██▉       | Ori × Time : 44/153 [00:01<00:04,   24.67it/s]
 29%|██▉       | Ori × Time : 45/153 [00:01<00:04,   24.71it/s]
 30%|███       | Ori × Time : 46/153 [00:01<00:04,   24.74it/s]
 31%|███       | Ori × Time : 47/153 [00:01<00:04,   24.78it/s]
 31%|███▏      | Ori × Time : 48/153 [00:01<00:04,   24.77it/s]
 32%|███▏      | Ori × Time : 49/153 [00:02<00:04,   24.73it/s]
 33%|███▎      | Ori × Time : 50/153 [00:02<00:04,   24.69it/s]
 33%|███▎      | Ori × Time : 51/153 [00:02<00:04,   24.68it/s]
 34%|███▍      | Ori × Time : 52/153 [00:02<00:04,   24.73it/s]
 35%|███▍      | Ori × Time : 53/153 [00:02<00:04,   24.75it/s]
 35%|███▌      | Ori × Time : 54/153 [00:02<00:03,   24.78it/s]
 36%|███▌      | Ori × Time : 55/153 [00:02<00:03,   24.76it/s]
 37%|███▋      | Ori × Time : 56/153 [00:02<00:03,   24.74it/s]
 37%|███▋      | Ori × Time : 57/153 [00:02<00:03,   24.76it/s]
 38%|███▊      | Ori × Time : 58/153 [00:02<00:03,   24.73it/s]
 39%|███▊      | Ori × Time : 59/153 [00:02<00:03,   24.72it/s]
 39%|███▉      | Ori × Time : 60/153 [00:02<00:03,   24.67it/s]
 40%|███▉      | Ori × Time : 61/153 [00:02<00:03,   24.66it/s]
 41%|████      | Ori × Time : 62/153 [00:02<00:03,   24.65it/s]
 41%|████      | Ori × Time : 63/153 [00:02<00:03,   24.69it/s]
 42%|████▏     | Ori × Time : 64/153 [00:02<00:03,   24.71it/s]
 42%|████▏     | Ori × Time : 65/153 [00:02<00:03,   24.73it/s]
 43%|████▎     | Ori × Time : 66/153 [00:02<00:03,   24.77it/s]
 44%|████▍     | Ori × Time : 67/153 [00:02<00:03,   24.80it/s]
 44%|████▍     | Ori × Time : 68/153 [00:02<00:03,   24.81it/s]
 45%|████▌     | Ori × Time : 69/153 [00:02<00:03,   24.81it/s]
 46%|████▌     | Ori × Time : 70/153 [00:02<00:03,   24.83it/s]
 46%|████▋     | Ori × Time : 71/153 [00:02<00:03,   24.84it/s]
 47%|████▋     | Ori × Time : 72/153 [00:02<00:03,   24.86it/s]
 48%|████▊     | Ori × Time : 73/153 [00:02<00:03,   24.83it/s]
 48%|████▊     | Ori × Time : 74/153 [00:03<00:03,   24.84it/s]
 49%|████▉     | Ori × Time : 75/153 [00:03<00:03,   24.85it/s]
 50%|████▉     | Ori × Time : 76/153 [00:03<00:03,   24.84it/s]
 50%|█████     | Ori × Time : 77/153 [00:03<00:03,   24.83it/s]
 51%|█████     | Ori × Time : 78/153 [00:03<00:03,   24.82it/s]
 52%|█████▏    | Ori × Time : 79/153 [00:03<00:02,   24.83it/s]
 52%|█████▏    | Ori × Time : 80/153 [00:03<00:02,   24.83it/s]
 53%|█████▎    | Ori × Time : 81/153 [00:03<00:02,   24.74it/s]
 54%|█████▎    | Ori × Time : 82/153 [00:03<00:02,   24.65it/s]
 54%|█████▍    | Ori × Time : 83/153 [00:03<00:02,   24.00it/s]
 55%|█████▍    | Ori × Time : 84/153 [00:03<00:02,   23.36it/s]
 56%|█████▌    | Ori × Time : 85/153 [00:03<00:02,   23.33it/s]
 56%|█████▌    | Ori × Time : 86/153 [00:03<00:02,   23.40it/s]
 57%|█████▋    | Ori × Time : 87/153 [00:03<00:02,   23.47it/s]
 58%|█████▊    | Ori × Time : 88/153 [00:03<00:02,   23.53it/s]
 58%|█████▊    | Ori × Time : 89/153 [00:03<00:02,   23.60it/s]
 59%|█████▉    | Ori × Time : 90/153 [00:03<00:02,   23.67it/s]
 59%|█████▉    | Ori × Time : 91/153 [00:03<00:02,   23.74it/s]
 60%|██████    | Ori × Time : 92/153 [00:03<00:02,   23.79it/s]
 61%|██████    | Ori × Time : 93/153 [00:03<00:02,   23.83it/s]
 61%|██████▏   | Ori × Time : 94/153 [00:03<00:02,   23.89it/s]
 62%|██████▏   | Ori × Time : 95/153 [00:03<00:02,   23.90it/s]
 63%|██████▎   | Ori × Time : 96/153 [00:03<00:02,   23.92it/s]
 63%|██████▎   | Ori × Time : 97/153 [00:03<00:02,   23.96it/s]
 64%|██████▍   | Ori × Time : 98/153 [00:04<00:02,   23.94it/s]
 65%|██████▍   | Ori × Time : 99/153 [00:04<00:02,   23.99it/s]
 65%|██████▌   | Ori × Time : 100/153 [00:04<00:02,   23.99it/s]
 66%|██████▌   | Ori × Time : 101/153 [00:04<00:02,   24.02it/s]
 67%|██████▋   | Ori × Time : 102/153 [00:04<00:02,   24.10it/s]
 67%|██████▋   | Ori × Time : 103/153 [00:04<00:02,   24.13it/s]
 68%|██████▊   | Ori × Time : 104/153 [00:04<00:02,   24.18it/s]
 69%|██████▊   | Ori × Time : 105/153 [00:04<00:01,   24.24it/s]
 69%|██████▉   | Ori × Time : 106/153 [00:04<00:01,   24.26it/s]
 70%|██████▉   | Ori × Time : 107/153 [00:04<00:01,   24.32it/s]
 71%|███████   | Ori × Time : 108/153 [00:04<00:01,   24.34it/s]
 71%|███████   | Ori × Time : 109/153 [00:04<00:01,   24.37it/s]
 72%|███████▏  | Ori × Time : 110/153 [00:04<00:01,   24.41it/s]
 73%|███████▎  | Ori × Time : 111/153 [00:04<00:01,   24.45it/s]
 73%|███████▎  | Ori × Time : 112/153 [00:04<00:01,   24.50it/s]
 74%|███████▍  | Ori × Time : 113/153 [00:04<00:01,   24.52it/s]
 75%|███████▍  | Ori × Time : 114/153 [00:04<00:01,   24.55it/s]
 75%|███████▌  | Ori × Time : 115/153 [00:04<00:01,   24.53it/s]
 76%|███████▌  | Ori × Time : 116/153 [00:04<00:01,   24.54it/s]
 76%|███████▋  | Ori × Time : 117/153 [00:04<00:01,   24.54it/s]
 77%|███████▋  | Ori × Time : 118/153 [00:04<00:01,   24.54it/s]
 78%|███████▊  | Ori × Time : 119/153 [00:04<00:01,   24.55it/s]
 78%|███████▊  | Ori × Time : 120/153 [00:04<00:01,   24.56it/s]
 79%|███████▉  | Ori × Time : 121/153 [00:04<00:01,   24.57it/s]
 80%|███████▉  | Ori × Time : 122/153 [00:04<00:01,   24.54it/s]
 80%|████████  | Ori × Time : 123/153 [00:05<00:01,   24.55it/s]
 81%|████████  | Ori × Time : 124/153 [00:05<00:01,   24.59it/s]
 82%|████████▏ | Ori × Time : 125/153 [00:05<00:01,   24.57it/s]
 82%|████████▏ | Ori × Time : 126/153 [00:05<00:01,   24.56it/s]
 83%|████████▎ | Ori × Time : 127/153 [00:05<00:01,   24.53it/s]
 84%|████████▎ | Ori × Time : 128/153 [00:05<00:01,   24.53it/s]
 84%|████████▍ | Ori × Time : 129/153 [00:05<00:00,   24.53it/s]
 85%|████████▍ | Ori × Time : 130/153 [00:05<00:00,   24.50it/s]
 86%|████████▌ | Ori × Time : 131/153 [00:05<00:00,   24.48it/s]
 86%|████████▋ | Ori × Time : 132/153 [00:05<00:00,   24.51it/s]
 87%|████████▋ | Ori × Time : 133/153 [00:05<00:00,   24.54it/s]
 88%|████████▊ | Ori × Time : 134/153 [00:05<00:00,   24.58it/s]
 88%|████████▊ | Ori × Time : 135/153 [00:05<00:00,   24.60it/s]
 89%|████████▉ | Ori × Time : 136/153 [00:05<00:00,   24.60it/s]
 90%|████████▉ | Ori × Time : 137/153 [00:05<00:00,   24.64it/s]
 90%|█████████ | Ori × Time : 138/153 [00:05<00:00,   24.66it/s]
 91%|█████████ | Ori × Time : 139/153 [00:05<00:00,   24.70it/s]
 92%|█████████▏| Ori × Time : 140/153 [00:05<00:00,   24.72it/s]
 92%|█████████▏| Ori × Time : 141/153 [00:05<00:00,   24.70it/s]
 93%|█████████▎| Ori × Time : 142/153 [00:05<00:00,   24.69it/s]
 93%|█████████▎| Ori × Time : 143/153 [00:05<00:00,   24.71it/s]
 94%|█████████▍| Ori × Time : 144/153 [00:05<00:00,   24.76it/s]
 95%|█████████▍| Ori × Time : 145/153 [00:05<00:00,   24.82it/s]
 95%|█████████▌| Ori × Time : 146/153 [00:05<00:00,   24.83it/s]
 96%|█████████▌| Ori × Time : 147/153 [00:06<00:00,   24.83it/s]
 97%|█████████▋| Ori × Time : 148/153 [00:06<00:00,   24.84it/s]
 97%|█████████▋| Ori × Time : 149/153 [00:06<00:00,   24.84it/s]
 98%|█████████▊| Ori × Time : 150/153 [00:06<00:00,   24.83it/s]
 99%|█████████▊| Ori × Time : 151/153 [00:06<00:00,   24.80it/s]
 99%|█████████▉| Ori × Time : 152/153 [00:06<00:00,   24.76it/s]
100%|██████████| Ori × Time : 153/153 [00:06<00:00,   24.73it/s]
100%|██████████| Ori × Time : 153/153 [00:06<00:00,   24.48it/s]

  0%|          | Ori × Time : 0/153 [00:00<?,       ?it/s]
  1%|          | Ori × Time : 1/153 [00:00<00:07,   20.43it/s]
  1%|▏         | Ori × Time : 2/153 [00:00<00:06,   22.49it/s]
  2%|▏         | Ori × Time : 3/153 [00:00<00:06,   23.29it/s]
  3%|▎         | Ori × Time : 4/153 [00:00<00:06,   23.59it/s]
  3%|▎         | Ori × Time : 5/153 [00:00<00:06,   23.80it/s]
  4%|▍         | Ori × Time : 6/153 [00:00<00:06,   23.94it/s]
  5%|▍         | Ori × Time : 7/153 [00:00<00:06,   24.15it/s]
  5%|▌         | Ori × Time : 8/153 [00:00<00:05,   24.18it/s]
  6%|▌         | Ori × Time : 9/153 [00:00<00:05,   24.22it/s]
  7%|▋         | Ori × Time : 10/153 [00:00<00:05,   24.33it/s]
  7%|▋         | Ori × Time : 11/153 [00:00<00:05,   24.46it/s]
  8%|▊         | Ori × Time : 12/153 [00:00<00:05,   24.50it/s]
  8%|▊         | Ori × Time : 13/153 [00:00<00:05,   24.55it/s]
  9%|▉         | Ori × Time : 14/153 [00:00<00:05,   24.61it/s]
 10%|▉         | Ori × Time : 15/153 [00:00<00:05,   24.55it/s]
 10%|█         | Ori × Time : 16/153 [00:00<00:05,   24.62it/s]
 11%|█         | Ori × Time : 17/153 [00:00<00:05,   24.62it/s]
 12%|█▏        | Ori × Time : 18/153 [00:00<00:05,   24.56it/s]
 12%|█▏        | Ori × Time : 19/153 [00:00<00:05,   24.60it/s]
 13%|█▎        | Ori × Time : 20/153 [00:00<00:05,   24.61it/s]
 14%|█▎        | Ori × Time : 21/153 [00:00<00:05,   24.61it/s]
 14%|█▍        | Ori × Time : 22/153 [00:00<00:05,   24.64it/s]
 15%|█▌        | Ori × Time : 23/153 [00:00<00:05,   24.62it/s]
 16%|█▌        | Ori × Time : 24/153 [00:00<00:05,   24.58it/s]
 16%|█▋        | Ori × Time : 25/153 [00:01<00:05,   24.53it/s]
 17%|█▋        | Ori × Time : 26/153 [00:01<00:05,   24.62it/s]
 18%|█▊        | Ori × Time : 27/153 [00:01<00:05,   24.72it/s]
 18%|█▊        | Ori × Time : 28/153 [00:01<00:05,   24.72it/s]
 19%|█▉        | Ori × Time : 29/153 [00:01<00:05,   24.75it/s]
 20%|█▉        | Ori × Time : 30/153 [00:01<00:04,   24.80it/s]
 20%|██        | Ori × Time : 31/153 [00:01<00:04,   24.81it/s]
 21%|██        | Ori × Time : 32/153 [00:01<00:04,   24.84it/s]
 22%|██▏       | Ori × Time : 33/153 [00:01<00:04,   24.79it/s]
 22%|██▏       | Ori × Time : 34/153 [00:01<00:04,   24.77it/s]
 23%|██▎       | Ori × Time : 35/153 [00:01<00:04,   24.76it/s]
 24%|██▎       | Ori × Time : 36/153 [00:01<00:04,   24.79it/s]
 24%|██▍       | Ori × Time : 37/153 [00:01<00:04,   24.79it/s]
 25%|██▍       | Ori × Time : 38/153 [00:01<00:04,   24.76it/s]
 25%|██▌       | Ori × Time : 39/153 [00:01<00:04,   24.73it/s]
 26%|██▌       | Ori × Time : 40/153 [00:01<00:04,   24.74it/s]
 27%|██▋       | Ori × Time : 41/153 [00:01<00:04,   24.72it/s]
 27%|██▋       | Ori × Time : 42/153 [00:01<00:04,   24.70it/s]
 28%|██▊       | Ori × Time : 43/153 [00:01<00:04,   24.70it/s]
 29%|██▉       | Ori × Time : 44/153 [00:01<00:04,   24.72it/s]
 29%|██▉       | Ori × Time : 45/153 [00:01<00:04,   24.72it/s]
 30%|███       | Ori × Time : 46/153 [00:01<00:04,   24.75it/s]
 31%|███       | Ori × Time : 47/153 [00:01<00:04,   24.77it/s]
 31%|███▏      | Ori × Time : 48/153 [00:01<00:04,   24.78it/s]
 32%|███▏      | Ori × Time : 49/153 [00:01<00:04,   24.83it/s]
 33%|███▎      | Ori × Time : 50/153 [00:02<00:04,   24.85it/s]
 33%|███▎      | Ori × Time : 51/153 [00:02<00:04,   24.92it/s]
 34%|███▍      | Ori × Time : 52/153 [00:02<00:04,   24.98it/s]
 35%|███▍      | Ori × Time : 53/153 [00:02<00:03,   25.00it/s]
 35%|███▌      | Ori × Time : 54/153 [00:02<00:03,   24.97it/s]
 36%|███▌      | Ori × Time : 55/153 [00:02<00:03,   24.93it/s]
 37%|███▋      | Ori × Time : 56/153 [00:02<00:03,   24.95it/s]
 37%|███▋      | Ori × Time : 57/153 [00:02<00:03,   24.94it/s]
 38%|███▊      | Ori × Time : 58/153 [00:02<00:03,   24.90it/s]
 39%|███▊      | Ori × Time : 59/153 [00:02<00:03,   24.89it/s]
 39%|███▉      | Ori × Time : 60/153 [00:02<00:03,   24.87it/s]
 40%|███▉      | Ori × Time : 61/153 [00:02<00:03,   24.82it/s]
 41%|████      | Ori × Time : 62/153 [00:02<00:03,   24.84it/s]
 41%|████      | Ori × Time : 63/153 [00:02<00:03,   24.82it/s]
 42%|████▏     | Ori × Time : 64/153 [00:02<00:03,   24.79it/s]
 42%|████▏     | Ori × Time : 65/153 [00:02<00:03,   24.78it/s]
 43%|████▎     | Ori × Time : 66/153 [00:02<00:03,   24.78it/s]
 44%|████▍     | Ori × Time : 67/153 [00:02<00:03,   24.78it/s]
 44%|████▍     | Ori × Time : 68/153 [00:02<00:03,   24.84it/s]
 45%|████▌     | Ori × Time : 69/153 [00:02<00:03,   24.87it/s]
 46%|████▌     | Ori × Time : 70/153 [00:02<00:03,   24.87it/s]
 46%|████▋     | Ori × Time : 71/153 [00:02<00:03,   24.89it/s]
 47%|████▋     | Ori × Time : 72/153 [00:02<00:03,   24.91it/s]
 48%|████▊     | Ori × Time : 73/153 [00:02<00:03,   24.90it/s]
 48%|████▊     | Ori × Time : 74/153 [00:02<00:03,   24.88it/s]
 49%|████▉     | Ori × Time : 75/153 [00:03<00:03,   24.87it/s]
 50%|████▉     | Ori × Time : 76/153 [00:03<00:03,   24.90it/s]
 50%|█████     | Ori × Time : 77/153 [00:03<00:03,   24.90it/s]
 51%|█████     | Ori × Time : 78/153 [00:03<00:03,   24.91it/s]
 52%|█████▏    | Ori × Time : 79/153 [00:03<00:02,   24.93it/s]
 52%|█████▏    | Ori × Time : 80/153 [00:03<00:02,   24.92it/s]
 53%|█████▎    | Ori × Time : 81/153 [00:03<00:02,   24.89it/s]
 54%|█████▎    | Ori × Time : 82/153 [00:03<00:02,   24.87it/s]
 54%|█████▍    | Ori × Time : 83/153 [00:03<00:02,   24.84it/s]
 55%|█████▍    | Ori × Time : 84/153 [00:03<00:02,   24.68it/s]
 56%|█████▌    | Ori × Time : 85/153 [00:03<00:02,   24.25it/s]
 56%|█████▌    | Ori × Time : 86/153 [00:03<00:02,   23.88it/s]
 57%|█████▋    | Ori × Time : 87/153 [00:03<00:02,   22.83it/s]
 58%|█████▊    | Ori × Time : 88/153 [00:03<00:02,   22.81it/s]
 58%|█████▊    | Ori × Time : 89/153 [00:03<00:02,   22.79it/s]
 59%|█████▉    | Ori × Time : 90/153 [00:03<00:02,   22.75it/s]
 59%|█████▉    | Ori × Time : 91/153 [00:03<00:02,   22.76it/s]
 60%|██████    | Ori × Time : 92/153 [00:03<00:02,   22.86it/s]
 61%|██████    | Ori × Time : 93/153 [00:03<00:02,   22.95it/s]
 61%|██████▏   | Ori × Time : 94/153 [00:03<00:02,   23.05it/s]
 62%|██████▏   | Ori × Time : 95/153 [00:03<00:02,   23.14it/s]
 63%|██████▎   | Ori × Time : 96/153 [00:03<00:02,   23.20it/s]
 63%|██████▎   | Ori × Time : 97/153 [00:04<00:02,   23.24it/s]
 64%|██████▍   | Ori × Time : 98/153 [00:04<00:02,   23.29it/s]
 65%|██████▍   | Ori × Time : 99/153 [00:04<00:02,   23.31it/s]
 65%|██████▌   | Ori × Time : 100/153 [00:04<00:02,   23.29it/s]
 66%|██████▌   | Ori × Time : 101/153 [00:04<00:02,   23.33it/s]
 67%|██████▋   | Ori × Time : 102/153 [00:04<00:02,   23.30it/s]
 67%|██████▋   | Ori × Time : 103/153 [00:04<00:02,   23.33it/s]
 68%|██████▊   | Ori × Time : 104/153 [00:04<00:02,   23.35it/s]
 69%|██████▊   | Ori × Time : 105/153 [00:04<00:02,   23.40it/s]
 69%|██████▉   | Ori × Time : 106/153 [00:04<00:02,   23.44it/s]
 70%|██████▉   | Ori × Time : 107/153 [00:04<00:01,   23.50it/s]
 71%|███████   | Ori × Time : 108/153 [00:04<00:01,   23.54it/s]
 71%|███████   | Ori × Time : 109/153 [00:04<00:01,   23.58it/s]
 72%|███████▏  | Ori × Time : 110/153 [00:04<00:01,   23.62it/s]
 73%|███████▎  | Ori × Time : 111/153 [00:04<00:01,   23.70it/s]
 73%|███████▎  | Ori × Time : 112/153 [00:04<00:01,   23.77it/s]
 74%|███████▍  | Ori × Time : 113/153 [00:04<00:01,   23.80it/s]
 75%|███████▍  | Ori × Time : 114/153 [00:04<00:01,   23.84it/s]
 75%|███████▌  | Ori × Time : 115/153 [00:04<00:01,   23.87it/s]
 76%|███████▌  | Ori × Time : 116/153 [00:04<00:01,   23.89it/s]
 76%|███████▋  | Ori × Time : 117/153 [00:04<00:01,   23.87it/s]
 77%|███████▋  | Ori × Time : 118/153 [00:04<00:01,   23.92it/s]
 78%|███████▊  | Ori × Time : 119/153 [00:04<00:01,   23.95it/s]
 78%|███████▊  | Ori × Time : 120/153 [00:04<00:01,   23.98it/s]
 79%|███████▉  | Ori × Time : 121/153 [00:04<00:01,   24.01it/s]
 80%|███████▉  | Ori × Time : 122/153 [00:05<00:01,   24.07it/s]
 80%|████████  | Ori × Time : 123/153 [00:05<00:01,   24.13it/s]
 81%|████████  | Ori × Time : 124/153 [00:05<00:01,   24.18it/s]
 82%|████████▏ | Ori × Time : 125/153 [00:05<00:01,   24.20it/s]
 82%|████████▏ | Ori × Time : 126/153 [00:05<00:01,   24.18it/s]
 83%|████████▎ | Ori × Time : 127/153 [00:05<00:01,   24.17it/s]
 84%|████████▎ | Ori × Time : 128/153 [00:05<00:01,   24.18it/s]
 84%|████████▍ | Ori × Time : 129/153 [00:05<00:00,   24.22it/s]
 85%|████████▍ | Ori × Time : 130/153 [00:05<00:00,   24.27it/s]
 86%|████████▌ | Ori × Time : 131/153 [00:05<00:00,   24.30it/s]
 86%|████████▋ | Ori × Time : 132/153 [00:05<00:00,   24.35it/s]
 87%|████████▋ | Ori × Time : 133/153 [00:05<00:00,   24.38it/s]
 88%|████████▊ | Ori × Time : 134/153 [00:05<00:00,   24.45it/s]
 88%|████████▊ | Ori × Time : 135/153 [00:05<00:00,   24.48it/s]
 89%|████████▉ | Ori × Time : 136/153 [00:05<00:00,   24.48it/s]
 90%|████████▉ | Ori × Time : 137/153 [00:05<00:00,   24.49it/s]
 90%|█████████ | Ori × Time : 138/153 [00:05<00:00,   24.52it/s]
 91%|█████████ | Ori × Time : 139/153 [00:05<00:00,   24.54it/s]
 92%|█████████▏| Ori × Time : 140/153 [00:05<00:00,   24.60it/s]
 92%|█████████▏| Ori × Time : 141/153 [00:05<00:00,   24.64it/s]
 93%|█████████▎| Ori × Time : 142/153 [00:05<00:00,   24.66it/s]
 93%|█████████▎| Ori × Time : 143/153 [00:05<00:00,   24.66it/s]
 94%|█████████▍| Ori × Time : 144/153 [00:05<00:00,   24.67it/s]
 95%|█████████▍| Ori × Time : 145/153 [00:05<00:00,   24.67it/s]
 95%|█████████▌| Ori × Time : 146/153 [00:05<00:00,   24.65it/s]
 96%|█████████▌| Ori × Time : 147/153 [00:06<00:00,   24.59it/s]
 97%|█████████▋| Ori × Time : 148/153 [00:06<00:00,   24.60it/s]
 97%|█████████▋| Ori × Time : 149/153 [00:06<00:00,   24.59it/s]
 98%|█████████▊| Ori × Time : 150/153 [00:06<00:00,   24.57it/s]
 99%|█████████▊| Ori × Time : 151/153 [00:06<00:00,   24.56it/s]
 99%|█████████▉| Ori × Time : 152/153 [00:06<00:00,   24.59it/s]
100%|██████████| Ori × Time : 153/153 [00:06<00:00,   24.61it/s]
100%|██████████| Ori × Time : 153/153 [00:06<00:00,   24.34it/s]

Now, the following code plots the anatomical localization. First, we locate the sources that are involved in the prominent early peaks in the Common stimulus code: P50: 50ms, N100: 95ms, P200: 170ms. They correspond to auditory response in both conditions.

times = (0.05, 0.095, 0.170,)
vmax = 5e-11
# vmax = hs[0].norm('space').max()  # alternative: vmax based on data
bf = eelbrain.plot.Butterfly(hs[0].norm('space'), axtitle='common', h=2,
                             vmax=vmax, ylabel='Amplitude')
for time in times:
    bf.add_vline(time, color='k', linestyle='--')
bs = [eelbrain.plot.GlassBrain(
        hs[0].sub(time=time), vmax=vmax, display_mode='lr',
        title=f"common-[{time*1000:.0f} ms]",
      ) for time in times]
  • 00 example vol src
  • common-[50 ms]
  • common-[95 ms]
  • common-[170 ms]

Next, we do the same with NCRFs to the Contrast predictor. Note that the peaks in the contrast condition are later than those in the common condition, and emphasizes known temporal dynamics of mismatch negativity (MMN) response. We locate the sources that are involved in the prominent MMN peak around 190ms. Note that the dircetion of activation is opposite to that of early peaks in the common condition.

times = (0.190,)
bf = eelbrain.plot.Butterfly(hs[1].norm('space'), axtitle='contrast',
                             h=2, vmax=vmax, ylabel='Amplitude')
for time in times:
    bf.add_vline(time, color='k', linestyle='--')

bs = [eelbrain.plot.GlassBrain(
        hs[1].sub(time=time), vmax=vmax, display_mode='lr',
        title=f"contrast-[{time*1000:.0f} ms]",
      ) for time in times]
  • 00 example vol src
  • contrast-[190 ms]

Finally, we can reconstruct the response to frequent and infrequent stimuli as \([Common - Contrast]\) amd \([Common + Contrast]\) respectively. Here, we locate the sources that are involved in the prominent peaks around 450ms, which are stronger for infrequent stimuli, to the left motor cortex. This aligns with the expected neural response to the motor task: the subject presses a button when detecting a deviant with the right index finger.

vmax = 7e-11
times = (0.45,)

# Frequent
h = hs[0] - hs[1]
bf = eelbrain.plot.Butterfly(h.norm('space'), h=2, vmax=vmax,
                             ylabel='Amplitude', frame=None, title='frequent')
for time in times:
    bf.add_vline(time, color='k', linestyle='--')

bs = [eelbrain.plot.GlassBrain(
        h.sub(time=time), vmax=vmax, display_mode='lr',
        title=f"frequent-[{time*1000:.0f} ms]",
      ) for time in times]

# Infrequent
h = hs[0] + hs[1]
bf = eelbrain.plot.Butterfly(h.norm('space'), title='infrequent',
                             h=2, vmax=vmax, frame=None, ylabel='Amplitude')
for time in times:
    bf.add_vline(time, color='k', linestyle='--')

bs = [eelbrain.plot.GlassBrain(
        h.sub(time=time), vmax=vmax, display_mode='lr',
        title=f"Infrequent-[{time*1000:.0f} ms]",
      ) for time in times]
  • frequent
  • frequent-[450 ms]
  • infrequent
  • Infrequent-[450 ms]

In an interactive iPython session, we can also use interactive time-linked plots with eelbrain.plot.GlassBrain.butterfly:

# brain, butterfly = eelbrain.plot.GlassBrain.butterfly(h)

Total running time of the script: (3 minutes 54.384 seconds)

Gallery generated by Sphinx-Gallery