nightcored the sh*t out of it

nightcored the sh*t out of it

//binnenhalen van de WAV-file
[testsign,Fs,bits]=wavread("D:\Programs\scilab-5.5.2\modules\sound\demos\BART2.wav");

samplespeed = Fs;
delay = 1500; // choose the echo time of the sound (ms)
echotime = [delay/1000] * samplespeed;

//for loop voor de lengte van het audio-signaal
for n=1:length(testsign),
    if n <= echotime  then       //tijd wachten voor echo begint
        outputO = testsign(n); //buffer met origineel
        testsign(n)= outputO;
    elseif n > echotime then  //na bepaalde tijd start de echo

        //testsign gelijkstellen aan testsign + signaal van echotime sampeles terug
         testsign(n)=[testsign(n) + (testsign(n-echotime)*0.7 )];
end,

end

playsnd(testsign,samplespeed); //afspelen van het audio-signaal met echo
// playsnd(testsign,samplespeed * 1.6); //afspelen van het audio-signaal met echo in nightcore mode


sb140: #i114669# appears be duplicate of fixed i114718, so re-enabling test


Consider 'ok' status in error handling for ADC

function [x,y,typ] = mdaq_adc(job,arg1,arg2)
    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        channel_desc = adc_info.channel;
        rate_desc = adc_info.rate;
        resolution_desc = adc_info.resolution;
        range_desc = adc_info.c_params.c_range_desc;
        range_spec_opt = [];
        range_desc = "";
        for i = 1:size(adc_info.c_params.c_range_desc, "r")
            range_spec_opt = [range_spec_opt; string(i) + ": " + adc_info.c_params.c_range_desc(i)];
        end
    else
        channel_desc = "Unknown";
        rate_desc = "Unknown";
        resolution_desc = "Unknown";
        range_desc = "Unknown";
        range_spec_opt = "Unknown";
    end

    adc_desc = ["This block reads MicroDAQ analog inputs (AI).";
    "Block detects MicroDAQ analog inputs type and allows";
    "channel, input range and measurement type selection.";
    "Single or multiply channels can be selected by providing";
    "vector with channel numbers. Input range can be selected";
    "and will be applied for all selected channels."
    "Single-ended or differential measurement type can be selected.";
    "In order to select differential mode ''Differential'' parameter";
    "has to be set to 1.";
    "";
    "Oversampling can be used to increase measurement resolution.";
    "Oversampling factor: ";
    "0 - disabled";
    "1 - 4 ADC readings   - 1 bit accuracy ";
    "2 - 16 ADC readings  - 2 bits accuracy";
    "3 - 64 ADC readings  - 3 bits accuracy";
    "4 - 256 ADC readings - 4 bits accuracy";
    "";
    "output - value in volts";
    "";
    "Analog inputs parameters:";
    "Channels: "+channel_desc;
    "Max sample rate: "+rate_desc;
    "Resolution: "+resolution_desc;
    "";
    "Input range:";
    range_spec_opt;
    "";
    "Set block parameters:"];
    x=[];y=[];typ=[];
    select job
    case 'set' then
        x=arg1
        model=arg1.model;
        graphics=arg1.graphics;
        exprs=graphics.exprs;
        while %t do
            try
                getversion('scilab');
                [ok, channel, adc_range, differential, oversamp_count,exprs]=..
                scicos_getvalue(adc_desc,..
                ['Channels:';
                'Range:';
                'Differential:';
                'Oversampling:'],..
                list('vec',-1,'vec',1,'vec',1,'vec',1),exprs)
            catch
                [ok, channel, adc_range, differential, oversamp_count,exprs]=..
                scicos_getvalue(adc_desc,..
                ['Channels:';
                'Range:';
                'Differential:';
                'Oversampling:'],..
                list('vec',-1,'vec',1,'vec',1,'vec',1),exprs)
            end

            if ~ok then
                break
            end

            n_channels = size(channel,"*");

            if %microdaq.private.mdaq_hwid <> [] then
                adc_id = %microdaq.private.mdaq_hwid(2);
                if ok & (find(adc_info.id == get_adc_list()) == []) then
                    ok = %f;
                    message("Configuration not detected - run mdaq_hwinfo and try again!");
                end

                // check Channel parameter
                adc_ch_count = strtod(adc_info.channel);

                if differential == 1 then
                    adc_ch_count = adc_ch_count / 2;
                end

                if ok & (size(channel, 'r') > 1) then
                    ok = %f;
                    error_msg = 'Wrong channel vector - single row vector expected!';
                    message(error_msg);
                end

                n_channels = size(channel, 'c');
                if ok & (n_channels > adc_ch_count) then
                    ok = %f;
                    error_msg = 'Too many channels selected!';
                    message(error_msg);
                end

                if ok & (max(channel) > adc_ch_count) | (min(channel) < 1) then
                    ok = %f;
                    error_msg = 'Wrong channel number selected!';
                    message(error_msg);
                end

                // check Range parameter
                if ok & (size(adc_range, 'r') > 1) then
                    ok = %f;
                    error_msg = 'Wrong range vector - single row vector expected!';
                    message(error_msg);
                end

                adc_range_size = size(adc_range, 'c');
                if ok & (adc_range_size > 1) & (adc_range_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong range vector - size should be same as Channel vector!';
                    message(error_msg);
                end

                if ok & (adc_range > size(adc_info.c_params.c_range)) | (adc_range == 0) then
                    ok = %f;
                    message("Wrong range selected");
                else
                    if ok & (differential == 1) & (adc_info.c_params.c_diff(adc_range) <> 1) then
                        ok = %f;
                        message("Converter does not support differential mode!");
                    end
                end

                if ok & (differential <> 0) & (differential <> 1) then
                    ok = %f;
                    message("Wrong mode selected - use 0 or 1 to set single-ended or differential mode!");
                end

                if ok & (oversamp_count < 0) | (oversamp_count > 4) then
                    ok = %f;
                    message("Wrong oversampling facator selected!");
                end
            else
                ok = %f;
                message('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
            end

            if ok then
                [model,graphics,ok] = check_io(model,graphics, [], n_channels, 1, []);
                graphics.exprs = exprs;

                adc_range_sim = adc_range;
                adc_range = adc_info.c_params.c_range(adc_range_sim);
                adc_polarity = adc_info.c_params.c_bipolar(adc_range_sim);

                if differential == 1 then
                    differential = 29;
                else
                    differential = 28;
                end

                model.ipar = [adc_range; adc_polarity; adc_range_sim; differential; oversamp_count; n_channels; channel'];

                model.dstate = [];
                x.graphics = graphics;
                x.model = model;
                break;
            end
        end
    case 'define' then
        adc_converter_str = [];
        adc_range = 1;
        adc_polarity = 1;
        adc_range_sim = 1;
        differential = 0;
        oversamp_count= 0;
        n_channels = 1;
        channel = 1;
        model=scicos_model()
        model.sim=list('mdaq_adc_sim',5)
        model.out=[1]
        model.outtyp=[1]
        model.evtin=1
        model.rpar=[]
        model.ipar=[ 0; 24; 1; 28; oversamp_count; n_channels; channel];
        model.dstate=[];
        model.blocktype='d'
        model.dep_ut=[%t %f]
        exprs=[sci2exp(channel); sci2exp(adc_range); sci2exp(differential); sci2exp(oversamp_count)];
        gr_i=['xstringb(orig(1),orig(2),[''CH: '' ; string(channel)],sz(1),sz(2),''fill'');']
        x=standard_define([4 3],model,exprs,gr_i)
        x.graphics.in_implicit=[];
        x.graphics.exprs=exprs;
        x.graphics.style=["blockWithLabel;verticalLabelPosition=center;displayedLabel=CH:%1$s;fontColor=#5f5f5f"]
    end
endfunction

function [x,y,typ] = mdaq_adc(job,arg1,arg2)
    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        channel_desc = adc_info.channel;
        rate_desc = adc_info.rate;
        resolution_desc = adc_info.resolution;
        range_desc = adc_info.c_params.c_range_desc;
        range_spec_opt = [];
        range_desc = "";
        for i = 1:size(adc_info.c_params.c_range_desc, "r")
            range_spec_opt = [range_spec_opt; string(i) + ": " + adc_info.c_params.c_range_desc(i)];
        end
    else
        channel_desc = "Unknown";
        rate_desc = "Unknown";
        resolution_desc = "Unknown";
        range_desc = "Unknown";
        range_spec_opt = "Unknown";
    end

    adc_desc = ["This block reads MicroDAQ analog inputs (AI).";
    "Block detects MicroDAQ analog inputs type and allows";
    "channel, input range and measurement type selection.";
    "Single or multiply channels can be selected by providing";
    "vector with channel numbers. Input range can be selected";
    "and will be applied for all selected channels."
    "Single-ended or differential measurement type can be selected.";
    "In order to select differential mode ''Differential'' parameter";
    "has to be set to 1.";
    "";
    "Oversampling can be used to increase measurement resolution.";
    "Oversampling factor: ";
    "0 - disabled";
    "1 - 4 ADC readings   - 1 bit accuracy ";
    "2 - 16 ADC readings  - 2 bits accuracy";
    "3 - 64 ADC readings  - 3 bits accuracy";
    "4 - 256 ADC readings - 4 bits accuracy";
    "";
    "output - value in volts";
    "";
    "Analog inputs parameters:";
    "Channels: "+channel_desc;
    "Max sample rate: "+rate_desc;
    "Resolution: "+resolution_desc;
    "";
    "Input range:";
    range_spec_opt;
    "";
    "Set block parameters:"];
    x=[];y=[];typ=[];
    select job
    case 'set' then
        x=arg1
        model=arg1.model;
        graphics=arg1.graphics;
        exprs=graphics.exprs;
        while %t do
            try
                getversion('scilab');
                [ok, channel, adc_range, differential, oversamp_count,exprs]=..
                scicos_getvalue(adc_desc,..
                ['Channels:';
                'Range:';
                'Differential:';
                'Oversampling:'],..
                list('vec',-1,'vec',1,'vec',1,'vec',1),exprs)
            catch
                [ok, channel, adc_range, differential, oversamp_count,exprs]=..
                scicos_getvalue(adc_desc,..
                ['Channels:';
                'Range:';
                'Differential:';
                'Oversampling:'],..
                list('vec',-1,'vec',1,'vec',1,'vec',1),exprs)
            end

            if ~ok then
                break
            end

            n_channels = size(channel,"*");

            if %microdaq.private.mdaq_hwid <> [] then
                adc_id = %microdaq.private.mdaq_hwid(2);
                if find(adc_info.id == get_adc_list()) == [] then
                    ok = %f;
                    message("Configuration not detected - run mdaq_hwinfo and try again!");
                end

                // check Channel parameter
                adc_ch_count = strtod(adc_info.channel);

                if differential == 1 then
                    adc_ch_count = adc_ch_count / 2;
                end

                if size(channel, 'r') > 1 then
                    ok = %f;
                    error_msg = 'Wrong channel vector - single row vector expected!';
                    message(error_msg);
                end

                n_channels = size(channel, 'c');
                if n_channels > adc_ch_count then
                    ok = %f;
                    error_msg = 'Too many channels selected!';
                    message(error_msg);
                end

                if max(channel) > adc_ch_count | min(channel) < 1 then
                    ok = %f;
                    error_msg = 'Wrong channel number selected!';
                    message(error_msg);
                end

                // check Range parameter
                if size(adc_range, 'r') > 1 then
                    ok = %f;
                    error_msg = 'Wrong range vector - single row vector expected!';
                    message(error_msg);
                end

                adc_range_size = size(adc_range, 'c');
                if adc_range_size > 1 & adc_range_size <> n_channels then
                    ok = %f;
                    error_msg = 'Wrong range vector - size should be same as Channel vector!';
                    message(error_msg);
                end

                if adc_range > size(adc_info.c_params.c_range) | adc_range == 0 then
                    ok = %f;
                    message("Wrong range selected");
                else
                    if differential == 1 & adc_info.c_params.c_diff(adc_range) <> 1 then
                        ok = %f;
                        message("Converter does not support differential mode!");
                    end
                end

                if differential <> 0 & differential <> 1 then
                    ok = %f;
                    message("Wrong mode selected - use 0 or 1 to set single-ended or differential mode!");
                end

                if oversamp_count < 0 | oversamp_count > 4 then
                    ok = %f;
                    message("Wrong oversampling facator selected!");
                end
            else
                ok = %f;
                message('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
            end

            if ok then
                [model,graphics,ok] = check_io(model,graphics, [], n_channels, 1, []);
                graphics.exprs = exprs;

                adc_range_sim = adc_range;
                adc_range = adc_info.c_params.c_range(adc_range_sim);
                adc_polarity = adc_info.c_params.c_bipolar(adc_range_sim);

                if differential == 1 then
                    differential = 29;
                else
                    differential = 28;
                end

                model.ipar = [adc_range; adc_polarity; adc_range_sim; differential; oversamp_count; n_channels; channel'];

                model.dstate = [];
                x.graphics = graphics;
                x.model = model;
                break;
            end
        end
    case 'define' then
        adc_converter_str = [];
        adc_range = 1;
        adc_polarity = 1;
        adc_range_sim = 1;
        differential = 0;
        oversamp_count= 0;
        n_channels = 1;
        channel = 1;
        model=scicos_model()
        model.sim=list('mdaq_adc_sim',5)
        model.out=[1]
        model.outtyp=[1]
        model.evtin=1
        model.rpar=[]
        model.ipar=[ 0; 24; 1; 28; oversamp_count; n_channels; channel];
        model.dstate=[];
        model.blocktype='d'
        model.dep_ut=[%t %f]
        exprs=[sci2exp(channel); sci2exp(adc_range); sci2exp(differential); sci2exp(oversamp_count)];
        gr_i=['xstringb(orig(1),orig(2),[''CH: '' ; string(channel)],sz(1),sz(2),''fill'');']
        x=standard_define([4 3],model,exprs,gr_i)
        x.graphics.in_implicit=[];
        x.graphics.exprs=exprs;
        x.graphics.style=["blockWithLabel;verticalLabelPosition=center;displayedLabel=CH:%1$s;fontColor=#5f5f5f"]
    end
endfunction


Handle AI scanning interruption

Handle AI scanning interruption

function  mdaq_ai_scan_init(arg1, arg2, arg3, arg4, arg5, arg6, arg7)
    global %microdaq;

    adc_channel_count_lut = [8,8,16,8,16];
    adc_polarity_e2000_lut = [%t,%f,%f,%f,%f];

    link_id = -1;
    if argn(2) == 6 then
        channels = arg1;
        ai_range = arg2;
        bipolar = arg3;
        differential = arg4;
        scan_freq = arg5;
        scan_time = arg6;
    end

    if argn(2) == 7 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        bipolar = arg4;
        differential = arg5;
        scan_freq = arg6;
        scan_time = arg7;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    mdaq_model = %microdaq.private.mdaq_hwid(1);
    mdaq_ai = %microdaq.private.mdaq_hwid(2);
    ch_config_ok = %t;

    ch_count = max(size(channels));
    if ch_count < 1 |...
       ch_count > adc_channel_count_lut(mdaq_ai) |...
       max(channels) > adc_channel_count_lut(mdaq_ai) then
        disp("ERROR: Wrong AI channel selected!")
        ch_config_ok = %f;
    end

    if bipolar == %f then
        if mdaq_model == 2000 & adc_polarity_e2000_lut(mdaq_ai) == %f then
            disp("ERROR: ADC doesn''t support unipolar mode!")
            ch_config_ok = %f;
        end
    end

    if argn(2) > 7 | argn(2) < 6 | ch_config_ok == %f then
        mprintf("Description:\n");
        mprintf("\tInit AI scan\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ai_scan_init(link_id, channels, range, bipolar, differential, frequency, time);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tchannels - analog input channels to read\n");
        mprintf("\trange - analog input range (5 or 10)\n");
        mprintf("\tbipolar - analog input polarity (%%T - bipolar, %%F - unipolar)\n");
        mprintf("\tdifferential - analog input mode (%%T - differential, %%F - single-ended)\n");
        mprintf("\tfrequency - analog input scan frequency\n");
        mprintf("\ttime - analog input scan duration in seconds\n");
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    s = size(channels);
    if s(1) > 1 then
        disp("ERROR: Wrong AI channel input parameter!")
    end

    if argn(2) == 6 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    if bipolar == %T then
        bipolar = 24;
    else
        bipolar = 25;
    end

    if ai_range == 5 then
        ai_range = 1;
    else
        ai_range = 0;
    end

    if differential == %T then
        differential = 29;
    else
        differential = 28;
    end

    result = [];
    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            differential, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    if result < 0 & result <> -88 then
            error(mdaq_error(result), 10000 + abs(result))
    else
        if result == -88 then
            disp("Warninng: AI scanning interrupted!")
            mdaq_ai_scan_stop()

            // time to terminate TCP connection
            sleep(200);

            result = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    ai_range, 4, "i",..
                    bipolar, 5, "i",..
                    differential, 6, "i",..
                    scan_freq, 7, "d",..
                    scan_time, 8, "d",..
                "out",..
                    [1, 1], 9, "i");
        end

        mprintf("Data acquisition session settings:\n");

        str = [];
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if differential == 0 then
            mprintf("Single Ended\n");
        else
            mprintf("Differential\n");
        end

        mprintf("\tRange:\t\t");
        if bipolar == 0 then
            mprintf("-%d to +%d Volts\n", ai_range, ai_range);
        else
            mprintf("0 to +%d Volts\n", ai_range);
        end

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d\n", scan_time * scan_freq);
        end
    end

    if argn(2) == 6 then
        mdaq_close(link_id);
    end

endfunction

function  mdaq_ai_scan_init(arg1, arg2, arg3, arg4, arg5, arg6, arg7)

    link_id = -1;

    if argn(2) == 6 then
        channels = arg1;
        ai_range = arg2;
        bipolar = arg3;
        adc_mode = arg4;
        scan_freq = arg5;
        scan_time = arg6;
    end

    if argn(2) == 7 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        bipolar = arg4;
        adc_mode = arg5;
        scan_freq = arg6;
        scan_time = arg7;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    if argn(2) > 7 | argn(2) < 6 then
        mprintf("Description:\n");
        mprintf("\tInit AI scan\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ai_scan_init(link_id, channels, range, bipolar, differential, frequency, time);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tchannels - analog input channels to read\n");
        mprintf("\trange - analog input range (5 or 10)\n");
        mprintf("\tbipolar - analog input polarity (%%T - bipolar, %%F - unipolar)\n");
        mprintf("\tdifferential - analog input mode (%%T - differential, %%F - single-ended)\n");
        mprintf("\tfrequency - analog input scan frequency\n");
        mprintf("\ttime - analog input scan duration in seconds\n");
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > 16 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    if max(channels) > 16 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    s = size(channels);
    if s(1) > 1 then
        disp("ERROR: Wrong AI channel input parameter!")
    end

    if argn(2) == 6 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    if bipolar == %T then
        bipolar = 0;
    else
        bipolar = 1;
    end

    if ai_range <> 5 then
        ai_range = 10;
    end

    if adc_mode == %T then
        adc_mode = 1;
    else
        adc_mode = 0;
    end
    result = [];

    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            adc_mode, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    if result < 0 then
        mdaq_error(result);
    else
        global %microdaq;
        mdaq_model = %microdaq.private.mdaq_hwid(1);
        mdaq_ai = %microdaq.private.mdaq_hwid(2);
        mprintf("Data acquisition session settings:\n");

        str = [];
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if adc_mode == 0 then
            mprintf("Single Ended\n");
        else
            mprintf("Differential\n");
        end

        mprintf("\tRange:\t\t");
        if bipolar == 0 then
            mprintf("-%d to +%d Volts\n", ai_range, ai_range);
        else
            mprintf("0 to +%d Volts\n", ai_range);
        end

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d", scan_time * scan_freq);
        end
    end

    if argn(2) == 6 then
        mdaq_close(link_id);
    end

endfunction


Poging 2

Poging 2

//binnenhalen van de WAV-file
[testsign,Fs,bits]=wavread("D:\Programs\scilab-5.5.2\modules\sound\demos\BART.wav");

//for loop voor de lengte van het audio-signaal
for n=1:length(testsign),
    if n <= 50000  then        //eerste 50.000 samples gewoon doorlaten
        outputO = testsign(n); //buffer met origineel
        testsign(n)= outputO;
    elseif n > 50000 then  //na 50.000 samples echo starten

        //testsign gelijkstellen aan testsign + signaal van 50.000 sampeles terug
         testsign(n)=[testsign(n) + (testsign(n-50000)*0.6 )];
end,

end
playsnd(testsign,44100); //afspelen van het audio-signaal met echo

[testsign,Fs,bits]=wavread("D:\Programs\scilab-5.5.2\modules\sound\demos\BART.wav");
//t = [1:1:length(testsign)]*1/Fs;
outputO = 0;
outputE= 0;
for n=1:length(testsign),
    if n <= 50000  then
        outputO = testsign(n);
        testsign(1)= outputO;

    elseif n > 50000 then
         testsign(n)=[testsign(n) + (testsign(n-50000)*0.6 )];
    elseif n > 100000 then

        testsign(n) = [testsign(n) + (testsign(n-50000)*0.6 ) + (testsign(n-100000)*0.7 )];
end,

end
playsnd(testsign,44100);


INTEGRATION: CWS unoapi1 (1.5.858); FILE MERGED 2007/10/11 19:34:05 cn 1.5.858.1: #i79479# update Lists

-o svx.SvxShapeDimensioning
#-o svx.SvxShapeControl
-o svx.SvxGraphicObject
-o svx.AccessibleGraphicShape
-o svx.AccessibleOLEShape
#-o svx.AccessiblePageShape
-o svx.AccessiblePresentationGraphicShape
-o svx.AccessiblePresentationOLEShape
#-o svx.AccessibleShape
#-o svx.GraphicExporter
-o svx.SvxDrawPage
#-o svx.SvxShape
-o svx.SvxShapeCircle
-o svx.SvxShapeCollection
#-o svx.SvxShapeConnector
-o svx.SvxShapeGroup
#-o svx.SvxShapePolyPolygon
#-o svx.SvxShapePolyPolygonBezier
-o svx.SvxUnoNumberingRules
-o svx.SvxUnoText
#-o svx.SvxUnoTextContent
-o svx.SvxUnoTextContentEnum
#-o svx.SvxUnoTextCursor
-o svx.SvxUnoTextField
#-o svx.SvxUnoTextRange
-o svx.SvxUnoTextRangeEnumeration
-o svx.AccessibleShape
-o svx.SvxGraphCtrlAccessibleContext
-o svx.AccessibleControlShape
### i58062 ###
-o svx.AccessibleEditableTextPara
### i57892 ###
#-o svx.AccessiblePresentationShape

-o svx.SvxShapeDimensioning
-o svx.SvxShapeControl
-o svx.SvxGraphicObject
-o svx.AccessibleGraphicShape
-o svx.AccessibleOLEShape
-o svx.AccessiblePageShape
-o svx.AccessiblePresentationGraphicShape
-o svx.AccessiblePresentationOLEShape
-o svx.AccessibleShape
-o svx.GraphicExporter
-o svx.SvxDrawPage
-o svx.SvxShape
-o svx.SvxShapeCircle
-o svx.SvxShapeCollection
-o svx.SvxShapeConnector
-o svx.SvxShapeGroup
-o svx.SvxShapePolyPolygon
-o svx.SvxShapePolyPolygonBezier
-o svx.SvxUnoNumberingRules
-o svx.SvxUnoText
-o svx.SvxUnoTextContent
-o svx.SvxUnoTextContentEnum
-o svx.SvxUnoTextCursor
-o svx.SvxUnoTextField
-o svx.SvxUnoTextRange
-o svx.SvxUnoTextRangeEnumeration
-o svx.AccessibleShape
-o svx.SvxGraphCtrlAccessibleContext
-o svx.AccessibleControlShape
### i58062 ###
#-o svx.AccessibleEditableTextPara
### i57892 ###
#-o svx.AccessiblePresentationShape


Add error handling for scanCount < 0

Add error handling for scanCount < 0

function [data, result] = mdaqAIScan(arg1, arg2, arg3)
    link_id = -1;
    data = [];
    result = [];

    ch_count = call("sci_mlink_ai_scan_get_ch_count", "out", [1, 1], 1, "i");
    if ch_count < 1 | ch_count > 16 then
        error("AI scan not initialized");
    end

    if argn(2) == 2 then;
        scan_count = arg1;
        blocking = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        scan_count = arg2;
        blocking = arg3;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    if argn(2) > 3 | argn(2) < 2 then
        mprintf("Description:\n");
        mprintf("\tStarts scanning operation and reads acquired data\n");
        mprintf("Usage:\n");
        mprintf("\t[data, result] = mdaqAIScan(linkID, scanCount, isBlocking\n")
        mprintf("\tlinkID - connection id returned by mdaqOpen() (OPTIONAL)\n");
        mprintf("\tscanCount - number of scans to read, when 0 - start acquisition only\n");
        mprintf("\tisBlocking - blocking or non-blocking read (%%T/%%F)\n");
        return;
    end

    if blocking == %T then
        blocking = 1;
    else
        blocking = 0;
    end

    if scan_count < 0 then
        error("scanCount parameter has to be equal or grater than 0");
    end

    [ data result ] = call("sci_mlink_ai_scan",..
                scan_count, 2, "i",..
                blocking, 3, "i",..
            "out",..
                [ch_count, scan_count], 1, "d",..
                [1, 1], 4, "i");

    if result < 0 then
        // -91 - timeout
        if result == -91  then
            mdaq_error(result)
        else
            error(mdaq_error2(result), 10000 + abs(result))
        end
        data = [];
    end

    data = data';
    result = round(result / ch_count);

    if result < scan_count then
        data = data(1:result,:)
    end
endfunction

function [data, result] = mdaqAIScan(arg1, arg2, arg3)
    link_id = -1;
    data = [];
    result = [];

    ch_count = call("sci_mlink_ai_scan_get_ch_count", "out", [1, 1], 1, "i");
    if ch_count < 1 | ch_count > 16 then
        error("AI scan not initialized");
    end

    if argn(2) == 2 then;
        scan_count = arg1;
        blocking = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        scan_count = arg2;
        blocking = arg3;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    if argn(2) > 3 | argn(2) < 2 then
        mprintf("Description:\n");
        mprintf("\tStarts scanning operation and reads acquired data\n");
        mprintf("Usage:\n");
        mprintf("\t[data, result] = mdaqAIScan(linkID, scanCount, isBlocking\n")
        mprintf("\tlinkID - connection id returned by mdaqOpen() (OPTIONAL)\n");
        mprintf("\tscanCount - number of scans to read, when 0 - start acquisition only\n");
        mprintf("\tisBlocking - blocking or non-blocking read (%%T/%%F)\n");
        return;
    end

    if blocking == %T then
        blocking = 1;
    else
        blocking = 0;
    end

    [ data result ] = call("sci_mlink_ai_scan",..
                scan_count, 2, "i",..
                blocking, 3, "i",..
            "out",..
                [ch_count, scan_count], 1, "d",..
                [1, 1], 4, "i");

    if result < 0 then
        // -91 - timeout
        if result == -91  then
            mdaq_error(result)
        else
            error(mdaq_error2(result), 10000 + abs(result))
        end
        data = [];
    end

    data = data';
    result = round(result / ch_count);

    if result < scan_count then
        data = data(1:result,:)
    end
endfunction


SCHEDULING-1381:

SCHEDULING-1381:

commit 20829 introduced a bug when displaying PATask

git-svn-id: 27916816d6cfa57849e9a885196bf7392b80e1ac@21091 28e8926c-6b08-0410-baaa-805c5e19b8d6

function %PATask_p(l)
    if typeof(l) == 'PATask' then
        n = size(l.matrix,1);
        m = size(l.matrix,2);
        //disp(m)
        for j=1:m
            for i=1:n
                patsk=l.matrix(i,j).entries;
                printf('('+string(i)+','+string(j)+'):\n');
                %PATsk_p(patsk);
            end

        end
     end
endfunction

function %PATask_p(l)
    if typeof(l) == 'PATask' then
        n = size(l.matrix,1);
        m = size(l.matrix,2);
        //disp(m)
        for j=1:m
            for i=1:m
                patsk=l.matrix(i,j).entries;
                printf('('+string(i)+','+string(j)+'):\n');
                %PATsk_p(patsk);
            end

        end
     end
endfunction


sb120: #i111199# disabled failing tests for now

-o sd.AccessibleDrawDocumentView
#i111199 -o sd.AccessibleOutlineView
#i35935# -o sd.AccessibleSlideView
#i111042# -o sd.DrawController_DrawView
#i111042# -o sd.DrawController_HandoutView
#i111042# -o sd.DrawController_NotesView
#i111043# -o sd.DrawController_OutlineView
#i111042# -o sd.DrawController_PresentationView
-o sd.SdDocLinkTargets
-o sd.SdDrawPage
-o sd.SdDrawPagesAccess
-o sd.SdGenericDrawPage
-o sd.SdLayer
-o sd.SdLayerManager
-o sd.SdMasterPage
-o sd.SdMasterPagesAccess
-o sd.SdPageLinkTargets
-o sd.SdXCustomPresentation
-o sd.SdXCustomPresentationAccess
#i84994# -o sd.SdXImpressDocument
-o sd.SdXPresentation
#i87746 -o sd.SdXShape

-o sd.AccessibleDrawDocumentView
-o sd.AccessibleOutlineView
#i35935# -o sd.AccessibleSlideView
#i111042# -o sd.DrawController_DrawView
#i111042# -o sd.DrawController_HandoutView
#i111042# -o sd.DrawController_NotesView
#i111043# -o sd.DrawController_OutlineView
#i111042# -o sd.DrawController_PresentationView
-o sd.SdDocLinkTargets
-o sd.SdDrawPage
-o sd.SdDrawPagesAccess
-o sd.SdGenericDrawPage
-o sd.SdLayer
-o sd.SdLayerManager
-o sd.SdMasterPage
-o sd.SdMasterPagesAccess
-o sd.SdPageLinkTargets
-o sd.SdXCustomPresentation
-o sd.SdXCustomPresentationAccess
#i84994# -o sd.SdXImpressDocument
-o sd.SdXPresentation
#i87746 -o sd.SdXShape


Delete VWFA_Color_Localizer_MRI.sce

Delete VWFA_Color_Localizer_MRI.sce

########################################################
# VWFA (Dutch), and (Synesthetic) Color Localizer      #
# O. Colizoli, 2012									   #
# Universiteit van Amsterdam (Dept. Psych.)			   #
#													   #
# Presentation SCE file 		                       #
# blocked fMRI - ABCDABCD			                   #
# 16 seconds active, 16 sec baseline (fixation cross)  #
# 4 conditions:                                        #
# Dutch words black                                    #
# Dutch words color                                    #
# Chinese words black                                  #
# Chinese words color                                  #
# Instructions - passive viewing, maintain fixation    #
# 4 conditions x 5 blocks = 20 blocks total            #
# 16 images per block x 5 blocks per condition         #
#######################################################

scenario = "VWFA_Color_Localizer_MRI";

default_background_color = 255, 255, 255;
default_font = "courier new";
default_font_size = 60;
default_text_color = 0,0,0;
response_matching = simple_matching;
response_logging = log_all;
active_buttons = 8;
button_codes = 1,2,3,4,5,6,7,8;

scenario_type = fMRI_emulation;
#scan_period = 2000;   # (ms) only here to make emulation possible if desired
#scenario_type = fMRI;
pulses_per_scan = 1;
pulse_code = 255;

begin;

################ STIMULUS DEFINITIONS ################

array{ # 80 words
text	{caption	=	"TIEN"	;	description	=	"	TIEN	"	;}	;
text	{caption	=	"ECHT"	;	description	=	"	ECHT	"	;}	;
text	{caption	=	"ENIG"	;	description	=	"	ENIG	"	;}	;
text	{caption	=	"OVER"	;	description	=	"	OVER	"	;}	;
text	{caption	=	"STOF"	;	description	=	"	STOF	"	;}	;
text	{caption	=	"LUST"	;	description	=	"	LUST	"	;}	;
text	{caption	=	"DANK"	;	description	=	"	DANK	"	;}	;
text	{caption	=	"VORM"	;	description	=	"	VORM	"	;}	;
text	{caption	=	"NAME"	;	description	=	"	NAME	"	;}	;
text	{caption	=	"UREN"	;	description	=	"	UREN	"	;}	;
text	{caption	=	"BOEK"	;	description	=	"	BOEK	"	;}	;
text	{caption	=	"VELD"	;	description	=	"	VELD	"	;}	;
text	{caption	=	"WANG"	;	description	=	"	WANG	"	;}	;
text	{caption	=	"ZULT"	;	description	=	"	ZULT	"	;}	;
text	{caption	=	"KANS"	;	description	=	"	KANS	"	;}	;
text	{caption	=	"ETEN"	;	description	=	"	ETEN	"	;}	;
text	{caption	=	"ALLE"	;	description	=	"	ALLE	"	;}	;
text	{caption	=	"GOLF"	;	description	=	"	GOLF	"	;}	;
text	{caption	=	"REIS"	;	description	=	"	REIS	"	;}	;
text	{caption	=	"DOEN"	;	description	=	"	DOEN	"	;}	;
text	{caption	=	"VLUG"	;	description	=	"	VLUG	"	;}	;
text	{caption	=	"HUID"	;	description	=	"	HUID	"	;}	;
text	{caption	=	"HEMD"	;	description	=	"	HEMD	"	;}	;
text	{caption	=	"TERM"	;	description	=	"	TERM	"	;}	;
text	{caption	=	"PIJN"	;	description	=	"	PIJN	"	;}	;
text	{caption	=	"STEM"	;	description	=	"	STEM	"	;}	;
text	{caption	=	"GAST"	;	description	=	"	GAST	"	;}	;
text	{caption	=	"LIED"	;	description	=	"	LIED	"	;}	;
text	{caption	=	"ZORG"	;	description	=	"	ZORG	"	;}	;
text	{caption	=	"ARME"	;	description	=	"	ARME	"	;}	;
text	{caption	=	"FLES"	;	description	=	"	FLES	"	;}	;
text	{caption	=	"ACHT"	;	description	=	"	ACHT	"	;}	;
text	{caption	=	"MOND"	;	description	=	"	MOND	"	;}	;
text	{caption	=	"RING"	;	description	=	"	RING	"	;}	;
text	{caption	=	"GRAS"	;	description	=	"	GRAS	"	;}	;
text	{caption	=	"MELK"	;	description	=	"	MELK	"	;}	;
text	{caption	=	"DOCH"	;	description	=	"	DOCH	"	;}	;
text	{caption	=	"BANG"	;	description	=	"	BANG	"	;}	;
text	{caption	=	"TONG"	;	description	=	"	TONG	"	;}	;
text	{caption	=	"ONZE"	;	description	=	"	ONZE	"	;}	;
text	{caption	=	"OPEN"	;	description	=	"	OPEN	"	;}	;
text	{caption	=	"JURK"	;	description	=	"	JURK	"	;}	;
text	{caption	=	"TRAP"	;	description	=	"	TRAP	"	;}	;
text	{caption	=	"ZAND"	;	description	=	"	ZAND	"	;}	;
text	{caption	=	"STAD"	;	description	=	"	STAD	"	;}	;
text	{caption	=	"SLOT"	;	description	=	"	SLOT	"	;}	;
text	{caption	=	"PLUS"	;	description	=	"	PLUS	"	;}	;
text	{caption	=	"FASE"	;	description	=	"	FASE	"	;}	;
text	{caption	=	"BLAD"	;	description	=	"	BLAD	"	;}	;
text	{caption	=	"CHEF"	;	description	=	"	CHEF	"	;}	;
text	{caption	=	"RIJK"	;	description	=	"	RIJK	"	;}	;
text	{caption	=	"EIND"	;	description	=	"	EIND	"	;}	;
text	{caption	=	"CAFE"	;	description	=	"	CAFE	"	;}	;
text	{caption	=	"MOED"	;	description	=	"	MOED	"	;}	;
text	{caption	=	"HALF"	;	description	=	"	HALF	"	;}	;
text	{caption	=	"PERS"	;	description	=	"	PERS	"	;}	;
text	{caption	=	"LEUK"	;	description	=	"	LEUK	"	;}	;
text	{caption	=	"ERIN"	;	description	=	"	ERIN	"	;}	;
text	{caption	=	"VALT"	;	description	=	"	VALT	"	;}	;
text	{caption	=	"OLIE"	;	description	=	"	OLIE	"	;}	;
text	{caption	=	"AUTO"	;	description	=	"	AUTO	"	;}	;
text	{caption	=	"NAUW"	;	description	=	"	NAUW	"	;}	;
text	{caption	=	"AARD"	;	description	=	"	AARD	"	;}	;
text	{caption	=	"JUNI"	;	description	=	"	JUNI	"	;}	;
text	{caption	=	"SOMS"	;	description	=	"	SOMS	"	;}	;
text	{caption	=	"GEUR"	;	description	=	"	GEUR	"	;}	;
text	{caption	=	"LAST"	;	description	=	"	LAST	"	;}	;
text	{caption	=	"IETS"	;	description	=	"	IETS	"	;}	;
text	{caption	=	"DIER"	;	description	=	"	DIER	"	;}	;
text	{caption	=	"KOUD"	;	description	=	"	KOUD	"	;}	;
text	{caption	=	"SPEL"	;	description	=	"	SPEL	"	;}	;
text	{caption	=	"MEID"	;	description	=	"	MEID	"	;}	;
text	{caption	=	"WILD"	;	description	=	"	WILD	"	;}	;
text	{caption	=	"ZIEK"	;	description	=	"	ZIEK	"	;}	;
text	{caption	=	"BEST"	;	description	=	"	BEST	"	;}	;
text	{caption	=	"LUID"	;	description	=	"	LUID	"	;}	;
text	{caption	=	"HAND"	;	description	=	"	HAND	"	;}	;
text	{caption	=	"HOGE"	;	description	=	"	HOGE	"	;}	;
text	{caption	=	"MATE"	;	description	=	"	MATE	"	;}	;
text	{caption	=	"ZELF"	;	description	=	"	ZELF	"	;}	;
} dutch_black;

array{ # 80 words
text	{caption	=	"TIEN"	;	description	=	"	TIEN	"	;}	;
text	{caption	=	"ECHT"	;	description	=	"	ECHT	"	;}	;
text	{caption	=	"ENIG"	;	description	=	"	ENIG	"	;}	;
text	{caption	=	"OVER"	;	description	=	"	OVER	"	;}	;
text	{caption	=	"STOF"	;	description	=	"	STOF	"	;}	;
text	{caption	=	"LUST"	;	description	=	"	LUST	"	;}	;
text	{caption	=	"DANK"	;	description	=	"	DANK	"	;}	;
text	{caption	=	"VORM"	;	description	=	"	VORM	"	;}	;
text	{caption	=	"NAME"	;	description	=	"	NAME	"	;}	;
text	{caption	=	"UREN"	;	description	=	"	UREN	"	;}	;
text	{caption	=	"BOEK"	;	description	=	"	BOEK	"	;}	;
text	{caption	=	"VELD"	;	description	=	"	VELD	"	;}	;
text	{caption	=	"WANG"	;	description	=	"	WANG	"	;}	;
text	{caption	=	"ZULT"	;	description	=	"	ZULT	"	;}	;
text	{caption	=	"KANS"	;	description	=	"	KANS	"	;}	;
text	{caption	=	"ETEN"	;	description	=	"	ETEN	"	;}	;
text	{caption	=	"ALLE"	;	description	=	"	ALLE	"	;}	;
text	{caption	=	"GOLF"	;	description	=	"	GOLF	"	;}	;
text	{caption	=	"REIS"	;	description	=	"	REIS	"	;}	;
text	{caption	=	"DOEN"	;	description	=	"	DOEN	"	;}	;
text	{caption	=	"VLUG"	;	description	=	"	VLUG	"	;}	;
text	{caption	=	"HUID"	;	description	=	"	HUID	"	;}	;
text	{caption	=	"HEMD"	;	description	=	"	HEMD	"	;}	;
text	{caption	=	"TERM"	;	description	=	"	TERM	"	;}	;
text	{caption	=	"PIJN"	;	description	=	"	PIJN	"	;}	;
text	{caption	=	"STEM"	;	description	=	"	STEM	"	;}	;
text	{caption	=	"GAST"	;	description	=	"	GAST	"	;}	;
text	{caption	=	"LIED"	;	description	=	"	LIED	"	;}	;
text	{caption	=	"ZORG"	;	description	=	"	ZORG	"	;}	;
text	{caption	=	"ARME"	;	description	=	"	ARME	"	;}	;
text	{caption	=	"FLES"	;	description	=	"	FLES	"	;}	;
text	{caption	=	"ACHT"	;	description	=	"	ACHT	"	;}	;
text	{caption	=	"MOND"	;	description	=	"	MOND	"	;}	;
text	{caption	=	"RING"	;	description	=	"	RING	"	;}	;
text	{caption	=	"GRAS"	;	description	=	"	GRAS	"	;}	;
text	{caption	=	"MELK"	;	description	=	"	MELK	"	;}	;
text	{caption	=	"DOCH"	;	description	=	"	DOCH	"	;}	;
text	{caption	=	"BANG"	;	description	=	"	BANG	"	;}	;
text	{caption	=	"TONG"	;	description	=	"	TONG	"	;}	;
text	{caption	=	"ONZE"	;	description	=	"	ONZE	"	;}	;
text	{caption	=	"OPEN"	;	description	=	"	OPEN	"	;}	;
text	{caption	=	"JURK"	;	description	=	"	JURK	"	;}	;
text	{caption	=	"TRAP"	;	description	=	"	TRAP	"	;}	;
text	{caption	=	"ZAND"	;	description	=	"	ZAND	"	;}	;
text	{caption	=	"STAD"	;	description	=	"	STAD	"	;}	;
text	{caption	=	"SLOT"	;	description	=	"	SLOT	"	;}	;
text	{caption	=	"PLUS"	;	description	=	"	PLUS	"	;}	;
text	{caption	=	"FASE"	;	description	=	"	FASE	"	;}	;
text	{caption	=	"BLAD"	;	description	=	"	BLAD	"	;}	;
text	{caption	=	"CHEF"	;	description	=	"	CHEF	"	;}	;
text	{caption	=	"RIJK"	;	description	=	"	RIJK	"	;}	;
text	{caption	=	"EIND"	;	description	=	"	EIND	"	;}	;
text	{caption	=	"CAFE"	;	description	=	"	CAFE	"	;}	;
text	{caption	=	"MOED"	;	description	=	"	MOED	"	;}	;
text	{caption	=	"HALF"	;	description	=	"	HALF	"	;}	;
text	{caption	=	"PERS"	;	description	=	"	PERS	"	;}	;
text	{caption	=	"LEUK"	;	description	=	"	LEUK	"	;}	;
text	{caption	=	"ERIN"	;	description	=	"	ERIN	"	;}	;
text	{caption	=	"VALT"	;	description	=	"	VALT	"	;}	;
text	{caption	=	"OLIE"	;	description	=	"	OLIE	"	;}	;
text	{caption	=	"AUTO"	;	description	=	"	AUTO	"	;}	;
text	{caption	=	"NAUW"	;	description	=	"	NAUW	"	;}	;
text	{caption	=	"AARD"	;	description	=	"	AARD	"	;}	;
text	{caption	=	"JUNI"	;	description	=	"	JUNI	"	;}	;
text	{caption	=	"SOMS"	;	description	=	"	SOMS	"	;}	;
text	{caption	=	"GEUR"	;	description	=	"	GEUR	"	;}	;
text	{caption	=	"LAST"	;	description	=	"	LAST	"	;}	;
text	{caption	=	"IETS"	;	description	=	"	IETS	"	;}	;
text	{caption	=	"DIER"	;	description	=	"	DIER	"	;}	;
text	{caption	=	"KOUD"	;	description	=	"	KOUD	"	;}	;
text	{caption	=	"SPEL"	;	description	=	"	SPEL	"	;}	;
text	{caption	=	"MEID"	;	description	=	"	MEID	"	;}	;
text	{caption	=	"WILD"	;	description	=	"	WILD	"	;}	;
text	{caption	=	"ZIEK"	;	description	=	"	ZIEK	"	;}	;
text	{caption	=	"BEST"	;	description	=	"	BEST	"	;}	;
text	{caption	=	"LUID"	;	description	=	"	LUID	"	;}	;
text	{caption	=	"HAND"	;	description	=	"	HAND	"	;}	;
text	{caption	=	"HOGE"	;	description	=	"	HOGE	"	;}	;
text	{caption	=	"MATE"	;	description	=	"	MATE	"	;}	;
text	{caption	=	"ZELF"	;	description	=	"	ZELF	"	;}	;
} dutch_color;

array{		# 80
text	{caption	=	"TIEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TIEN	"	;}	;
text	{caption	=	"ECHT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ECHT	"	;}	;
text	{caption	=	"ENIG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ENIG	"	;}	;
text	{caption	=	"OVER"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OVER	"	;}	;
text	{caption	=	"STOF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STOF	"	;}	;
text	{caption	=	"LUST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LUST	"	;}	;
text	{caption	=	"DANK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DANK	"	;}	;
text	{caption	=	"VORM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VORM	"	;}	;
text	{caption	=	"NAME"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	NAME	"	;}	;
text	{caption	=	"UREN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	UREN	"	;}	;
text	{caption	=	"BOEK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BOEK	"	;}	;
text	{caption	=	"VELD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VELD	"	;}	;
text	{caption	=	"WANG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	WANG	"	;}	;
text	{caption	=	"ZULT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZULT	"	;}	;
text	{caption	=	"KANS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	KANS	"	;}	;
text	{caption	=	"ETEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ETEN	"	;}	;
text	{caption	=	"ALLE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ALLE	"	;}	;
text	{caption	=	"GOLF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GOLF	"	;}	;
text	{caption	=	"REIS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	REIS	"	;}	;
text	{caption	=	"DOEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DOEN	"	;}	;
text	{caption	=	"VLUG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VLUG	"	;}	;
text	{caption	=	"HUID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HUID	"	;}	;
text	{caption	=	"HEMD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HEMD	"	;}	;
text	{caption	=	"TERM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TERM	"	;}	;
text	{caption	=	"PIJN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PIJN	"	;}	;
text	{caption	=	"STEM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STEM	"	;}	;
text	{caption	=	"GAST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GAST	"	;}	;
text	{caption	=	"LIED"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LIED	"	;}	;
text	{caption	=	"ZORG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZORG	"	;}	;
text	{caption	=	"ARME"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ARME	"	;}	;
text	{caption	=	"FLES"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	FLES	"	;}	;
text	{caption	=	"ACHT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ACHT	"	;}	;
text	{caption	=	"MOND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MOND	"	;}	;
text	{caption	=	"RING"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	RING	"	;}	;
text	{caption	=	"GRAS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GRAS	"	;}	;
text	{caption	=	"MELK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MELK	"	;}	;
text	{caption	=	"DOCH"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DOCH	"	;}	;
text	{caption	=	"BANG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BANG	"	;}	;
text	{caption	=	"TONG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TONG	"	;}	;
text	{caption	=	"ONZE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ONZE	"	;}	;
text	{caption	=	"OPEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OPEN	"	;}	;
text	{caption	=	"JURK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	JURK	"	;}	;
text	{caption	=	"TRAP"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TRAP	"	;}	;
text	{caption	=	"ZAND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZAND	"	;}	;
text	{caption	=	"STAD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STAD	"	;}	;
text	{caption	=	"SLOT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SLOT	"	;}	;
text	{caption	=	"PLUS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PLUS	"	;}	;
text	{caption	=	"FASE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	FASE	"	;}	;
text	{caption	=	"BLAD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BLAD	"	;}	;
text	{caption	=	"CHEF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	CHEF	"	;}	;
text	{caption	=	"RIJK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	RIJK	"	;}	;
text	{caption	=	"EIND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	EIND	"	;}	;
text	{caption	=	"CAFE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	CAFE	"	;}	;
text	{caption	=	"MOED"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MOED	"	;}	;
text	{caption	=	"HALF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HALF	"	;}	;
text	{caption	=	"PERS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PERS	"	;}	;
text	{caption	=	"LEUK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LEUK	"	;}	;
text	{caption	=	"ERIN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ERIN	"	;}	;
text	{caption	=	"VALT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VALT	"	;}	;
text	{caption	=	"OLIE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OLIE	"	;}	;
text	{caption	=	"AUTO"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	AUTO	"	;}	;
text	{caption	=	"NAUW"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	NAUW	"	;}	;
text	{caption	=	"AARD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	AARD	"	;}	;
text	{caption	=	"JUNI"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	JUNI	"	;}	;
text	{caption	=	"SOMS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SOMS	"	;}	;
text	{caption	=	"GEUR"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GEUR	"	;}	;
text	{caption	=	"LAST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LAST	"	;}	;
text	{caption	=	"IETS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	IETS	"	;}	;
text	{caption	=	"DIER"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DIER	"	;}	;
text	{caption	=	"KOUD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	KOUD	"	;}	;
text	{caption	=	"SPEL"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SPEL	"	;}	;
text	{caption	=	"MEID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MEID	"	;}	;
text	{caption	=	"WILD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	WILD	"	;}	;
text	{caption	=	"ZIEK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZIEK	"	;}	;
text	{caption	=	"BEST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BEST	"	;}	;
text	{caption	=	"LUID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LUID	"	;}	;
text	{caption	=	"HAND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HAND	"	;}	;
text	{caption	=	"HOGE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HOGE	"	;}	;
text	{caption	=	"MATE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MATE	"	;}	;
text	{caption	=	"ZELF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZELF	"	;}	;
} chinese_black;

array{		# 80
text	{caption	=	"TIEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TIEN	"	;}	;
text	{caption	=	"ECHT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ECHT	"	;}	;
text	{caption	=	"ENIG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ENIG	"	;}	;
text	{caption	=	"OVER"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OVER	"	;}	;
text	{caption	=	"STOF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STOF	"	;}	;
text	{caption	=	"LUST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LUST	"	;}	;
text	{caption	=	"DANK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DANK	"	;}	;
text	{caption	=	"VORM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VORM	"	;}	;
text	{caption	=	"NAME"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	NAME	"	;}	;
text	{caption	=	"UREN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	UREN	"	;}	;
text	{caption	=	"BOEK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BOEK	"	;}	;
text	{caption	=	"VELD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VELD	"	;}	;
text	{caption	=	"WANG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	WANG	"	;}	;
text	{caption	=	"ZULT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZULT	"	;}	;
text	{caption	=	"KANS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	KANS	"	;}	;
text	{caption	=	"ETEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ETEN	"	;}	;
text	{caption	=	"ALLE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ALLE	"	;}	;
text	{caption	=	"GOLF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GOLF	"	;}	;
text	{caption	=	"REIS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	REIS	"	;}	;
text	{caption	=	"DOEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DOEN	"	;}	;
text	{caption	=	"VLUG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VLUG	"	;}	;
text	{caption	=	"HUID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HUID	"	;}	;
text	{caption	=	"HEMD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HEMD	"	;}	;
text	{caption	=	"TERM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TERM	"	;}	;
text	{caption	=	"PIJN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PIJN	"	;}	;
text	{caption	=	"STEM"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STEM	"	;}	;
text	{caption	=	"GAST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GAST	"	;}	;
text	{caption	=	"LIED"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LIED	"	;}	;
text	{caption	=	"ZORG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZORG	"	;}	;
text	{caption	=	"ARME"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ARME	"	;}	;
text	{caption	=	"FLES"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	FLES	"	;}	;
text	{caption	=	"ACHT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ACHT	"	;}	;
text	{caption	=	"MOND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MOND	"	;}	;
text	{caption	=	"RING"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	RING	"	;}	;
text	{caption	=	"GRAS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GRAS	"	;}	;
text	{caption	=	"MELK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MELK	"	;}	;
text	{caption	=	"DOCH"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DOCH	"	;}	;
text	{caption	=	"BANG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BANG	"	;}	;
text	{caption	=	"TONG"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TONG	"	;}	;
text	{caption	=	"ONZE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ONZE	"	;}	;
text	{caption	=	"OPEN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OPEN	"	;}	;
text	{caption	=	"JURK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	JURK	"	;}	;
text	{caption	=	"TRAP"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	TRAP	"	;}	;
text	{caption	=	"ZAND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZAND	"	;}	;
text	{caption	=	"STAD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	STAD	"	;}	;
text	{caption	=	"SLOT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SLOT	"	;}	;
text	{caption	=	"PLUS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PLUS	"	;}	;
text	{caption	=	"FASE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	FASE	"	;}	;
text	{caption	=	"BLAD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BLAD	"	;}	;
text	{caption	=	"CHEF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	CHEF	"	;}	;
text	{caption	=	"RIJK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	RIJK	"	;}	;
text	{caption	=	"EIND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	EIND	"	;}	;
text	{caption	=	"CAFE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	CAFE	"	;}	;
text	{caption	=	"MOED"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MOED	"	;}	;
text	{caption	=	"HALF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HALF	"	;}	;
text	{caption	=	"PERS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	PERS	"	;}	;
text	{caption	=	"LEUK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LEUK	"	;}	;
text	{caption	=	"ERIN"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ERIN	"	;}	;
text	{caption	=	"VALT"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	VALT	"	;}	;
text	{caption	=	"OLIE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	OLIE	"	;}	;
text	{caption	=	"AUTO"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	AUTO	"	;}	;
text	{caption	=	"NAUW"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	NAUW	"	;}	;
text	{caption	=	"AARD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	AARD	"	;}	;
text	{caption	=	"JUNI"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	JUNI	"	;}	;
text	{caption	=	"SOMS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SOMS	"	;}	;
text	{caption	=	"GEUR"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	GEUR	"	;}	;
text	{caption	=	"LAST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LAST	"	;}	;
text	{caption	=	"IETS"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	IETS	"	;}	;
text	{caption	=	"DIER"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	DIER	"	;}	;
text	{caption	=	"KOUD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	KOUD	"	;}	;
text	{caption	=	"SPEL"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	SPEL	"	;}	;
text	{caption	=	"MEID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MEID	"	;}	;
text	{caption	=	"WILD"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	WILD	"	;}	;
text	{caption	=	"ZIEK"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZIEK	"	;}	;
text	{caption	=	"BEST"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	BEST	"	;}	;
text	{caption	=	"LUID"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	LUID	"	;}	;
text	{caption	=	"HAND"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HAND	"	;}	;
text	{caption	=	"HOGE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	HOGE	"	;}	;
text	{caption	=	"MATE"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	MATE	"	;}	;
text	{caption	=	"ZELF"	;	font_size = 35;	font=	"Hanzi Kaishu";	description	=	"	ZELF	"	;}	;
} chinese_color;

picture { description = "rest"; text {caption = "+"; font_color= 0,0,0; font_size = 30; font = "Times New Roman";}; x = 0; y = 0; } rest;

#Instructions for participants
picture { text {caption = "You will see a series of Dutch and Chinese words.

Look at the middle of the screen while the words appear.
Also, keep looking at the screen when there are no words.

The experiment will start at any moment.
Make sure that you stay still. ";
font_color = 0,0,0; font_size = 24; font = "Times New Roman";
}; x = 0; y = 0; } startTrialPicture;

# Blank and fixation screens
picture {background_color = 255,255,255;} white_screen;
picture {text {caption = "+"; font_color= 0,0,0; font_size=30; font = "Times New Roman";} fix_text; x = 0; y = 0; }  pic_fix;

############ Start fMRI Trial ####################
trial {
   picture startTrialPicture;
   time = 0;
   duration = next_picture;
   picture startTrialPicture;
   mri_pulse = 1;
   duration = 1000;
} startTrial;

################# Button Trial ################################
trial {
		all_responses = false;	           # Does not log all responses, only those during active events #
		trial_type = fixed;

	stimulus_event {
					picture pic_fix;
					time = 0;
					duration = 245;
					code = "isi_fix";
					response_active = false;
					}isi_fix;

	stimulus_event {
					picture {
						text fix_text;
						x = 0; y = 0;
					} word_stim;
					deltat = 245;
					duration = 745;
					response_active = true;
					}word_event;

} word_trial;

################# Baseline ################################
trial {
		all_responses = false;	           # Does not log all responses, only those during active events #
		trial_type = fixed;

	stimulus_event {
					picture white_screen;
					time = 0;
					duration = 15995;
					code = "rest";
					response_active = false;
					}rest_event;

} rest_trial;

################################## START PCL ####################################

begin_pcl;

############# DECLARATIONS ##############
preset int run = 1;

int start_time = clock.time();

string subnr = logfile.subject();
logfile.set_filename(subnr + "_run" + string(run) + "_VWFA_Color_Syn_Localizer_MRI.log");
output_file output = new output_file;
output.open( subnr + "_run" + string(run) + "_VWFA_Color_Syn_Localizer_MRI_output.txt" );
output.print(start_time);output.print("\n");
output.print( "block\ttrialnr\tpic_trial\tword\tcolor\tresponse_button\tRT\n" );

string word = "";
string color = "";
int isi = 0;
int j = 1;
int k1 = 1;
int k2 = 1;
int m = 1;
int c1 = 1;
int c2 = 1;
int z = 1;

string dblack = "1";
string dcolor = "2";
string cblack = "3";
string ccolor = "4";
string baseline = "5";

int lastResponse = 0;
double lastRT = 0.0;

int trial_number = 1;

int r = 0;
int g = 0;
int b = 0;

array <int> stroop_color [16][3] =
{
	{230,0,0}, 		#red
	{255,102,0}, 	#orange
	{0,203,230}, 	#torquoise (0,203,230) brown  (0, 158, 179)  brown {179,110,0}
	{246,236,0}, 	#yellow
	{0,210,0}, 		#green
	{0,203,230}, 	#blue
	{150,45,225}, 	#purple
	{242,112,220}, #pink
	{230,0,0}, 		#red
	{255,102,0}, 	#orange
	{0,203,230}, 	#torquoise (0,203,230) brown  (0, 158, 179)  brown {179,110,0}
	{246,236,0}, 	#yellow
	{0,210,0}, 		#green
	{0,203,230}, 	#blue
	{150,45,225}, 	#purple
	{242,112,220} 	#pink
} ;

###############################################################################

### START OF THE TRIALS LOOPS ###

###################
sub condition1 begin # dutch_black

loop j = 1 until j > 16  begin;

		dutch_black[k1].set_font_color(0,0,0);
		dutch_black[k1].redraw();
		color = "black";

		word_stim.set_part( 1, dutch_black[k1] );
		word = dutch_black[k1].description();
		word_event.set_event_code(dblack);

		word_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("dutch_black");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(k1);output.print("\t");
		output.print(word);output.print("\t");
		output.print(color);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		k1 = k1 + 1;
		j = j + 1;
		end;
end;

###################
sub condition2 begin # dutch_color

stroop_color.shuffle();

loop j = 1 until j > 16  begin;

		dutch_color[k2].set_font_color(stroop_color[j][1],stroop_color[j][2],stroop_color[j][3]);
		dutch_color[k2].redraw();

		r = stroop_color[j][1];
		g = stroop_color[j][2];
		b = stroop_color[j][3];

		word_stim.set_part( 1, dutch_color[k2] );
		word = dutch_color[k2].description();
		word_event.set_event_code(dcolor);

		word_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("dutch_color");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(k2);output.print("\t");
		output.print(word);output.print("\t");
		output.print(r);output.print(",");output.print(g);output.print(",");output.print(b);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		k2 = k2 + 1;
		j = j + 1;
		end;
end;

###################
sub condition3 begin # chinese_black

loop j = 1 until j > 16  begin;

		chinese_black[c1].set_font_color(0,0,0);
		chinese_black[c1].redraw();
		color = "black";

		word_stim.set_part( 1, chinese_black[c1] );
		word = chinese_black[c1].description();
		word_event.set_event_code(cblack);

		word_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("chinese_black");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(c1);output.print("\t");
		output.print(word);output.print("\t");
		output.print(color);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		c1 = c1 + 1;
		j = j + 1;
		end;
end;

###################
sub condition4 begin # chinese_color

stroop_color.shuffle();

loop j = 1 until j > 16  begin;

		chinese_color[c2].set_font_color(stroop_color[j][1],stroop_color[j][2],stroop_color[j][3]);
		chinese_color[c2].redraw();

		r = stroop_color[j][1];
		g = stroop_color[j][2];
		b = stroop_color[j][3];

		word_stim.set_part( 1, chinese_color[c2] );
		word = chinese_color[c2].description();
		word_event.set_event_code(ccolor);

		word_trial.present();

		if response_manager.response_count() > 0
			then
				stimulus_data last = stimulus_manager.last_stimulus_data();
				lastRT = last.reaction_time_double();
				lastResponse = response_manager.last_response();
			else
				lastRT = 0.0;
				lastResponse = 0;
		end;

		output.print("chinese_color");output.print("\t");
		output.print(trial_number);output.print("\t");
		output.print(c2);output.print("\t");
		output.print(word);output.print("\t");
		output.print(r);output.print(",");output.print(g);output.print(",");output.print(b);output.print("\t");
		output.print(lastResponse);output.print("\t");
		output.print(lastRT);output.print("\n");

		trial_number = trial_number + 1;

		c2 = c2 + 1;
		j = j + 1;
		end;
end;

######### Define subject conditions, counterbalancing

array <int> randomize_conditions [4][20] =
{
	{4,2,3,1,2,1,3,4,1,2,3,4,2,1,3,4,1,2,4,3},
	{1,2,4,3,2,1,3,4,1,2,4,3,1,2,3,4,3,4,2,1},
	{2,4,1,3,1,2,4,3,1,4,3,2,3,4,1,2,4,3,2,1},
	{3,2,4,1,3,1,2,4,3,2,4,1,4,1,2,3,1,2,4,3}
};

		dutch_black.shuffle();
		dutch_color.shuffle();
		chinese_black.shuffle();
		chinese_color.shuffle();

		startTrial.present();

		# Begin with rest - Baseline block

		rest_event.set_event_code(baseline);
		rest_event.set_duration(17995);

		rest_event.set_stimulus( rest );
		rest_trial.present();

	loop k1 = 1 until k1 > dutch_black.count() begin;
	loop k2 = 1 until k2 > dutch_color.count() begin;
	loop c1 = 1 until c1 > chinese_black.count() begin;
	loop c2 = 1 until c2 > chinese_color.count() begin;

		#the run number picks which of the 4 pseudo randomized condition orders
	loop z = 1 until z > 20 begin;

			if randomize_conditions[run][z] == 1
					then condition1();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_duration(15995);
					rest_event.set_stimulus( rest );
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 2
					then condition2();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 3
					then condition3();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			elseif randomize_conditions[run][z] == 4
					then condition4();
					# Baseline block
					rest_event.set_event_code(baseline);
					rest_event.set_stimulus( rest );
					rest_event.set_duration(15995);
					rest_trial.present();
					z = z + 1;
			end;

		end;
	end;
	end;
end;
end;

int end_time = clock.time();
output.print(end_time);output.print("\n");


Fix for wrong func name

Fix for wrong func name

function  mdaq_ai_scan_init(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        ai_range = arg2;
        differential = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        differential = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInit AI scan\n");
            mprintf("Usage:\n");
            mprintf("\tmdaq_ai_scan_init(link_id, channels, range, differential, frequency, time);\n");               mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range:\n");
            for i = 1:size(adc_info.c_params.c_range_desc, "r")
                mprintf("\t    %s\n", string(i) + ": " + adc_info.c_params.c_range_desc(i));
            end

            if adc_info.c_params.c_diff(1) == 1 then
                mprintf("\tdifferential - measurement type (%%T - differential, %%F - single-ended)\n");
            else
                mprintf("\tdifferential - set %%F (differential mode not supported by AI converter)\n");
            end

            mprintf("\tfrequency - scan frequency\n");
            mprintf("\tduration - scan duration in seconds\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    adc_ch_count = strtod(adc_info.channel);
    if differential then
        adc_ch_count = adc_ch_count / 2;
    end

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > adc_ch_count then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    if max(channels) > adc_ch_count | min(channels) < 1 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    try
        bipolar = adc_info.c_params.c_bipolar(ai_range);
        ai_range_desc = adc_info.c_params.c_range_desc(ai_range);
        ai_range = adc_info.c_params.c_range(ai_range);
    catch
        error("Error: wrong AI range selected!");
    end

    if differential == %F | differential == 0 then
        differential = 28;
    else
        differential = 29;
    end

    if argn(2) == 5 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    result = [];
    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            differential, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    disp("result: ");
    disp(result);
    if result < 0 & result <> -88 then
            error(mdaq_error(result), 10000 + abs(result))
    else
        if result == -88 then
            disp("Warninng: AI scanning interrupted!")
            mdaq_ai_scan_stop()

            // time to terminate TCP connection
            sleep(200);

            result = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    ai_range, 4, "i",..
                    bipolar, 5, "i",..
                    differential, 6, "i",..
                    scan_freq, 7, "d",..
                    scan_time, 8, "d",..
                "out",..
                    [1, 1], 9, "i");
        end

        mprintf("Data acquisition session settings:\n");

        str = [];
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if differential == 29 then
            mprintf("Differential\n");
        else
            mprintf("Single Ended\n");
        end

        mprintf("\tRange:\t\t");
        mprintf("%s\n", ai_range_desc);

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d\n", scan_time * scan_freq);
        end
    end

    if argn(2) == 5 then
        mdaq_close(link_id);
    end

endfunction

function  mdaq_ai_scan_init2(arg1, arg2, arg3, arg4, arg5, arg6)
    link_id = -1;

    if argn(2) == 5 then
        channels = arg1;
        ai_range = arg2;
        differential = arg3;
        scan_freq = arg4;
        scan_time = arg5;
    end

    if argn(2) == 6 then
        link_id = arg1;
        channels = arg2;
        ai_range = arg3;
        differential = arg4;
        scan_freq = arg5;
        scan_time = arg6;

        if link_id < 0 then
            disp("ERROR: Invalid link ID!")
            return;
        end
    end

    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        adc_info = get_adc_info(%microdaq.private.mdaq_hwid);
        if argn(2) > 6 | argn(2) < 5 then
            mprintf("Description:\n");
            mprintf("\tInit AI scan\n");
            mprintf("Usage:\n");
            mprintf("\tmdaq_ai_scan_init(link_id, channels, range, differential, frequency, time);\n");               mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
            mprintf("\tchannels - analog input channels to read\n");
            mprintf("\trange - analog input range:\n");
            for i = 1:size(adc_info.c_params.c_range_desc, "r")
                mprintf("\t    %s\n", string(i) + ": " + adc_info.c_params.c_range_desc(i));
            end

            if adc_info.c_params.c_diff(1) == 1 then
                mprintf("\tdifferential - measurement type (%%T - differential, %%F - single-ended)\n");
            else
                mprintf("\tdifferential - set %%F (differential mode not supported by AI converter)\n");
            end

            mprintf("\tfrequency - scan frequency\n");
            mprintf("\tduration - scan duration in seconds\n");
            return;
        end
    else
        error('Unable to detect MicroDAQ confituration - run mdaq_hwinfo and try again!');
        return;
    end

    if scan_time < 0 then
        scan_time = -1;
    end

    adc_ch_count = strtod(adc_info.channel);
    if differential then
        adc_ch_count = adc_ch_count / 2;
    end

    ch_count = max(size(channels));
    if ch_count < 1 | ch_count > adc_ch_count then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    if max(channels) > adc_ch_count | min(channels) < 1 then
        disp("ERROR: Wrong AI channel selected!")
        return;
    end

    try
        bipolar = adc_info.c_params.c_bipolar(ai_range);
        ai_range_desc = adc_info.c_params.c_range_desc(ai_range);
        ai_range = adc_info.c_params.c_range(ai_range);
    catch
        error("Error: wrong AI range selected!");
    end

    if differential == %F | differential == 0 then
        differential = 28;
    else
        differential = 29;
    end

    if argn(2) == 5 then
        link_id = mdaq_open();
        if link_id < 0 then
            disp("ERROR: Unable to connect to MicroDAQ device!");
            return;
        end
    end

    result = [];
    result = call("sci_mlink_ai_scan_init",..
            link_id, 1, "i",..
            channels, 2, "i",..
            ch_count, 3, "i",..
            ai_range, 4, "i",..
            bipolar, 5, "i",..
            differential, 6, "i",..
            scan_freq, 7, "d",..
            scan_time, 8, "d",..
        "out",..
            [1, 1], 9, "i");

    disp("result: ");
    disp(result);
    if result < 0 & result <> -88 then
            error(mdaq_error(result), 10000 + abs(result))
    else
        if result == -88 then
            disp("Warninng: AI scanning interrupted!")
            mdaq_ai_scan_stop()

            // time to terminate TCP connection
            sleep(200);

            result = call("sci_mlink_ai_scan_init",..
                    link_id, 1, "i",..
                    channels, 2, "i",..
                    ch_count, 3, "i",..
                    ai_range, 4, "i",..
                    bipolar, 5, "i",..
                    differential, 6, "i",..
                    scan_freq, 7, "d",..
                    scan_time, 8, "d",..
                "out",..
                    [1, 1], 9, "i");
        end

        mprintf("Data acquisition session settings:\n");

        str = [];
        s = size(channels);
        for j=1:s(2)
            if j > 1
              str = str + ", ";
            end
            str = str + string(channels(1,j));
        end
        mprintf("\tChannles:\t%s\n", str);

        mprintf("\tInput Type:\t");
        if differential == 29 then
            mprintf("Differential\n");
        else
            mprintf("Single Ended\n");
        end

        mprintf("\tRange:\t\t");
        mprintf("%s\n", ai_range_desc);

        if scan_freq >= 1000
            mprintf("\tFrequency:\t%.3fkHz\n", scan_freq/1000);
        else
            mprintf("\tFrequency:\t%dHz\n", scan_freq);
        end

        if scan_time < 0
            mprintf("\tDuration:\tInf\n");
            mprintf("\tScan count:\tInf");
        else
            mprintf("\tDuration:\t%.2fsec\n", scan_time);
            mprintf("\tScan count:\t%d\n", scan_time * scan_freq);
        end
    end

    if argn(2) == 5 then
        mdaq_close(link_id);
    end

endfunction


chart47: #i83867# enable test again

chart47: #i83867# enable test again

-o sch.ChXChartDocument
#i79073 -o sch.AccArea
#i79073 -o sch.AccAxis
#i79073 -o sch.AccDataPoint
#i79073 -o sch.AccDataSeries
#i79073 -o sch.AccDiagram
#i79073 -o sch.AccFloor
#i79073 -o sch.AccGrid
#i79073 -o sch.AccLegend
#i79073 -o sch.AccLegendEntry
#i79073 -o sch.AccStatisticsObject
#i79073 -o sch.AccTitle
#i79073 -o sch.AccWall
#i79073 -o sch.AccessibleDocumentView
-o sch.ChXChartAxis
-o sch.ChXChartData
-o sch.ChXChartDataArray
-o sch.ChXChartView
-o sch.ChXDataPoint
#i83868 -o sch.ChXDataRow
#i87138 -o sch.ChXDiagram
-o sch.ChartArea
-o sch.ChartGrid
-o sch.ChartLegend
-o sch.ChartLine
-o sch.ChartTitle

-o sch.ChXChartDocument
#i79073 -o sch.AccArea
#i79073 -o sch.AccAxis
#i79073 -o sch.AccDataPoint
#i79073 -o sch.AccDataSeries
#i79073 -o sch.AccDiagram
#i79073 -o sch.AccFloor
#i79073 -o sch.AccGrid
#i79073 -o sch.AccLegend
#i79073 -o sch.AccLegendEntry
#i79073 -o sch.AccStatisticsObject
#i79073 -o sch.AccTitle
#i79073 -o sch.AccWall
#i79073 -o sch.AccessibleDocumentView
-o sch.ChXChartAxis
-o sch.ChXChartData
-o sch.ChXChartDataArray
-o sch.ChXChartView
#i83867 -o sch.ChXDataPoint
#i83868 -o sch.ChXDataRow
#i87138 -o sch.ChXDiagram
-o sch.ChartArea
-o sch.ChartGrid
-o sch.ChartLegend
-o sch.ChartLine
-o sch.ChartTitle


mdaq_open allows passing IP address

mdaq_open allows passing IP address

function link_id = mdaq_open(ipAddr)
    link_id = -1;
    hwid = [];
    result = 0;

    if argn(2) == 1 then
        ip_address = ipAddr;
    else
        [ip_address, result] = mdaq_get_ip();
        if result < 0 then
            error("Unable to get IP address - run microdaq_setup!");
        end
    end

    [link_id, hwid] = mlink_connect(ip_address, 4343);
    if link_id < 0 then
        link_id = -1;
        error("Unable to connect to MicroDAQ device!");
    end

    if hwid(1) == 0 then
        mdaq_close(link_id);
        link_id = -1;
        error("Unrecodnized MicroDAQ device - contact support!");
    end

    global %microdaq
    %microdaq.private.mdaq_hwid = hwid;
endfunction

function link_id = mdaq_open()
    global %microdaq;
    link_id = -1;
    hwid = [];
    result = 0;
    [ip_address, result] = mdaq_get_ip();
    if result < 0 then
        disp("ERROR: Unable to get IP address - run microdaq_setup!");
        return;
    end
    [link_id, hwid] = mlink_connect(ip_address, 4343);
    if link_id < 0 then
        ulink(%microdaq.private.mlink_link_id);
        exec(mdaq_toolbox_path()+filesep()+"etc"+filesep()+..
                "mlink"+filesep()+"MLink.sce", -1);
        link_id = mlink_connect(ip_address, 4343);
    end
endfunction