How to enter the path of the folder that has the raw data to be analyzed

28 views (last 30 days)
Hello I am new to MATLAB and am sure this is a simple question. I am trying to use the MADE pipeline code to analyse some EEG data and keep getting the same error code:
Index exceeds the number of array elements (0).
Error in MADE_pipeline_v1_0 (line 131)
[filepath,name,ext] = fileparts(char(datafile_names{1}));
This is for the section of code that looks like this:
%% Read files to analyses
datafile_names=dir(rawdata_location);
datafile_names=datafile_names(~ismember({datafile_names.name},{'.'}));
datafile_names={datafile_names.name};
[filepath,name,ext] = fileparts(char(datafile_names{1}));
My tutor suggested it was because the rawdata_location had been coded wrong. This is the code I have wrriten for that section:
clear % clear matlab workspace
clc % clear matlab command window
addpath(genpath(('Users/ elinorbaldwin/ Desktop/ eeglab2021.1')))
eeglab
rawdata_location ='C:Users\ elinorbaldwin\ Desktop\ eeglab2021.1\ Data';
output_location ='C:\ Users\ elinorbaldwin\ Desktop\ Output';
channel_locations ='C:\ Users\ elinorbaldwin\ Desktop\ eeglab2021.1\ plugins\ MADE-EEG-preprocessing-pipeline-master\ channel location files';
Does anyone have any ideas why I keep getting this error code?

Answers (1)

Voss
Voss on 28 Jan 2022
Edited: Voss on 28 Jan 2022
The problem is that dir() returns an empty struct array because the directory you gave it doesn't exist.
You can fix this by giving dir() directories that do, in fact, exist, by making sure your directories are written correctly.
For instance,
rawdata_location ='C:Users\ elinorbaldwin\ Desktop\ eeglab2021.1\ Data';
should be:
rawdata_location ='C:\Users\elinorbaldwin\Desktop\eeglab2021.1\Data';
(backslash after C: and no spaces before each folder).
etc. for the others.
This is assuming you're on Windows, but the line:
addpath(genpath(('Users/ elinorbaldwin/ Desktop/ eeglab2021.1')))
is not Windows-style directory syntax. So it may be that they all should be Linux/Unix-style separators. Regardless, all of those directories need to be accurate for your code to work.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!