<div dir="ltr"><div dir="ltr"><div dir="ltr" style="font-family:arial,sans-serif;font-size:13px">Hello FieldTrip members,<div><br></div><div>I am trying to source localize EEG oscillatory activity and have a few problems in constructing the forward model and eventually running the source analysis. I think the problems are related to each other. Here is what happens:</div>
<div><br></div><div>1- When I run the source analysis, I get this error message:</div><div><br></div></div><blockquote style="font-family:arial,sans-serif;font-size:13px;margin:0px 0px 0px 40px;border:none;padding:0px"><div>
<i><font size="1">??? Error using ==> svd</font></i></div><div><i><font size="1">Input to SVD must not contain NaN or Inf.</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">Error in ==> beamformer_dics>pinv at 650</font></i></div>
<div><i><font size="1"> [U,S,V] = svd(A,0);</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">Error in ==> beamformer_dics at 339</font></i></div><div><i><font size="1"> filt = pinv(lf' * invCf * lf) * lf' * invCf; % Gross eqn. 3, use PINV/SVD to cover rank</font></i></div>
<div><i><font size="1"> deficient leadfield</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">Error in ==> ft_sourceanalysis at 572</font></i></div><div><i><font size="1"> dip(i) = beamformer_dics(grid, sens, vol, [], squeeze(Cf(i,:,:)), optarg{:});</font></i></div>
<div><i><font size="1"><br></font></i></div><div><i><font size="1">Error in ==> test_sourceanalysis at 12</font></i></div><div><i><font size="1">sourceTF = ft_sourceanalysis(cfg, data_TF);</font></i></div></blockquote>
<div dir="ltr" style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>2- Checking the leadfiled matrices, I see there are a lot of NaN values.</div><div>3- When I visualize the head model I have created, the plots don't look right. The third field, <i>vol.bnd(3),</i> which is supposed to be the brain tissue, looks like a cube.</div>
<div><br></div><div>And here are my code lines:</div><div><br></div></div><blockquote style="font-family:arial,sans-serif;font-size:13px;margin:0px 0px 0px 40px;border:none;padding:0px"><div><i><font size="1">% CONSTRUCT A HEAD MODEL from the template mri in FT's template/anatomy</font></i></div>
<div><i><font size="1">mri = ft_read_mri('template\anatomy\single_subj_T1.nii');</font></i></div><div><i><font size="1">mri.coordsys = 'spm';</font></i></div><div><i><font size="1"><br></font></i></div><div>
<i><font size="1">%SEGMENTATION:</font></i></div><div><i><font size="1">cfg = [];</font></i></div><div><i><font size="1">cfg.output = {'brain','skull','scalp'};</font></i></div><div><i><font size="1">segmentedmri_template = ft_volumesegment(cfg, mri); % Using NOT resliced data</font></i></div>
<div><i><font size="1">save segmentedmri_template segmentedmri_template</font></i></div><div><i><font size="1"><br></font></i></div><div><br></div><div><i><font size="1">%CREATE THE HEAD MODEL (VOLUME CONDUCTION MODEL)</font></i></div>
<div><i><font size="1">cfg = [];</font></i></div><div><i><font size="1">cfg.method ='bemcp';</font></i></div><div><i><font size="1">cfg.tissue ={'brain','skull','scalp'};</font></i></div>
<div><i><font size="1">% cfg.outputfile = 'template_';</font></i></div><div><i><font size="1">vol = ft_prepare_headmodel(cfg, segmentedmri_template);</font></i></div><div><i><font size="1">save vol vol</font></i></div>
<div><i><font size="1"><br></font></i></div><div><i><font size="1">%Visualization of the head model</font></i></div><div><i><font size="1">figure;</font></i></div><div><i><font size="1">ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp </font></i></div>
<div><i><font size="1">figure;</font></i></div><div><i><font size="1">ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull</font></i></div><div><i><font size="1">figure;</font></i></div><div><i><font size="1">ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain This one looks like a cube</font></i></div>
<div><i><font size="1"><br></font></i></div><div><i><font size="1">% Align electrodes </font></i></div><div><i><font size="1">elec = ft_read_sens('template\electrode\standard_1020.elc'); </font></i></div><div>
<i><font size="1">% load volume conduction model</font></i></div>
<div><i><font size="1">% load vol; </font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">%interactive allignment</font></i></div><div><i><font size="1">cfg = [];</font></i></div>
<div><i><font size="1">cfg.method = 'interactive';</font></i></div><div><i><font size="1">cfg.elec = elec;</font></i></div><div><i><font size="1">cfg.headshape = vol.bnd(1);</font></i></div><div><i><font size="1">elec_aligned = ft_electroderealign(cfg);</font></i></div>
<div><i><font size="1"><br></font></i></div><div><i><font size="1">save elec_aligned elec_aligned</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">% Prepare leadfield</font></i></div><div>
<i><font size="1">load data_TF</font></i></div><div><i><font size="1">cfg=[];</font></i></div><div><i><font size="1">cfg.vol = vol; %structure with volume conduction model</font></i></div><div><i><font size="1">cfg.elec = elec_aligned;%structure with electrode positions</font></i></div>
<div><i><font size="1">[grid] = ft_prepare_leadfield(cfg, data_TF);</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">% Find source</font></i></div><div><i><font size="1">cfg = []; </font></i></div>
<div><i><font size="1">cfg.method = 'dics';</font></i></div><div><i><font size="1">cfg.frequency = 25; </font></i></div><div><i><font size="1">cfg.grid = grid; </font></i></div><div><i><font size="1">cfg.vol = vol;</font></i></div>
<div><i><font size="1">cfg.latency = .4;%single number in seconds, for time-frequency analysis</font></i></div><div><i><font size="1">cfg.dics.projectnoise = 'yes';</font></i></div><div><i><font size="1">cfg.dics.lambda = 0;</font></i></div>
<div><i><font size="1">cfg.elec = elec_aligned;%structure with electrode positions</font></i></div><div><i><font size="1"><br></font></i></div><div><i><font size="1">sourceTF = ft_sourceanalysis(cfg, data_TF);</font></i></div>
</blockquote><div dir="ltr" style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div><div>I am using <i>wavelet </i>with a <i>fourier</i> output for the time-frequency analysis (<i>data_TF)</i>. Do you have any idea what might be wrong here?</div>
<div><br></div><div>I also have a more general question. What type of time-frequency data can be input to source analysis? <i>ft_freqanalysis</i> provides power, power and cross-spectra, and complex fourier outputs. But is source-localization based on only power data correct? I couldn't find any explanations regarding this issue in the tutorial.</div>
</div><div><br></div><div>I look forward to hearing from anyone who might have ideas about any of these issues! </div></div><br clear="all" style="font-family:arial,sans-serif;font-size:13px"><div style="font-family:arial,sans-serif;font-size:13px">
Many thanks,</div><div class="" style="font-family:arial,sans-serif;font-size:13px"></div></div><div><br></div>-- <br>Azadeh HajiHosseini<br><br>
</div>