[Eeglablist] FW: script to batch process multiple Neuroscan CNT files

Cedric Cannard ccannard at protonmail.com
Tue Mar 14 11:16:58 PDT 2023


Hi Jeff,

There was a typo (missing parenthesis to close fullfile call). 

You need to edit with something like this for going into subfolders. Edit number of sessions and runs below:

dataFolder = 'D:\Sorg memory project\BU data\cue_reactivity_1';
nSessions = 3;  % edit with your number of sessions here
nRuns = 3;      % edit with your number of runs here

eeglab; close;
for iSession = 1:nSessions
    session = sprintf('s%2.2d', iSession);
    for iRun = 1:nRuns
        run = sprintf('run%g', iRun);
        filepath = fullfile(dataFolder, session, run);
        cd(filepath)
        fileNames = dir('*.cnt');
        fileNames = {fileNames.name};

        for iFile = 1:length(fileNames)
            filename = fileNames{iFile};
            EEG = pop_loadcnt(fullfile(filepath, filename), 'dataformat', 'auto', 'memmapfile', '');
            EEG = pop_saveset(EEG,'filename',[filename(1:end-5) '.set'],'filepath',filepath);
        end
    end
end

And check out the pipelines Arno sent ;)

Cedric



------- Original Message -------
On Tuesday, March 14th, 2023 at 9:48 AM, Jeffrey Eriksen <jeriksen at downeurobiology.org> wrote:


> Hi
> 
> Cedric
> 
> 
> ,
> 
> Thank you for writing out a whole script for me. If it is not too much to ask, can you modify it to scan all subfolders? I was perhaps not totally clear in my initial request. The CNT files are nested in several layers by subject and run.
> 
> More importantly, I encountered an error in the call to loadcnt. I do not presume that you know the inner workings of loadcnt, but could you take a look at the error message and see if it is something you could figure out? In the meantime I will look to see who wrote it and consider writing them directly.
> 
> -Jeff
> 
> My version (for a particular subject and run):
> % scan for and convert CNT files to SET files
> 
> dataFolder = 'D:\Sorg memory project\BU data\cue_reactivity_1\s03\run1';
> cd(dataFolder)
> filenames = dir('*.cnt');
> filenames = {filenames.name};
> eeglab; close;
> 
> for iFile = 1:length(filenames)
> filename = filenames{iFile};
> EEG = pop_loadcnt(fullfile(dataFolder, filename, 'dataformat', 'auto', 'memmapfile', ''));
> EEG = pop_saveset(EEG,'filename',[filename(1:end-5) '.set'],'filepath',dataFolder);
> end
> disp('Done!')
> 
> output to command line:
> 
> > > scan_convert
> 
> eeglab: options file is C:\Users\Jeff\eeg_options.m
> Retrieving plugin versions from server...
> Retrieving download statistics...
> EEGLAB: adding "Biosig" v3.8.1 to the path
> EEGLAB: adding "Cleanline" v2.00 (see >> help eegplugin_cleanline)
> 
> EEGLAB: adding "Fileio" v20230309 to the path
> EEGLAB: adding "ICLabel" v1.4 (see >> help eegplugin_iclabel)
> 
> EEGLAB: adding "MFFMatlabIO" v4.1 (see >> help eegplugin_mffmatlabio)
> 
> EEGLAB: adding "MFFimport" v2.3 (see >> help eegplugin_mffimport)
> 
> EEGLAB: adding "clean_rawdata" v2.8 (see >> help eegplugin_clean_rawdata)
> 
> EEGLAB: adding "dipfit" v5.0 (see >> help eegplugin_dipfit)
> 
> EEGLAB: adding "egilegacy" v1.0 (see >> help eegplugin_egilegacy)
> 
> EEGLAB: adding "firfilt" v2.7.1 (see >> help eegplugin_firfilt)
> 
> EEGLAB: adding "neuroscanio" v1.6 (see >> help eegplugin_neuroscanio)
> 
> You are using the latest version of EEGLAB.
> 9 for iFile = 1:length(filenames)
> Error using fread
> Invalid file identifier. Use fopen to generate a valid file identifier.
> 
> Error in loadcnt (line 110)
> h.rev = fread(fid,12,'char');
> 
> Error in pop_loadcnt (line 132)
> r = loadcnt( fullFileName);
> 
> Error in scan_convert (line 11)
> EEG = pop_loadcnt(fullfile(dataFolder, filename, 'dataformat', 'auto', 'memmapfile', ''));
> 
> 
> 
> -----Original Message-----
> From: Cedric Cannard ccannard at protonmail.com
> 
> Sent: Sunday, March 12, 2023 12:13 PM
> To: Jeffrey Eriksen jeriksen at downeurobiology.org
> 
> Cc: eeglablist at sccn.ucsd.edu
> Subject: Re: [Eeglablist] FW: script to batch process multiple Neuroscan CNT files
> 
> Hi Jeff,
> 
> After installing the Neuroscanio plugin, this should do:
> 
> dataFolder = 'pathToYourDataFolder';
> cd(dataFolder )
> filenames = dir('*.cnt');
> filenames = {filenames.name};
> eeglab; close;
> 
> for iFile = 1:length(filenames)
> filename = filenames{iFile};
> EEG = pop_loadcnt(fullfile(dataFolder, filename, 'dataformat', 'auto', 'memmapfile', '');
> 
> EEG = pop_saveset(EEG,'filename',[filename(1:end-5) '.set'],'filepath',dataFolder);
> 
> end
> disp('Done!')
> 
> 
> Cedric
> 
> 
> 
> ------- Original Message -------
> On Friday, March 10th, 2023 at 10:04 AM, Jeffrey Eriksen jeriksen at downeurobiology.org wrote:
> 
> 
> 
> > Hello,
> > 
> > I have 327 Neuroscan CNT files. Does anyone know of a script that I could use or modify to do the following:
> > 
> > 1. Scan a set of folders and find all the CNT files 2. Import them
> > using the neuroscanio plugin 3. Save them as SET format
> > 
> > Thanks,
> > -Jeff Eriksen
> > 
> > ________________________________
> > IMPORTANT NOTICE: This communication, including any attachment, contains important information that may be confidential or privileged, and is intended solely for the entity or individual to whom it is addressed. If you are not the intended recipient, you should contact the sender and delete this message. Any unauthorized disclosure, copying, or distribution of this message is strictly prohibited. Nothing in this email, including any attachment, is intended to be a legally binding signature.
> > _______________________________________________
> > Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> > To unsubscribe, send an empty email to
> > eeglablist-unsubscribe at sccn.ucsd.edu
> > For digest mode, send an email with the subject "set digest mime" to
> > eeglablist-request at sccn.ucsd.edu



More information about the eeglablist mailing list