差分トポなど①準備編の続きです.

改造編と称していますが,
これはEEGLAB既存のmファイルを書き換えるからです.
基本的に悪さをしない書き換えをしていますが,
嫌な人はSTUDYファイルを作る際に,
差分したデータセットを用意して,
それをつかって①をやる,という感じにすればよいと思います.

では本題.

「①準備編」で紹介したことができている前提です.
先ほどのParam設定の中に

[Plot scalp map at latency [ms]]

という設定がありました.

さきほどはスルーしていましたが,
ここに数値を入れるとトポグラフィー描画モードになります.

DPSVOX.NKのブログ

画像は400-600msの平均電位のトポを出したい場合.
単一の数値でも機能します.

ただ①で紹介した[Sel. all]をやってからでないと,
Plot ERPsを押してもエラーが出ます.
プログラムで電極が5個以上選択されていないと
出してくれないようになっているからです.

しかしここで出せるのは各条件ごとのトポ.
差分など好きなデータでトポを出したい場合は
いくつかのmファイルを書き換えます.

ポイントになるのは

std_erpplot
std_chantopo
std_readdata

の三つです.

このうち今回はできるだけ書き込みがバグにならないように,
std_erpplotのみを書き換えて,
後は手打ちで算出するという方法にします.

which std_erpplot

とかでどこにあるかを探してeditorで見てみます.

長いので細かくは見ませんが,

約330-340行目くらいにある以下の記述を変更します.

% compute statistics and plot
% ---------------------------
[pcond pgroup pinter] = std_stat(erpdata, 'groupstats', opt.groupstats, 'condstats', opt.condstats, ...
'statistics', opt.statistics, 'naccu', opt.naccu, 'threshold', opt.threshold);
locs = eeg_mergelocs(ALLEEG.chanlocs);
locs = locs(std_chaninds(STUDY, opt.channels));

if ~isempty(opt.topotime) & ~isnan(opt.topotime)
std_chantopo(erpdata, 'condnames', STUDY.condition, 'plottopo', fastif(length(allinds)==1, 'off', 'on'), ...
'datatype', 'spec', 'plotmode', opt.plotmode, 'groupnames', STUDY.group, 'unitx', '\muV', ...
'groupstats', pgroup, 'condstats', pcond, 'interstats', pinter, ...
'chanlocs', locs, 'plotsubjects', opt.plotsubjects, 'topovals', titlestr, plotcurveopt{:});
else
std_plotcurve(alltimes, erpdata, 'condnames', STUDY.condition, 'plottopo', fastif(length(allinds)==1, 'off', 'on'), ...
'datatype', 'spec', 'plotmode', opt.plotmode, 'groupnames', STUDY.group, 'unitx', 'ms', ...
'groupstats', pgroup, 'condstats', pcond, 'interstats', pinter, ...
'chanlocs', locs, 'plotsubjects', opt.plotsubjects, plotcurveopt{:});
end;

ここはデータに基づいて統計解析とデータのプロットをするところです.
注目するのは

std_chantopo(erpdata, 'condnames', STUDY.condition, 'plottopo', fastif(length(allinds)==1, 'off', 'on'), ...
'datatype', 'spec', 'plotmode', opt.plotmode, 'groupnames', STUDY.group, 'unitx', '\muV', ...
'groupstats', pgroup, 'condstats', pcond, 'interstats', pinter, ...
'chanlocs', locs, 'plotsubjects', opt.plotsubjects, 'topovals', titlestr, plotcurveopt{:});

です.

ここで

std_chantopo

はトポを表示するmファイルなので,
括弧内で指定したパラメータを引数として持って,
表示処理に向かう感じです.
そこでここで必要になるパラメータをmatファイルに保存してしまいます.

そのためのスクリプトが以下,

%% added by Noriaki Kanayama
condition=STUDY.condition;group=STUDY.group;
save('std_topo_set.mat','erpdata','condition', 'group', 'allinds', 'opt', 'pgroup', 'pcond', 'pinter', 'locs', 'titlestr', 'plotcurveopt','-mat');
%% added by Noriaki Kanayama

これを

std_chantopo(...

の直前に貼り付けます.
(もちろん%%がついている行はコメントなので任意で.
でもmファイル改変なので,後で検索しやすいようにしておくとよいです)

すると
std_topo_set.mat
というマットファイルを「トポを表示する」たびに
カレントフォルダに算出してくれます.

これで改造は終了です.

プログラムの途中で変数をファイルに保存しているだけなので,
基本的に他のどんな作業にも影響を与えないはずです.

このmatファイルを使うと,
後々楽に色々できます.

では続きは別で