1

I am trying to open a dialog box that prompts the user to select a file and then using that file in a function written for a matlab toolbox called EEGLAB. The code is as follows:

[F,PathName,FilterIndex] = uigetfile({'*.*','All Files(*.*)'}, 'Select your File ')
b = strcat(PathName,F)
Input = importdata(b)
FF = Input.filename;
%Loading the dataset into EEG lab. and rereferencing to Cz. 
EEG = pop_loadset('filename','FF','filepath','/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data/infant control01 and lance01 ref Fz - TF Analysis - all electrodes/');
EEG = eeg_checkset( EEG );

The problem I am encountering is in this line:

EEG = pop_loadset('filename','FF','filepath','/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data/infant control01 and lance01 ref Fz - TF Analysis - all electrodes/');

and this is the error message I get:

Error using load Unable to read file '/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data/infant control01 and lance01 ref Fz - TF Analysis - all electrodes/FF': no such file or directory. Error in pop_loadset (line 108) TMPVAR = load('-mat', filename); Error in newrereferencing (line 7) EEG = pop_loadset('filename','FF','filepath','/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data/infant control01 and lance01 ref Fz - TF Analysis - all electrodes/');

Now if I don't do the popup dialog window in the beginning (meaning I delete the first 4 lines of code I have and in the following line I have:

  EEG = pop_loadset('filename','206301L01.set','filepath','/Users/maheensiddiqui/Desktop/eeglab13_4_4b/EEG_data/Data/infant control01

and lance01 ref Fz - TF Analysis - all electrodes/');

i.e. I explicitly state the name of the file, the rest of the code works fine. I am not sure why this is happening... I need to run my code for about 20 different files and its very inefficient if the name needs to be typed in each time for it to work! (Especially if I will be sharing my code with other people).

Does anyone know why I might be getting this error? Could it be because of the file format? .set rather than a conventional format like .mat or .txt or whatever. But the .set format works when the filename is put in explicitly. I have also changed my directory to exclude spaces but that doesn't work either...

I would appreciate any help!

Greg
  • 5,422
  • 1
  • 27
  • 32
Maheen Siddiqui
  • 539
  • 8
  • 19
  • It might be because of the spaces inside the spaces inside the directory you are specifying: `infant control01 and lance01 ref Fz - TF Analysis - all electrodes/`. Maybe place this in a directory with **no spaces**? Make something simpler, like `tmp1`. – rayryeng Feb 22 '15 at 18:06
  • @rayryeng I tried removing the spaces and I also tried to create a new directory tmp1 and put it in there, nothing seems to work so far. – Maheen Siddiqui Feb 22 '15 at 18:12
  • 1
    `FF` is a variable, but you input it as a string (you use `'FF'`). Try to use : `EEG = pop_loadset('filename',FF,'filepath',...)`. If it doesn't work, look in the workspace the value of `FF`, it should be a string containing your file name. – Hoki Feb 22 '15 at 18:27
  • @Hoki - Wow I didn't see that. I didn't see this amongst the rather bad formatting lol. Nice catch. – rayryeng Feb 22 '15 at 21:53
  • 1
    @rayryeng, yes the formatting threw me off as well. I first tried to make sense of the bold error message (way too bold indeed) ... I was about to give up when I picked up the wrong string construction. It is a good thing the OP precised what worked in the line of code later (it showed that he tried to work it out in some way, and it confirmed my suspicions about the file name). – Hoki Feb 22 '15 at 22:04
  • @rayryeng I'm really sorry if it was difficult to understand! I'll be more careful and explicit about everything I post now.. sorry and thanks! – Maheen Siddiqui Feb 22 '15 at 22:46

1 Answers1

2

Thanks to Hoki's comment I was able to solve the problem. I was inputting the filename as a string when it was a variable.

EEG = pop_loadset('filename',FF,'filepath',...) using FF without 'FF' used it as the variable it was an fixed the problem.

Thanks Hoki.

Maheen Siddiqui
  • 539
  • 8
  • 19