Problem : loading external list

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem : loading external list

Emilie04
Hello everybody,

My script functions perfectly on MATLAB, but in my lab, I have to test on Octave. So I transform my script for that it's conform to Octave (the difference is only, I think, the command to load external lists).

The script runs at the beginning, but when it arrives at the moment where it has to load the file in .txt, nothing happens (in bold in the script beside).

Here, this is a part of my script. Have you an idea of what is dysfunctioning? Thank you very much

w=Screen('OpenWindow', 0);
cycleRefresh=Screen('GetFlipInterval', w);

HideCursor

[width, height]=Screen('WindowSize', w);

%% ETAPE 2: INSTRUCTIONS

instruction=imread('Instruction1.jpg');
Screen(w, 'FillRect', [255, 255, 255])
Screen('Putimage', w, instruction)
Screen(w, 'Flip')
[secs, keyCode, deltaSecs]=KbWait
WaitSecs(0.3)

%% ETAPE 4 : IMPORTATION DES FICHIERS

items=[];
        fid = fopen('horlogealea.txt');
                while ~feof(fid)
                        temp=sscanf(fgetl(fid), '%s');
                        items=[items;temp];
                        temp=[];
                end
        fclose(fid);
items = cellstr(items);


nItems=length(items); % spécifie la longueur de la liste
tex=zeros(1,nItems);% Textures


Order=randi(length(items)):length(items) % Premier stimulus aléatoire, puis suite de la liste

stimuli=[];
        fid = fopen('horloge.txt');
                while ~feof(fid)
                        temp=sscanf(fgetl(fid), '%s');
                        stimuli=[stimuli;temp];
                        temp=[];
                end
        fclose(fid);
stimuli = cellstr(stimuli);


    nStim=length(stimuli);
    texstim=zeros(1,nStim);

    vbl=Screen(w, 'Flip');

    %% ETAPE 5 : HORLOGE AL»ATOIRE

            for g=Order
                img=imread(items{g});
                tex(g)=Screen('MakeTexture', w, img); %Faire les textures
                Screen('drawtexture', w, tex(g))
                vbl=Screen(w, 'Flip', vbl+(2.5*cycleRefresh));
                KbCheck;    
            end

...
Reply | Threaded
Open this post in threaded view
|

Re: Problem : loading external list

Juan Pablo Carbajal-2
On Fri, Dec 7, 2012 at 6:46 PM, Emilie04 <[hidden email]> wrote:

> Hello everybody,
>
> My script functions perfectly on MATLAB, but in my lab, I have to test on
> Octave. So I transform my script for that it's conform to Octave (the
> difference is only, I think, the command to load external lists).
>
> The script runs at the beginning, but when it arrives at the moment where it
> has to load the file in .txt, nothing happens (in bold in the script
> beside).
>
> Here, this is a part of my script. Have you an idea of what is
> dysfunctioning? Thank you very much
>
> w=Screen('OpenWindow', 0);
> cycleRefresh=Screen('GetFlipInterval', w);
>
> HideCursor
>
> [width, height]=Screen('WindowSize', w);
>
> %% ETAPE 2: INSTRUCTIONS
>
> instruction=imread('Instruction1.jpg');
> Screen(w, 'FillRect', [255, 255, 255])
> Screen('Putimage', w, instruction)
> Screen(w, 'Flip')
> [secs, keyCode, deltaSecs]=KbWait
> WaitSecs(0.3)
>
> %% ETAPE 4 : IMPORTATION DES FICHIERS
>
> *items=[];
>         fid = fopen('horlogealea.txt');
>                 while ~feof(fid)
>                         temp=sscanf(fgetl(fid), '%s');
>                         items=[items;temp];
>                         temp=[];
>                 end
>         fclose(fid);
> items = cellstr(items);*
>
> nItems=length(items); % spécifie la longueur de la liste
> tex=zeros(1,nItems);% Textures
>
>
> Order=randi(length(items)):length(items) % Premier stimulus aléatoire, puis
> suite de la liste
>
> *stimuli=[];
>         fid = fopen('horloge.txt');
>                 while ~feof(fid)
>                         temp=sscanf(fgetl(fid), '%s');
>                         stimuli=[stimuli;temp];
>                         temp=[];
>                 end
>         fclose(fid);
> stimuli = cellstr(stimuli);*
>
>     nStim=length(stimuli);
>     texstim=zeros(1,nStim);
>
>     vbl=Screen(w, 'Flip');
>
>     %% ETAPE 5 : HORLOGE AL»ATOIRE
>
>             for g=Order
>                 img=imread(items{g});
>                 tex(g)=Screen('MakeTexture', w, img); %Faire les textures
>                 Screen('drawtexture', w, tex(g))
>                 vbl=Screen(w, 'Flip', vbl+(2.5*cycleRefresh));
>                 KbCheck;
>             end
>
> ...
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/Problem-loading-external-list-tp4647632.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

Hi,
The part where you read the txt file looks alright, maybe redundant.
fgelt already gives you a string so instead of calling sscanf on top
of fgetl seems to be useless. If you want to read formatted input, you
could use fscanf.

There are many functions in your script that will not work in Octave.
Are you sure the failure is not in one of those?


Cheers
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem : loading external list

Emilie04
This post has NOT been accepted by the mailing list yet.
Aie, so the problem could be the functions. This is very big problem. I thought that, because it's the PTB, there are no differences if the script is reading by Octave or Matlab.

I could replace some commands otherwise, but I use also the 'Ask' command with 'GetChar' (it doesn't appear on this script but I use it), which is very important.

reply=Ask(window,'Who are you?',[],[],'GetChar',RectLeft,RectTop); % Accept keyboard input, echo it to screen.

I suppose that this command doesn't function on Octave?

Thank you,

Emilie