文章来源于微信公众号(茗创科技),欢迎有兴趣的朋友搜索关注。

关于偶极子源定位:是指在 64~128 多导头皮脑电图记录的基础上,运用计算机数学模型推算自发或诱发脑电活动的起源,可用于癫痫外科术前辅助棘波起源的定位或诱发电位起源的研究。

如何用 DIPFIT 拟合一个偶极子与 EEG 或 ERP 的头皮图?

EEGLAB 有一个命令行函数可以允许 DIPFIT 进行拟合。拟合只能在选定的时间点进行,而不能在整个时间窗口中进行。在平均 ERP 波形中拟合 100ms 的时间点,可以使用以下 MATLAB 命令。

eeglab; close; % add path
eeglabp = fileparts(which('eeglab.m'));
EEG = pop_loadset(fullfile(eeglabp, 'sample_data', 'eeglab_data_epochs_ica.set'));% Find the 100-ms latency data frame
latency = 0.100;
pt100 = round((latency-EEG.xmin)*EEG.srate);% Find the best-fitting dipole for the ERP scalp map at this timepoint
erp = mean(EEG.data(:,:,:), 3);
dipfitdefs;% Use MNI BEM model
EEG = pop_dipfit_settings( EEG, 'hdmfile',template_models(2).hdmfile,'coordformat',template_models(2).coordformat,...'mrifile',template_models(2).mrifile,'chanfile',template_models(2).chanfile,...'coord_transform',[0.83215 -15.6287 2.4114 0.081214 0.00093739 -1.5732 1.1742 1.0601 1.1485] ,'chansel',[1:32] );
[ dipole, model, TMPEEG] = dipfit_erpeeg(erp(:,pt100), EEG.chanlocs, 'settings', EEG.dipfit, 'threshold', 100);% plot the dipole in 3-D
pop_dipplot(TMPEEG, 1, 'normlen', 'on');% Plot the dipole plus the scalp map
figure; pop_topoplot(TMPEEG,0,1, [ 'ERP 100ms, fit with a single dipole (RV ' num2str(dipole(1).rv*100,2) '%)'], 0, 1);

运行脚本后会生成这样两张图。

注:使用 eLoreta 也可以定位 EEG/ERP 源。

使用 DIPFIT/Fieldtrip 进行高级源重构。

DIPFIT 依赖于 Fieldtrip。开发者对 DIPFIT 进行了重新设计,使其能够使用 Fieldtrip 函数。以下是关于如何使用应用于 EEGLAB 数据集中的 Fieldtrip 执行源建模的简短教程。

先使用 DIPFIT 将电极位置与所选择的头部模型(菜单项工具→使用 DIPFIT 定位偶极子→头部模型和设置)对齐。得到的 DIPFIT 信息可以用来在 Fieldtrip 中执行源定位。

对体素进行源重构。

下面的第一个代码片段为 3-D 网格生成引导场矩阵(和 eLoreta 一起使用)。


%% First load a dataset in EEGLAB.
% Then use EEGLAB menu item <em>Tools > Locate dipoles using DIPFIT > Head model and settings</em>
% to align electrode locations to a head model of choice
% The eeglab/fieldtrip code is shown below:eeglab                        % start eeglab
eeglabPath = fileparts(which('eeglab'));                 % save its location
bemPath = fullfile(eeglabPath, 'plugins', 'dipfit', 'standard_BEM');    % load the dipfit plugin
EEG = pop_loadset(fullfile(eeglabPath, 'sample_data', 'eeglab_data_epochs_ica.set'));   % load the sample eeglab epoched dataset
EEG = pop_dipfit_settings( EEG, 'hdmfile',fullfile(bemPath, 'standard_vol.mat'), ...'coordformat','MNI','mrifile',fullfile(bemPath, 'standard_mri.mat'), ...'chanfile',fullfile(bemPath, 'elec', 'standard_1005.elc'), ...'coord_transform',[0.83215 -15.6287 2.4114 0.081214 0.00093739 -1.5732 1.1742 1.0601 1.1485] , ...

然后使用 Fieldtrip 的 ft_prepare_leadfield 函数计算引导场矩阵。注意,头部模型也可以用于评估体素是在大脑内部还是外部。


%% Leadfield Matrix calculation
dataPre = eeglab2fieldtrip(EEG, 'preprocessing', 'dipfit');   % convert the EEG data structure to fieldtripcfg = [];
cfg.channel = {'all', '-EOG1'};
cfg.reref = 'yes';
cfg.refchannel = {'all', '-EOG1'};
dataPre = ft_preprocessing(cfg, dataPre);vol = load('-mat', EEG.dipfit.hdmfile);cfg            = [];
cfg.elec       = dataPre.elec;
cfg.headmodel  = vol.vol;
cfg.resolution = 10;   % use a 3-D grid with a 1 cm resolution
cfg.unit       = 'mm';
cfg.channel    = { 'all' };
[sourcemodel] = ft_prepare_leadfield(cfg);

使用现在生成的引导场矩阵进行源重构。这里,使用 eLoreta 为 ERP 的假定来源建模。这一步,可以用其他方法来代替 eLoreta,比如相干源的动态成像“dics”(感兴趣的小伙伴可以在 Fieldtrip 上了解关于这步的更多信息,网址为:https://www.fieldtriptoolbox.org/tutorial/beamformer/)。


%% Compute an ERP in Fieldtrip. Note that the covariance matrix needs to be calculated here for use in source estimation.
cfg                  = [];
cfg.covariance       = 'yes';
cfg.covariancewindow = [EEG.xmin 0]; % calculate the average of the covariance matrices% for each trial (but using the pre-event baseline  data only)
dataAvg = ft_timelockanalysis(cfg, dataPre);% source reconstruction
cfg             = [];
cfg.method      = 'eloreta';
cfg.sourcemodel = sourcemodel;
cfg.headmodel   = vol.vol;
source          = ft_sourceanalysis(cfg, dataAvg);  % compute the source model

使用 Fieldtrip 函数进行绘制,画出不同偶极子的方向轴。

%% Plot Loreta solution
cfg = [];
cfg.projectmom = 'yes';
cfg.flipori = 'yes';
sourceProj = ft_sourcedescriptives(cfg, source);cfg = [];
cfg.parameter = 'mom';
cfg.operation = 'abs';
sourceProj = ft_math(cfg, sourceProj);cfg              = [];
cfg.method       = 'ortho';
cfg.funparameter = 'mom';
figure; ft_sourceplot(cfg, sourceProj);

选择感兴趣的潜伏期,就可以将其投射到高分辨率 MRI 中(head image)。下面显示了头模的核磁共振切片的全脑功率。

%% project sources on MRI and plot solution
mri = load('-mat', EEG.dipfit.mrifile);
mri = ft_volumereslice([], mri.mri);cfg              = [];
cfg.downsample   = 2;
cfg.parameter    = 'pow';
source.oridimord = 'pos';
source.momdimord = 'pos';
sourceInt  = ft_sourceinterpolate(cfg, source , mri);cfg              = [];
cfg.method       = 'slice';
cfg.funparameter = 'pow';
ft_sourceplot(cfg, sourceInt);

在头皮表面进行源重构。

或者,用下面的代码在 MNI 空间中生成一个真实的 3-D 网格的引导场矩阵。这里,需要在 DIPFIT 设置菜单中选择头部模型时选择 MNI BEM 头部模型。不同的网格版本可以使用不同的分辨率(有关更多信息,请查看网址:https://www.fieldtriptoolbox.org/template/sourcemodel/)。


%% Prepare leadfield surface
[ftVer, ftPath] = ft_version;
sourcemodel = ft_read_headshape(fullfile(ftPath, 'template', 'sourcemodel', 'cortex_8196.surf.gii'));cfg           = [];
cfg.grid      = sourcemodel;    % source points
cfg.headmodel = vol.vol;        % volume conduction model
leadfield = ft_prepare_leadfield(cfg, dataAvg);

前一节中的代码使用了 eLoreta,本节将使用最小范数估计(MNE)。MNE 和 eLoreta 都可以在每个延迟时间执行源重构(假设使用 EEG 时间序列作为输入)。


%% Surface source analysis
cfg               = [];
cfg.method        = 'mne';
cfg.grid          = leadfield;
cfg.headmodel     = vol.vol;
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
source            = ft_sourceanalysis(cfg, dataAvg);

现在绘制全脑功率,使用相同的方法,可以创建 MNE 源解决方法随时间变化的图片展示。


%% Surface source plot
cfg = [];
cfg.funparameter = 'pow';
cfg.maskparameter = 'pow';
cfg.method = 'surface';
cfg.latency = 0.4;
cfg.opacitylim = [0 200];
ft_sourceplot(cfg, source);

也可以通过在上面的图像上叠加 BEM 网格来查看源模型网格与 BEM 头部模型网格的对齐情况,如下图所示。

hold on; ft_plot_mesh(vol.vol.bnd(3), 'facecolor', 'red', 'facealpha', 0.05, 'edgecolor', 'none');
hold on; ft_plot_mesh(vol.vol.bnd(2), 'facecolor', 'red', 'facealpha', 0.05, 'edgecolor', 'none');
hold on; ft_plot_mesh(vol.vol.bnd(1), 'facecolor', 'red', 'facealpha', 0.05, 'edgecolor', 'none');

参考来源:

https://github.com/sccn/sccn.github.io/blob/master/tutorials/09_source/EEG_sources.md

https://www.fieldtriptoolbox.org/tutorial/beamformer/

https://www.fieldtriptoolbox.org/template/sourcemodel/

代码分享 | EEG数据的等效偶极子源定位相关推荐

  1. matlab 数据透视表,MATLAB | 用行为数据处理EEG数据事件码

    脑电图(Electroencephalogram,EEG)是通过精密的电子仪器,从头皮上将脑部的自发性生物电位加以放大记录而获得的图形,同时具有极高的时间分辨率.EEGLAB和ERPLAB常被用来处理 ...

  2. 爱可可推荐!关于竞赛思路,方法和代码实践,数据竞赛Baseline开源分享!

    数据竞赛中baseline是最入门的分享, 它不仅有思路.方法还有内容: 或许你与Top选手的差距就是一个baseline! 01 项目介绍 如果你是数据竞赛的初学者.爱好者,比赛的baseline不 ...

  3. php熊掌号怎么设置json-ld,织梦DEDECMS熊掌号JSON LD结构化数据代码分享

    织梦DEDECMS熊掌号JSON LD结构化数据代码分享 效果: 注意:@id里面的地址必须是自适应网站或者手机站,pc端链接是不支持! 百度官方JSON-LD示例: { "@context ...

  4. 代码分享:面波数据快速成图

    代码分享:面波数据快速成图 前言 目前,物探数据主要用surfer软件成图,surfer软件具有强大的插值和绘图功能,成图比较美观.但是,生产过程中大量的物探数据,依靠excel和surfer来成图耗 ...

  5. 外文文献下载网站;数据获取网站;中文文献下载网站;论文原创性保真网站;外包项目申请网站;大数据比赛收录网站;提高编程能力;代码分享网站

    外文文献 名称:IEEE 简介:世界上最大的技术专业组织,180多本高质量期刊 网址:https://www.ieee.org/ 名称:Sci-Hub | Effective Data Cluster ...

  6. taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,R2接口,oAuth2.0交易接口代码分享

    一.taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,R2接口,oAuth2.0交易接口代码分享 搜索当前会话用户作为卖家已卖出的 ...

  7. taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享

    一.taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,R2接口,oAuth2.0交易接口代码分享 搜索当前会话用户作为卖家已卖出的 ...

  8. 热动力数据MATLAB代码分享

    DSC 数据拟合和转化率计算 本文介绍 补充说明 热动力学介绍 拟合采用kissinger方程 拟合过程代码 拟合结果展示 通过计算,输出反应结果和拟合的r^2大小 反应转率介绍 反应产物转化计算程序 ...

  9. 【第十一届泰迪杯B题产品订单的数据分析与需求预测产品订单的数据分析与需求预测 】第二大问代码分享+解题思路(EDA数据再探索+LightGBM模型)

    [第十一届泰迪杯B题产品订单的数据分析与需求预测]第二大问代码分享+解题思路(EDA数据再探索+LightGBM模型) 写在前面: ​ 拖了这么长时间,一方面是我在找实习面试准备.另一方面是在做第二问 ...

最新文章

  1. log4j中调试与错误日志分开_Log4j 配置
  2. 【0521模拟赛】小Z爱划水
  3. Golang实现简单爬虫框架(4)——队列实现并发任务调度
  4. python 命令行参数-python实现读取命令行参数的方法
  5. 阿里 双11 同款流控降级组件 Sentinel Go 正式 GA,助力云原生服务稳稳稳
  6. Kettle使用_26 根据增删改标识处理数据
  7. 想更换手机卡,但它绑定了支付宝,微信,银行卡等,该怎么办啊?
  8. Office技巧之一 EXCEL设置下拉菜单
  9. win10 默认程序 edge
  10. form表单上传文件
  11. spring boot 相关快捷内置类和配置
  12. 181113每日一句
  13. Mybaitis框架与Spring整合详解(三)
  14. mybatis-plus中Constants.WRAPPER的导入包
  15. 邮件个性签名html,iphone发邮件添加个性签名方法
  16. html上外边距是,margin-top css设置对象上外边距间距(上外补白)
  17. PE、PM、PD、PR分别是什么岗位?
  18. 城市建筑三维白膜数据的制作
  19. 如果你没读懂《骇客帝国》
  20. 一款基于chatGPT的插件【Merlin】,聊天式感受强大AI能力

热门文章

  1. 黑客入侵无线网络常用手段
  2. srgan要训练多久_核心训练需要做多久?学会这些动作,5分钟完成核心训练
  3. 2021年茶艺师(中级)复审考试及茶艺师(中级)复审模拟考试
  4. 转一首普希金的诗,给郁闷的日子煽煽情!
  5. sv基础-数据类型(一)
  6. 项目视频讲解_马震宇-博客
  7. springboot整合缓存Redis
  8. 以太网适配器和隧道适配器
  9. 华为MateBook D14 安装ubuntu16 wifi、蓝牙、触控板驱动问题解决
  10. Python自动生成当月上班及加班时间模板表