Code not working on new laptop
8 次查看(过去 30 天)
显示 更早的评论
Lucie Aman
2024-7-2
Hello,
I have several scripts using EEGlab and one of its pluggin (mffimport). The scripts work well on other mac laptops (I've tried 3), but not on my new laptop (Macbookpro sonoma nov 2023). Any idea why?
I have changed the paths, dowloaded the necessarry toolboxes.
I have contacted EEGlab support who told me it's a matlab problem and I have contacted Matlab support who told me it is a code problem, not a software problem, but my code works well on other laptops...
THank you in advance for your help.
12 个评论
Stephen23
2024-7-3
编辑:Stephen23
2024-7-3
"Any idea why?"
Most likely because of your code, MATLAB, or your computer.
But because you did not give us any concrete information to help you (e.g. warning messages, error messages, the versions involved, the input values used, an MWE, a description of the observed behavior) we are limited to giving you a very general response to your very general question.
Lucie Aman
2024-7-3
编辑:Walter Roberson
2024-7-8
thank you. I haven't given any details because I have multiple errors when I try to shunt some steps of the code using the GUI.
The main script is calle pipelineMMN.m the first section establishes the directory and the path to the folder (loadpathMMN.m). The second section calls EEGlab and the MFFImport plugin to import the PiPWS_PWS023.mff file. The third section filters (this works) and epochs(doesn't work) the continuous EEG recording calling the script epoch_MMN.m
- Let's start with the first error: I am using a script calling EEGlab and the MFFImport plugin to import mff files and convert them to get a .set and a .fdt file.
the error is Undefined function 'pop_mffimport' for input arguments of type 'char'.
Error in dataimport_MMN (line 16)
EEG = pop_mffimport(sprintf('%s%s', filepath, filename), 'code'); %needs MFFMatlabIO2.01 plugin
Error in pipelineMMN (line 49)
dataimport_MMN(basenames{i}, raw_dir)
I have tried to uninstall EEGlab and the MFFimport plugin, put them in different folders, but it seems that matlab doesn't recognise the function.
- The second error when I import the file manually and try to epoch my EEG file, is the following:
Error using pop_epoch (line 279)
pop_epoch(): empty epoch range (no epochs were found).
Error in epoch_MMN (line 114)
EEG = pop_epoch(EEG,{},opt.timewindow,'eventindices',selectevents);
Error in pipelineMMN (line 58)
epoch_MMN(basenames{i}, 'indir', imp_dir, 'outdir', epo_dir, 'timewindow', [-0.1 0.6], 'lpfreq',
20)
It seems matlab cannot find epochs, but when I check using the GUI, I can see the epochs markers.
Many thanks for your help.
Stephen23
2024-7-3
"but it seems that matlab doesn't recognise the function."
Check that the MFFImport folder is on the MATLAB search path.
Lucie Aman
2024-7-3
I have added it to the path in right clicking on the folder and selected add folder and subfolder. Should I do anything different?
Andreas Goser
2024-7-3
I recommend to check (again) if the different machines run the exact same code. I know it might be cumbersome debugging, but in my experience this is likely.
Stephen23
2024-7-3
编辑:Stephen23
2024-7-3
"I have added it to the path in right clicking on the folder and selected add folder and subfolder."
After adding the MFFimport folder to the search path:
- check that pop_mffimport can be called from the command line,
- call dbstop if error, run your code, check the search path after the error occurs (e.g. using path).
Lucie Aman
2024-7-8
The pop_mffimport function can be called from the command line.The problem seems to come from finding events (= epochs). I have highlighted the problematic line in the code below.
function dataimport_MMN(mfffiles, indir)
% Import mff files
dbstop if error
filepath = [indir filesep];
basename = mfffiles(1:19);
if isempty(mfffiles)
error('No files found to import!\n');
end
filename = mfffiles;
fprintf('\nProcessing %s.\n\n', mfffiles);
EEG = pop_mffimport(sprintf('%s%s', filepath, filename), 'code'); %needs MFFMatlabIO2.01 plugin
%Add marker at 5th tone (move to 600ms because S1@0ms, S2@150ms,
%S3@300, S4@450, S5@600ms)
fprintf('Adding markers to 5th tone.\n');
events = {'LAX', 'LAY', 'LBX', 'LBY', 'RAX', 'RAY', 'RBX', 'RBY'};
EEG.eventOrig = EEG.event; This is the bit not working
f = fieldnames(EEG.eventOrig)';
f{2,1} = {};
EEG.event = struct(f{:});
c = 1;
for q = 1:length(EEG.eventOrig)
cont = contains(events, EEG.eventOrig(q).type(1:3));
if (sum(cont))==1 % istrue fct but doesn't work anymore%
EEG.event(c) = EEG.eventOrig(q);
c = c+1;
EEG.event(c) = EEG.eventOrig(q);
EEG.event(c).type = [EEG.event(c).type '_5'];
EEG.event(c).latency = EEG.eventOrig(q).latency + 600*(EEG.srate/1000); %onset of 5th sound is 600ms after onset of 1st
c = c+1;
else
EEG.event(c) = EEG.eventOrig(q);
end
end
EEG.setname = sprintf('%s_orig',basename);
EEG.filename = sprintf('%s_orig.set',basename);
EEG.filepath = filepath;
loadPathMMN;
fprintf('Saving %s%s.\n',[filepath '/Analysis/Imported/'], EEG.filename);
pop_saveset(EEG,'filename', EEG.filename, 'filepath', [filepath '/Analysis/Imported'],'version','7.3');
Steven Lord
2024-7-8
What happens when you run the "problematic line"?
- Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
- Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
- Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
Lucie Aman
2024-7-8
Thank you Steven for your reply.
when I run the import section of my main pipeline script (pipeline_MMN), it calls a script called dataimport_MMN. Please see below the full error message when I try to run the import section of pipeline_MMN
Processing PiPWS_PWS023_GloLoc.
Make sure you call this function with the full MFF ressource path name ******
Error using mff_importsignal (line 218)
Error: Can not open the signal resource.\n
Error in mff_import (line 85)
[floatData, allDataSize, srate, nchans] = mff_importsignal(mffFile);
Error in pop_mffimport (line 65)
EEG = mff_import(fileName);
Error in dataimport_MMN (line 16)
EEG = pop_mffimport(sprintf('%s%s', filepath, filename), 'code'); %needs MFFMatlabIO2.01 plugin
Error in pipelineMMN (line 49)
dataimport_MMN(basenames{i}, raw_dir)
Stephen23
2024-7-8
Compare the search path before and after the error occurs. Does it change? If so, find out where.
Stephen23
2024-7-9
编辑:Stephen23
2024-7-9
Follow these steps:
- Try calling the function (from the command line in normal mode)
- Save the path in a MAT file.
- Call DBSTOP IF ERROR
- Run the code
- Try calling the function (from the command line in debug mode)
- Save the path in a MAT file.
- Upload the MAT files here.
- Lets us know the results of each previous step.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)