Error in running loop for importing .cnt data file for multiple files

조회 수: 6 (최근 30일)
Luke Pezanko
Luke Pezanko 2020년 10월 20일
답변: Joana 2021년 10월 4일
Hello,
I am attempting to run a simple loop through EEGlab and am able to run each line of code individually but I encounter an error in an attempt to run a loop that imports, runs localization command, and save. The first subject can correctly be called and saved, however, when moving on to the next subject my script is unable to do so due to the following three errors:
Thank you in advance!
eeglab: options file is ~/eeg_options.m
EEGLAB warning: there can be only one EEGLAB window, closing old one
Retrieving plugin versions from server...
Retreiving download statistics...
EEGLAB: adding "Fieldtrip-lite" to the path; subfolders (if any) might be missing from the path
EEGLAB: adding "ICLabel" v1.2.6 (see >> help eegplugin_iclabel)
EEGLAB: adding "clean_rawdata" v2.2 (see >> help eegplugin_clean_rawdata)
EEGLAB: adding "dipfit" v3.3 (see >> help eegplugin_dipfit) - new version 3.4 available
EEGLAB: adding "eeglab_plugin_aar-master" v? (see >> help eegplugin_aar)
EEGLAB: adding "firfilt" v2.4 (see >> help eegplugin_firfilt)
EEGLAB: adding "neuroscanio" v1.3 (see >> help eegplugin_neuroscanio)
You are using the latest version of EEGLAB.
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in loadcnt (line 111)
h.rev = fread(fid,12,'char');
Error in pop_loadcnt (line 130)
r = loadcnt( fullFileName, varargin{:});
here is a copy of my script:
homefolder = '/Volumes/Backup Plus/BMC_Data/YA_CNT_Files';
datafolder = '/Volumes/Backup Plus/BMC_Data/YA_CNT_Files';
cd(datafolder);
Files = dir('*.cnt');
cd(datafolder);
for i=1:length(Files)
[ALLEEG, EEG, ~, ALLCOM] = eeglab;
FileName = Files(i).name;
cd(datafolder);
thisfilename = FileName;
Ind1 = find(FileName == '.');
basefilename = thisfilename(1:Ind1-1);
EEG = pop_loadcnt('thisfilename', 'dataformat', 'auto', 'memmapfile', '');
EEG.setname= [basefilename '.set'];
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0,'setname',EEG.setname,'gui','off');
EEG = eeg_checkset( EEG );
[ALLEEG, EEG, CURRENTSET] = eeg_store(ALLEEG, EEG);
eeglab redraw
counter = 1;
EEG=pop_chanedit(EEG, 'lookup','/Users/lpez/Documents/MATLAB/eeglab2020_0/plugins/dipfit/standard_BESA/standard-10-5-cap385.elp');
EEG = eeg_checkset( EEG );
[ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET);
EEG.setname = [basefilename '_1.set'];
pop_saveset( EEG, 'filename',EEG.setname,'filepath', datafolder);
clear EEG ALLEEG CURRENTSET
end
  댓글 수: 1
Stephen23
Stephen23 2020년 10월 20일
편집: Stephen23 2020년 10월 20일
Ugh, that cd is a bad omen... why not just provide an absolute/relative filename? That might resolve the issue.
Tip: use fileparts rather than messing about locating the period character to split the file-name and file-extension.

댓글을 달려면 로그인하십시오.

답변 (1개)

Joana
Joana 2021년 10월 4일
Hey Luke
Did you end up solving this problem.?
Currently i am facing the exact same error actually.

카테고리

Help CenterFile Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by