-
Notifications
You must be signed in to change notification settings - Fork 7
/
bf_output_image_sensitivity.m
83 lines (61 loc) · 1.93 KB
/
bf_output_image_sensitivity.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function res = bf_output_image_sensitivity(BF, S)
% Sensitivity profile for a group of sensors
% Copyright (C) 2017 Wellcome Trust Centre for Neuroimaging
% Vladimir Litvak
% $Id$
%--------------------------------------------------------------------------
if nargin == 0
modality = cfg_menu;
modality.tag = 'modality';
modality.name = 'Modality';
modality.help = {'Specify modality'};
modality.labels = {
'MEG'
'MEGPLANAR'
'EEG'
}';
modality.values = {
'MEG'
'MEGPLANAR'
'EEG'
}';
modality.val = {'MEG'};
sensitivity = cfg_branch;
sensitivity.tag = 'image_sensitivity';
sensitivity.name = 'Sensitivity image';
sensitivity.val = {spm_cfg_eeg_channel_selector, modality};
res = sensitivity;
return
elseif nargin < 2
error('Two input arguments are required');
end
nvert = size(BF.sources.pos, 1);
spm('Pointer', 'Watch');drawnow;
spm_progress_bar('Init', nvert, 'Scanning grid points'); drawnow;
if nvert > 100, Ibar = floor(linspace(1, nvert,100));
else Ibar = 1:nvert; end
val = nan(1, nvert);
D = BF.data.D;
selectchan = D.chanlabels(D.selectchannels(spm_cfg_eeg_channel_selector(S.channels)));
for i = 1:nvert
if isfield(BF, 'inverse')
lf = BF.inverse.(S.modality).L{i};
channels = BF.inverse.(S.modality).channels;
else
lf = BF.sources.L.(S.modality(1:3)){i};
channels = BF.sources.channels.(S.modality(1:3));
end
[sel1, sel2] = spm_match_str(selectchan, channels);
lf = lf(sel2, :);
if ~any(isnan(lf))
val(i) = sqrt(trace(lf'*lf));
end
if ismember(i, Ibar)
spm_progress_bar('Set', i); drawnow;
end
end
spm_progress_bar('Clear');
image.val = val;
image.label = ['sensitivity_' spm_file(fname(BF.data.D), 'basename')];
spm('Pointer', 'Arrow');drawnow;
res = image;