Home > vbmeg > demo > tutorial_for_vbmeg2 > easy_VBMEG > show_source_current_eeg.m

show_source_current_eeg

PURPOSE ^

Show source current estimated from EEG data

SYNOPSIS ^

function show_source_current_eeg(p)

DESCRIPTION ^

 Show source current estimated from EEG data

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function show_source_current_eeg(p)
0002 % Show source current estimated from EEG data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Set parameters
0010 time_to_show = [-0.1 0.4];% sec
0011 time_of_interest = [0 0.24];% sec
0012 angle(:,:,1) = [-90 0;90 0];% Angle to see brain (auditory)
0013 angle(:,:,2) = [-90 0;90 0];% Angle to see brain (sensorimotor)
0014 angle(:,:,3) = [-50 0;50 0];% Angle to see brain (visual)
0015 
0016 % Make directory to save figures
0017 save_dir = fullfile(p.fig_root, mfilename, p.sub);
0018 if exist(save_dir, 'dir') ~= 7
0019     vb_mkdir(save_dir);
0020 end
0021 
0022 % Load time information
0023 current_file = fullfile(p.proj_root, p.eeg_dirname, ['standard_' p.current_dirname, 's.curr.mat']);
0024 Jinfo = vb_load_current(current_file);
0025 time = Jinfo.Tmsec/1000;% sec
0026 [~, from_show] = min(abs(time-time_to_show(1)));
0027 [~, to_show] = min(abs(time-time_to_show(2)));
0028 time = time(from_show: to_show);
0029 
0030 % Load brain model on which current is shown
0031 brain_file = ['/home/cbi-data20/common/software/internal/vbmeg/vbmeg2_0_0_b_4/'...
0032         'standard_brain/mni_icbm152_t1_tal_nlin_asym_09c_10000/mni_icbm152_t1_tal_nlin_asym_09c_10000.brain.mat'];
0033 [V, F, xx, inf_C] = vb_load_cortex(brain_file, 'Inflate');
0034 plot_parm = vb_set_plot_parm;
0035 
0036 % Load current
0037 current_file = fullfile(p.proj_root, p.eeg_dirname, ['standard_' p.current_dirname, 's.curr.mat']);
0038 [~, current] = vb_load_current(current_file);
0039 
0040 % Average source currents across trials
0041 y = mean(current(:, from_show:to_show, :), 3);
0042 
0043 % Calculate absolute value of current
0044 [~, from_power] = min(abs(time-time_of_interest(1)));
0045 [~, to_power] = min(abs(time-time_of_interest(2)));
0046 ay=mean(abs(y(:,from_power:to_power)),2);
0047 
0048 % Plot time series of averaged EEG data
0049 h = figure;
0050 max_y = max(y(:));
0051 min_y = min(y(:));
0052 subplot(2, 1, 1)
0053 plot(time, y)
0054 xlabel('Time [s]')
0055 ylabel('Current [Am/m^2]')
0056 axis([time(1) time(end) min_y max_y])
0057 
0058 % Plot spatial pattern of absolute value of current
0059 for an = 1:size(angle, 1)
0060     subplot(2, 2, 2+an)
0061     vb_plot_cortex(plot_parm, V, F, inf_C, ay, max(ay)*0.3, max(ay));
0062     axis equal off
0063     view(angle(an, :, 1))
0064     %zoom(1.5)
0065     if an==1
0066         title(['Absolute value of current (' num2str(time_of_interest(1)) ' - ' num2str(time_of_interest(2)) ' sec)'])
0067     end
0068 end
0069 
0070 % Save figure
0071 vb_savefig_as_shown(h, fullfile(save_dir, 's'))
0072 end
0073 
0074

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005