You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Code not working on new laptop
8 views (last 30 days)
Show older comments
Lucie Aman
on 2 Jul 2024
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 Comments
Stephen23
on 3 Jul 2024
Edited: Stephen23
on 3 Jul 2024
"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
on 3 Jul 2024
Edited: Walter Roberson
on 8 Jul 2024
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.
Lucie Aman
on 3 Jul 2024
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
on 3 Jul 2024
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
on 3 Jul 2024
Edited: Stephen23
on 3 Jul 2024
"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
on 8 Jul 2024
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
on 8 Jul 2024
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
on 8 Jul 2024
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)
Lucie Aman
on 9 Jul 2024
no it does not change
Stephen23
on 9 Jul 2024
Edited: Stephen23
on 9 Jul 2024
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.
Answers (0)
See Also
Categories
Find more on EEG/MEG/ECoG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)