Wrong range when DAC used without default settings

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

    dac_desc = ["This block writes data to MicroDAQ analog output module (AO).";
    "Block detects MicroDAQ analog output type and allows";
    "setting output range, initial and termination voltage.";
    "The Range value can be a scalar or a vector that must ";
    "be the same length as the channel vector. If scalar value";
    "is specified, that setting is replicated over the channel vector.";
    "Different ranges can be set for each channel if ADC supports ";
    "more then one output range.";
    "The Initial and Termination property can be a scalar or a vector";
    "";
    "Use Init/Term parameter allows to enable or disable setting";
    "initial or/and termination voltage values. User can provide";
    "scalar or vector with following values:";
    "0 - Initial and termination voltage value is ignored";
    "1 - Initial voltage value is used";
    "2 - Termination voltage value is used";
    "3 - Initial and termination voltage value is used";
    "";
    "input - value in volts"
    "";
    "Analog outputs parameters:";
    "Channels: "+channel_desc;
    "Resolution: "+resolution_desc;
    "";
    "Output rage:";
    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,dac_range,init_value,term_value,use_init_term,exprs]=..
                scicos_getvalue(dac_desc,..
                ['Channels:';
                'Range:';
                'Initial value:';
                'Termination value:';
                'Use Init/Term:'],..
                list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs)
            catch
                [ok,channel,dac_range,init_value,term_value,use_init_term,exprs]=..
                scicos_getvalue(dac_desc,..
                ['Channels:';
                'Range:';
                'Initial value:';
                'Termination value:';
                'Use Init/Term:'],..
                list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs)
            end;

            if ~ok then
                break
            end

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

                dac_ch_count = strtod(dac_info.channel);

                // check Channel parameter
                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 > dac_ch_count) then
                    ok = %f;
                    error_msg = 'Too many channels selected!';
                    message(error_msg);
                end

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

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

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

                for i = 1:dac_range_size
                    if ok & (dac_range(i) > size(dac_info.c_params.c_range, 'c')) | (dac_range(i) < 1) then
                        ok = %f;
                        error_msg = 'Wrong range value!';
                        message(error_msg);
                    end
                end

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

                init_value_size = size(init_value, 'c');
                if ok & (init_value_size > 1) & (init_value_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong init value vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end

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

                term_value_size = size(term_value, 'c');
                if ok & (term_value_size > 1) & (term_value_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong termination value vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end

                // check init term enable
                if ok & (find(use_init_term > 3) <> []) | (find(use_init_term < 0) <> []) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter value!';
                    message(error_msg);
                end

                if ok & (size(use_init_term, 'r') > 1) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter vector - single row vector expected!';
                    message(error_msg);
                end

                use_init_term_size = size(use_init_term, 'c');
                if ok & (use_init_term_size > 1) & (use_init_term_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end
            else
                ok = %f;
                error_msg = 'Unable to detect MicroDAQ analog outputs - run mdaq_hwinfo and try again!';
                message(error_msg);
            end

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

                // prepare block IPAR/RPAR data
                if dac_range_size == 1 then
                    dac_range_p = ones(n_channels, 1) * dac_info.c_params.c_range(dac_range);
                    dac_range_raw_p = ones(n_channels, 1) * dac_range;
                else
                    dac_range_p = ones(n_channels, 1);
                    dac_range_raw_p = ones(n_channels, 1);
                    for i = 1:n_channels
                        dac_range_p(i) = dac_info.c_params.c_range(dac_range(i));
                        dac_range_raw_p(i) = dac_range(i);
                    end
                end

                // init value
                if init_value_size == 1 then
                    init_value = ones(n_channels, 1) * init_value;
                else
                    init_value = init_value';
                end

                // termination value
                if term_value_size == 1 then
                    term_value = ones(n_channels, 1) * term_value;
                else
                    term_value = term_value';
                end

                // init term enable value
                if use_init_term_size == 1 then
                    use_init_term = ones(n_channels, 1) * use_init_term;
                else
                    use_init_term = use_init_term';
                end

                // set IPAR and RPAR
                model.ipar = [n_channels; channel'; dac_range_p; dac_range_raw_p; use_init_term];
                model.rpar = [init_value; term_value];

                model.dstate = [];
                x.graphics = graphics;
                x.model = model;
                break
            end
        end
    case 'define' then
        channel=1
        dac_range = 1;
        dac_range_raw = 1;
        init_value = 0;
        term_value = 0;
        use_init_term = 2;
        n_channels = 1;
        model=scicos_model();
        model.sim=list('mdaq_dac_sim',5);
        model.in =1;
        model.in2=1;
        model.intyp=1;
        model.out=[];
        model.evtin=1;
        model.rpar = [init_value; term_value];
        // TODO: range hardcoded
        model.ipar = [n_channels; channel'; 3; dac_range_raw; use_init_term];
        model.dstate=[];
        model.blocktype='d';
        model.dep_ut=[%t %f];
        exprs=[sci2exp(channel);sci2exp(dac_range);sci2exp(init_value);sci2exp(term_value);sci2exp(use_init_term)];
        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_dac(job,arg1,arg2)
    global %microdaq;
    if %microdaq.private.mdaq_hwid <> [] then
        dac_info = get_dac_info(%microdaq.private.mdaq_hwid);
        dac_converter = dac_info.id;
        channel_desc = dac_info.channel;
        resolution_desc = dac_info.resolution;
        range_desc = dac_info.c_params.c_range_desc;
        range_spec_opt = [];
        for i = 1:size(dac_info.c_params.c_range_desc, "r")
            range_spec_opt = [range_spec_opt; string(i) + ": " + dac_info.c_params.c_range_desc(i)];
        end
    else
        dac_converter = 1;
        channel_desc = "Unknown";
        resolution_desc = "Unknown";
        range_desc = "Unknown";
        range_spec_opt = "Unknown";
    end

    dac_desc = ["This block writes data to MicroDAQ analog output module (AO).";
    "Block detects MicroDAQ analog output type and allows";
    "setting output range, initial and termination voltage.";
    "The Range value can be a scalar or a vector that must ";
    "be the same length as the channel vector. If scalar value";
    "is specified, that setting is replicated over the channel vector.";
    "Different ranges can be set for each channel if ADC supports ";
    "more then one output range.";
    "The Initial and Termination property can be a scalar or a vector";
    "";
    "Use Init/Term parameter allows to enable or disable setting";
    "initial or/and termination voltage values. User can provide";
    "scalar or vector with following values:";
    "0 - Initial and termination voltage value is ignored";
    "1 - Initial voltage value is used";
    "2 - Termination voltage value is used";
    "3 - Initial and termination voltage value is used";
    "";
    "input - value in volts"
    "";
    "Analog outputs parameters:";
    "Channels: "+channel_desc;
    "Resolution: "+resolution_desc;
    "";
    "Output rage:";
    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,dac_range,init_value,term_value,use_init_term,exprs]=..
                scicos_getvalue(dac_desc,..
                ['Channels:';
                'Range:';
                'Initial value:';
                'Termination value:';
                'Use Init/Term:'],..
                list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs)
            catch
                [ok,channel,dac_range,init_value,term_value,use_init_term,exprs]=..
                scicos_getvalue(dac_desc,..
                ['Channels:';
                'Range:';
                'Initial value:';
                'Termination value:';
                'Use Init/Term:'],..
                list('vec',-1,'vec',-1,'vec',-1,'vec',-1,'vec',-1),exprs)
            end;

            if ~ok then
                break
            end

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

                dac_ch_count = strtod(dac_info.channel);

                // check Channel parameter
                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 > dac_ch_count) then
                    ok = %f;
                    error_msg = 'Too many channels selected!';
                    message(error_msg);
                end

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

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

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

                for i = 1:dac_range_size
                    if ok & (dac_range(i) > size(dac_info.c_params.c_range, 'c')) | (dac_range(i) < 1) then
                        ok = %f;
                        error_msg = 'Wrong range value!';
                        message(error_msg);
                    end
                end

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

                init_value_size = size(init_value, 'c');
                if ok & (init_value_size > 1) & (init_value_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong init value vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end

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

                term_value_size = size(term_value, 'c');
                if ok & (term_value_size > 1) & (term_value_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong termination value vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end

                // check init term enable
                if ok & (find(use_init_term > 3) <> []) | (find(use_init_term < 0) <> []) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter value!';
                    message(error_msg);
                end

                if ok & (size(use_init_term, 'r') > 1) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter vector - single row vector expected!';
                    message(error_msg);
                end

                use_init_term_size = size(use_init_term, 'c');
                if ok & (use_init_term_size > 1) & (use_init_term_size <> n_channels) then
                    ok = %f;
                    error_msg = 'Wrong Use init/term paremeter vector - scalar or vector for selected channels expected!';
                    message(error_msg);
                end
            else
                ok = %f;
                error_msg = 'Unable to detect MicroDAQ analog outputs - run mdaq_hwinfo and try again!';
                message(error_msg);
            end

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

                // prepare block IPAR/RPAR data
                if dac_range_size == 1 then
                    dac_range_p = ones(n_channels, 1) * dac_info.c_params.c_range(dac_range);
                    dac_range_raw_p = ones(n_channels, 1) * dac_range;
                else
                    dac_range_p = ones(n_channels, 1);
                    dac_range_raw_p = ones(n_channels, 1);
                    for i = 1:n_channels
                        dac_range_p(i) = dac_info.c_params.c_range(dac_range(i));
                        dac_range_raw_p(i) = dac_range(i);
                    end
                end

                // init value
                if init_value_size == 1 then
                    init_value = ones(n_channels, 1) * init_value;
                else
                    init_value = init_value';
                end

                // termination value
                if term_value_size == 1 then
                    term_value = ones(n_channels, 1) * term_value;
                else
                    term_value = term_value';
                end

                // init term enable value
                if use_init_term_size == 1 then
                    use_init_term = ones(n_channels, 1) * use_init_term;
                else
                    use_init_term = use_init_term';
                end

                // set IPAR and RPAR
                model.ipar = [n_channels; channel'; dac_range_p; dac_range_raw_p; use_init_term];
                model.rpar = [init_value; term_value];

                model.dstate = [];
                x.graphics = graphics;
                x.model = model;
                break
            end
        end
    case 'define' then
        channel=1
        dac_range = 1;
        dac_range_raw = 1;
        init_value = 0;
        term_value = 0;
        use_init_term = 2;
        n_channels = 1;
        model=scicos_model();
        model.sim=list('mdaq_dac_sim',5);
        model.in =1;
        model.in2=1;
        model.intyp=1;
        model.out=[];
        model.evtin=1;
        model.rpar = [init_value; term_value];
        model.ipar = [n_channels; channel'; dac_range; dac_range_raw; use_init_term];
        model.dstate=[];
        model.blocktype='d';
        model.dep_ut=[%t %f];
        exprs=[sci2exp(channel);sci2exp(dac_range);sci2exp(init_value);sci2exp(term_value);sci2exp(use_init_term)];
        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


Fix for mdaq_upgrade - still test download location

function fw_ver = mdaq_latest_fw()
    try
        getURL("raw.githubusercontent.com/microdaq/Firmware/test/LATEST", TMPDIR + filesep() + "LATEST");
    catch
        fw_ver = [];
        return
    end
    fw_ver = csvRead( TMPDIR + filesep() + "LATEST", " ");
endfunction

function fw_ver = mdaq_latest_fw()
    try
        getURL("raw.githubusercontent.com/microdaq/MLink/upgrade_test/LATEST", TMPDIR + filesep() + "LATEST");
    catch
        fw_ver = [];
        return
    end
    fw_ver = csvRead( TMPDIR + filesep() + "LATEST", " ");
endfunction


Delete VWFA_Color_Localizer_MRI.sce

Delete VWFA_Color_Localizer_MRI.sce

########################################################
# VWFA (Dutch) and 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");


mdaq_dio_func double close error and desc fix

function mdaq_dio_func(arg1, arg2, arg3)

    if argn(2) == 2 then
        func = arg1;
        enable = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        func = arg2;
        enable = arg3;

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

    if argn(2) > 3 | argn(2) < 2 | func > 6 | func == 0 then
        mprintf("Description:\n");
        mprintf("\tSets DIO alternative function\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_dio_func(link_id, func, state);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tfunc - DIO alternative function\n");
        mprintf("\t\t1 - ENC1: DIO1 - Channel A, DIO2 - Channel B (enabled by default)\n");
        mprintf("\t\t2 - ENC2: DIO3 - Channel A, DIO4 - Channel B (enabled by default)\n");
        mprintf("\t\t3 - PWM1: DIO10 - Channel A, DIO11 - Channel B (enabled by default)\n");
        mprintf("\t\t4 - PWM2: DIO12 - Channel A, DIO13 - Channel B (enabled by default)\n");
        mprintf("\t\t5 - PWM3: DIO14 - Channel A, DIO14 - Channel B (enabled by default)\n");
        mprintf("\t\t6 - UART: DIO8 - Rx, DIO9 - Tx (enabled by default)\n");
        mprintf("\tstate - function state (%%T/%%F to enable/disable function)\n");
        return;
    end

    if enable <> %F then
        enable = 1;
    else
        enable = 0;
    end

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

    result = call("sci_mlink_dio_set_func",..
            link_id, 1, "i",..
            func, 2, "i",..
            enable, 3, "i",..
        "out",..
            [1, 1], 4, "i");

    if result < 0 then
        mdaq_error(result);
    end

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

function mdaq_dio_func(arg1, arg2, arg3)

    if argn(2) == 2 then
        func = arg1;
        enable = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        func = arg2;
        enable = arg3;

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

    if argn(2) > 3 | argn(2) < 2 | func > 6 | func == 0 then
        mprintf("Description:\n");
        mprintf("\tSets DIO alternative function\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_dio_func(link_id, func, state);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tfunc - DIO alternative function\n");
        mprintf("\t\t1 - ENC1: DIO1 - Channel A, DIO2 - Channel B (enabled by default)\n");
        mprintf("\t\t2 - ENC2: DIO3 - Channel A, DIO4 - Channel B (enabled by default)\n");
        mprintf("\t\t3 - UART: DIO8 - Rx, DIO9 - Tx (enabled by default)\n");
        mprintf("\t\t4 - PWM1: DIO10 - Channel A, DIO11 - Channel B (enabled by default)\n");
        mprintf("\t\t5 - PWM2: DIO12 - Channel A, DIO13 - Channel B (enabled by default)\n");
        mprintf("\t\t6 - PWM3: DIO14 - Channel A, DIO14 - Channel B (enabled by default)\n");
        mprintf("\tstate - function state (%%T/%%F to enable/disable function)\n");
        return;
    end

    if enable <> %F then
        enable = 1;
    else
        enable = 0;
    end

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

    result = call("sci_mlink_dio_set_func",..
            link_id, 1, "i",..
            func, 2, "i",..
            enable, 3, "i",..
        "out",..
            [1, 1], 4, "i");

    if result < 0 then
        mdaq_error(result);
    end

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

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


fix for SCHEDULING-1392

fix for SCHEDULING-1392

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

function res=PAResult(future,taskinfo)
    global ('PAResult_DB');
    if typeof(PAResult_DB) ~= 'list'
        PAResult_DB = list();
    end
    PAResult_DB($+1) = %f;
    rid = length(PAResult_DB);
    jimport java.util.concurrent.atomic.AtomicBoolean;
    jautoUnwrap(%t);
    jimport java.lang.StringBuilder;
    res = tlist(['PAResult','future','cleanFileSet','cleanDirSet', 'outFile','jobid','taskid', 'cleaned', 'logsPrinted','logs','waited','iserror','resultSet','rid'],future, taskinfo.cleanFileSet, taskinfo.cleanDirSet, taskinfo.outFile, taskinfo.jobid, taskinfo.taskid, jnewInstance(AtomicBoolean,%f), jnewInstance(AtomicBoolean,%f), jnewInstance(StringBuilder), jnewInstance(AtomicBoolean,%f), jnewInstance(AtomicBoolean,%f),jnewInstance(AtomicBoolean,%f), rid);

endfunction

function res=PAResult(future,taskinfo)
    global ('PAResult_DB');
    if ~exists('PAResult_DB')
        PAResult_DB = list();
    end
    PAResult_DB($+1) = %f;
    rid = length(PAResult_DB);
    jimport java.util.concurrent.atomic.AtomicBoolean;
    jautoUnwrap(%t);
    jimport java.lang.StringBuilder;
    res = tlist(['PAResult','future','cleanFileSet','cleanDirSet', 'outFile','jobid','taskid', 'cleaned', 'logsPrinted','logs','waited','iserror','resultSet','rid'],future, taskinfo.cleanFileSet, taskinfo.cleanDirSet, taskinfo.outFile, taskinfo.jobid, taskinfo.taskid, jnewInstance(AtomicBoolean,%f), jnewInstance(AtomicBoolean,%f), jnewInstance(StringBuilder), jnewInstance(AtomicBoolean,%f), jnewInstance(AtomicBoolean,%f),jnewInstance(AtomicBoolean,%f), rid);

endfunction


Fix madq_dio_write description

Fix madq_dio_write description

function mdaq_dio_write(arg1, arg2, arg3)

    if argn(2) == 2 then
        dio = arg1;
        state = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        dio = arg2;
        state = 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("\tStart and reads scann data\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_ai_scan(link_id, scan_count, blocking);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tscan_count - number of scans to read\n");
        mprintf("\tblocking - blocking or non-blocking read (%T/%F)\n");
        return;
    end

    dio_count = mdaq_get_dio_config();
    if dio > dio_count | dio < 1 then
        disp("ERROR: Wrong DIO number!")
        return;
    end

    if type(state) == 4 then
        if state then
            state = 1;
        else
            state = 0;
        end
    else
        if state <> 0 then
           state = 1;
        end
    end

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

    result = call("sci_mlink_dio_set",..
            link_id, 1, "i",..
            dio, 2, "i",..
            state, 3, "i",..
        "out",..
            [1, 1], 4, "i");

    if  result < 0  then
        mdaq_error(result);
    end

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

endfunction

function mdaq_dio_write(arg1, arg2, arg3)

    if argn(2) == 2 then
        dio = arg1;
        state = arg2;
    end

    if argn(2) == 3 then
        link_id = arg1;
        dio = arg2;
        state = 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("\tWrites DIO state\n");
        mprintf("Usage:\n");
        mprintf("\tmdaq_dio_write(link_id, dio, state);\n")
        mprintf("\tlink_id - connection id returned by mdaq_open() (OPTIONAL)\n");
        mprintf("\tdio - DIO number\n");
        mprintf("\tstate - DIO output state\n");
        return;
    end

    dio_count = mdaq_get_dio_config();
    if dio > dio_count | dio < 1 then
        disp("ERROR: Wrong DIO number!")
        return;
    end

    if type(state) == 4 then
        if state then
            state = 1;
        else
            state = 0;
        end
    else
        if state <> 0 then
           state = 1;
        end
    end

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

    result = call("sci_mlink_dio_set",..
            link_id, 1, "i",..
            dio, 2, "i",..
            state, 3, "i",..
        "out",..
            [1, 1], 4, "i");

    if  result < 0  then
        mdaq_error(result);
    end

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

endfunction


sb120: #i111252# disabled failing tests for now

#i98339 -o svx.AccessibleControlShape
-o svx.AccessibleEditableTextPara
#i111252 -o svx.AccessibleGraphicShape
#i46736 -o svx.AccessibleImageBullet
#i111252 -o svx.AccessibleOLEShape
-o svx.AccessiblePageShape
#i111216 -o svx.AccessiblePresentationGraphicShape
#i111216 -o svx.AccessiblePresentationOLEShape
#i85539 -o svx.AccessiblePresentationShape
-o svx.AccessibleShape
#i90294 -o svx.GraphicExporter
-o svx.SvxDrawPage
#i85501 -o svx.SvxGraphCtrlAccessibleContext
#i87746 -o svx.SvxGraphicObject
#i85263 -o svx.SvxShape
#i87746 -o svx.SvxShapeCircle
-o svx.SvxShapeCollection
#i85263 -o svx.SvxShapeConnector
#i87746 -o svx.SvxShapeControl
#i87746 -o svx.SvxShapeDimensioning
#i87746 -o svx.SvxShapeGroup
#i87746 -o svx.SvxShapePolyPolygon
#i87746 -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

#i98339 -o svx.AccessibleControlShape
-o svx.AccessibleEditableTextPara
-o svx.AccessibleGraphicShape
#i46736 -o svx.AccessibleImageBullet
#i111252 -o svx.AccessibleOLEShape
-o svx.AccessiblePageShape
#i111216 -o svx.AccessiblePresentationGraphicShape
#i111216 -o svx.AccessiblePresentationOLEShape
#i85539 -o svx.AccessiblePresentationShape
-o svx.AccessibleShape
#i90294 -o svx.GraphicExporter
-o svx.SvxDrawPage
#i85501 -o svx.SvxGraphCtrlAccessibleContext
#i87746 -o svx.SvxGraphicObject
#i85263 -o svx.SvxShape
#i87746 -o svx.SvxShapeCircle
-o svx.SvxShapeCollection
#i85263 -o svx.SvxShapeConnector
#i87746 -o svx.SvxShapeControl
#i87746 -o svx.SvxShapeDimensioning
#i87746 -o svx.SvxShapeGroup
#i87746 -o svx.SvxShapePolyPolygon
#i87746 -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


Delete deprecated function

Delete deprecated function

function calc_forces()
    global voltageToForce scaleDrift forces
    global forcefile // Muss das?

    forcefile = uigetfile(["*.*", "Force files"], cwd + "/../data/Waage/","Select force data",%t)

    for i = 1 : size(forcefile, 2)
        forceRaw = readScaleFile(forcefile(i));
        force_sum = combineChannels(forceRaw)
        force_smooth = calculateForces(force_sum, scaleDrift, voltageToForce)
        forces(i) = force_smooth
        tmp = tokens(forcefile(i), ['/','.'])
        forces(i).name = tmp($ - 1)
    end

    //forces = force_smooth(1)
endfunction

function inverse_kinetic()

    global body
    global forces
    global g
    global axes_frame
    global results_figure
    global enable_help

    for i = 1 : size(forces, 1)

        [toes, ankle, knee, hip, shoulder, elbow, hand, neck, foot, leg, thigh, leg_total, upperarm, forearm, arm_total, trunk] = setCurrentBody(body(i))

        grfBalance = forces(i)
        // Determine initial Contact from force Data
        force_window = scf(100)
        force_axes = force_window.children

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf den Fuß" "des ersten Kraftpeaks"])
        end

        plot2d(grfBalance.Fz)
        forceStart = locate(1)
        startBalance = int(forceStart(1))
        force_axes.title.text = "Waagenkraft senkrecht"

        // Determine initial Contact from Kinematic Data
        delete(gca())
        plot2d(ankle.y)
        force_axes = gca()
        force_axes.title.text = "Knöchel, Y-Koordinate bei v = " + body(i).name

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf initialen minimalen" "y-Wert der Hacke"])
        end

        startContact = locate(1)
        initialContact = floor(startContact(1))

        delete(gca())
        plot2d(toes.y)
        force_axes = gca()
        force_axes.title.text = "Zehen, Y-Koordinate bei v = " + body(i).name

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf letzten minimalen" "y-Wert der Zehen"])
        end

        tmp = locate(1)
        liftOff = ceil(tmp(1))

        delete(force_window)

        center_of_balance = getCobValues()

        // Create Ground reaction force object
        grf.Fx = grfBalance.Fy(startBalance:2:$)
        grf.Fy = grfBalance.Fz(startBalance:2:$)
        grf.x = grfBalance.CoF_y(startBalance:2:$) + center_of_balance.x
        grf.y = center_of_balance.y

        // INVERSE KINETICS

        contactLength = liftOff - initialContact

        // Slice data that is needed for inverse kinetics to frames with ground contact

        foot.acc.x = foot.acc.x(initialContact: liftOff)
        foot.acc.y = foot.acc.y(initialContact: liftOff)
        foot.angacc = foot.angacc(initialContact : liftOff)
        foot.x = foot.x(initialContact : liftOff)
        foot.y = foot.y(initialContact : liftOff)
        ankle.x = ankle.x(initialContact : liftOff)
        ankle.y = ankle.y(initialContact : liftOff)

        leg.acc.x = leg.acc.x(initialContact : liftOff)
        leg.acc.y = leg.acc.y(initialContact : liftOff)
        leg.angacc = leg.angacc(initialContact : liftOff)
        leg.x = leg.x(initialContact : liftOff)
        leg.y = leg.y(initialContact : liftOff)
        knee.x = knee.x(initialContact : liftOff)
        knee.y = knee.y(initialContact : liftOff)

        thigh.acc.x = thigh.acc.x(initialContact : liftOff)
        thigh.acc.y = thigh.acc.y(initialContact : liftOff)
        thigh.angacc = thigh.angacc(initialContact : liftOff)
        thigh.x = thigh.x(initialContact : liftOff)
        thigh.y = thigh.y(initialContact : liftOff)
        hip.x = hip.x(initialContact : liftOff)
        hip.y = hip.y(initialContact : liftOff)

        // Iterate over ground contact duration
        for j = 1 : contactLength
            // Waagewerte Fy positiv, wenn positive Belastung
            // Waagenwerte Fx negativ, wenn Bremsen --> Umdrehen
            grf.Fx(j) = - grf.Fx(j)

            // Kräfte beim Einlesen umschreiben um Koordinatensystem anzupassen!

            // Calculate Joint forces and moments
            ankle.Fx(j) = foot.mass * foot.acc.x(j) - grf.Fx(j)
            ankle.Fy(j) = foot.mass * (foot.acc.y(j) - g) - grf.Fy(j)
            ankle.M(j) = foot.MoI * foot.angacc(j)...
                      - ankle.Fy(j) * (ankle.x(j) - foot.x(j)) - ankle.Fx(j) * (foot.y(j) - ankle.y(j))...
                      - grf.Fx(j) * ( foot.y(j) - grf.y ) - grf.Fy(j) * (grf.x(j) - foot.x(j))

            //knee.Fx(j) = leg.mass * leg.acc.x(j) - ankle.Fx(j) * (-1)
            knee.Fx(j) = leg.mass * leg.acc.x(j) - ankle.Fx(j) * (-1)
            knee.Fy(j) = leg.mass * (leg.acc.y(j) - g) - ankle.Fy(j) * (-1)
            knee.M(j) = leg.MoI * leg.angacc(j) - ankle.M(j) * (-1)...
                     - knee.Fy(j) * (knee.x(j) - leg.x(j)) - knee.Fx(j) * (leg.y(j) - knee.y(j))...
                     - ankle.Fx(j) * (-1) * (leg.y(j) - ankle.y(j)) - ankle.Fy(j) * (-1) * (ankle.x(j) - leg.x(j))

            hip.Fx(j) = thigh.mass * thigh.acc.x(j) - knee.Fx(j) * (-1)
            hip.Fy(j) = thigh.mass * (thigh.acc.y(j) - g) - knee.Fy(j) * (-1)
            hip.M(j) = thigh.MoI * thigh.angacc(j) - knee.M(j) * (-1)...
                     - hip.Fy(j) * (hip.x(j) - thigh.x(j)) - hip.Fx(j) * (thigh.y(j) - hip.y(j))...
                     - knee.Fx(j) * (-1) * (thigh.y(j) - knee.y(j)) - knee.Fy(j) * (-1) * (knee.x(j) - thigh.x(j))

         end

         body(i).ankle.Fx = ankle.Fx
         body(i).ankle.Fy = ankle.Fy
         body(i).ankle.M = ankle.M

         body(i).knee.Fx = knee.Fx
         body(i).knee.Fy = knee.Fy
         body(i).knee.M = knee.M

         body(i).hip.Fx = hip.Fx
         body(i).hip.Fy = hip.Fy
         body(i).hip.M = hip.M

//        force_window.visible = "on"

//        delete(gca())

        timesteps = contactLength
        time = linspace(0, 1, timesteps)

        sca(axes_results)
        clear_plot(axes_results)

        setAxes(gca(), "Belastungsdauer", 5, "Kraft [N]", 5);
        plot(time, ankle.Fy, 'r')
        plot(time, knee.Fy, 'b')
        plot(time, hip.Fy, 'g')

        legend("Knöchel", "Knie", "Hüfte")

        results_figure.visible = "on"
    end
endfunction

function calc_forces()
    global voltageToForce scaleDrift forces
    global forcefile // Muss das?

    forcefile = uigetfile(["*.*", "Force files"], cwd + "/../data/Waage/","Select force data",%t)

    for i = 1 : size(forcefile, 2)
        forceRaw = readScaleFile(forcefile(i));
        force_sum = combineChannels(forceRaw)
        force_smooth = calculateForces(force_sum, scaleDrift, voltageToForce)
        forces(i) = force_smooth
        tmp = tokens(forcefile(i), ['/','.'])
        forces(i).name = tmp($ - 1)
    end

    //forces = force_smooth(1)
endfunction

function [force] = load_forces(path)
    forceRaw = readScaleFile(path);
    force_sum = combineChannels(forceRaw, 2.5)
    force = calculateForces(force_sum, scaleDrift, voltageToForce)
endfunction

function inverse_kinetic()

    global body
    global forces
    global g
    global axes_frame
    global results_figure
    global enable_help

    for i = 1 : size(forces, 1)

        [toes, ankle, knee, hip, shoulder, elbow, hand, neck, foot, leg, thigh, leg_total, upperarm, forearm, arm_total, trunk] = setCurrentBody(body(i))

        grfBalance = forces(i)
        // Determine initial Contact from force Data
        force_window = scf(100)
        force_axes = force_window.children

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf den Fuß" "des ersten Kraftpeaks"])
        end

        plot2d(grfBalance.Fz)
        forceStart = locate(1)
        startBalance = int(forceStart(1))
        force_axes.title.text = "Waagenkraft senkrecht"

        // Determine initial Contact from Kinematic Data
        delete(gca())
        plot2d(ankle.y)
        force_axes = gca()
        force_axes.title.text = "Knöchel, Y-Koordinate bei v = " + body(i).name

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf initialen minimalen" "y-Wert der Hacke"])
        end

        startContact = locate(1)
        initialContact = floor(startContact(1))

        delete(gca())
        plot2d(toes.y)
        force_axes = gca()
        force_axes.title.text = "Zehen, Y-Koordinate bei v = " + body(i).name

        if enable_help == %t then
            messagebox(["Synchronisation:" "Klicke auf letzten minimalen" "y-Wert der Zehen"])
        end

        tmp = locate(1)
        liftOff = ceil(tmp(1))

        delete(force_window)

        center_of_balance = getCobValues()

        // Create Ground reaction force object
        grf.Fx = grfBalance.Fy(startBalance:2:$)
        grf.Fy = grfBalance.Fz(startBalance:2:$)
        grf.x = grfBalance.CoF_y(startBalance:2:$) + center_of_balance.x
        grf.y = center_of_balance.y

        // INVERSE KINETICS

        contactLength = liftOff - initialContact

        // Slice data that is needed for inverse kinetics to frames with ground contact

        foot.acc.x = foot.acc.x(initialContact: liftOff)
        foot.acc.y = foot.acc.y(initialContact: liftOff)
        foot.angacc = foot.angacc(initialContact : liftOff)
        foot.x = foot.x(initialContact : liftOff)
        foot.y = foot.y(initialContact : liftOff)
        ankle.x = ankle.x(initialContact : liftOff)
        ankle.y = ankle.y(initialContact : liftOff)

        leg.acc.x = leg.acc.x(initialContact : liftOff)
        leg.acc.y = leg.acc.y(initialContact : liftOff)
        leg.angacc = leg.angacc(initialContact : liftOff)
        leg.x = leg.x(initialContact : liftOff)
        leg.y = leg.y(initialContact : liftOff)
        knee.x = knee.x(initialContact : liftOff)
        knee.y = knee.y(initialContact : liftOff)

        thigh.acc.x = thigh.acc.x(initialContact : liftOff)
        thigh.acc.y = thigh.acc.y(initialContact : liftOff)
        thigh.angacc = thigh.angacc(initialContact : liftOff)
        thigh.x = thigh.x(initialContact : liftOff)
        thigh.y = thigh.y(initialContact : liftOff)
        hip.x = hip.x(initialContact : liftOff)
        hip.y = hip.y(initialContact : liftOff)

        // Iterate over ground contact duration
        for j = 1 : contactLength
            // Waagewerte Fy positiv, wenn positive Belastung
            // Waagenwerte Fx negativ, wenn Bremsen --> Umdrehen
            grf.Fx(j) = - grf.Fx(j)

            // Kräfte beim Einlesen umschreiben um Koordinatensystem anzupassen!

            // Calculate Joint forces and moments
            ankle.Fx(j) = foot.mass * foot.acc.x(j) - grf.Fx(j)
            ankle.Fy(j) = foot.mass * (foot.acc.y(j) - g) - grf.Fy(j)
            ankle.M(j) = foot.MoI * foot.angacc(j)...
                      - ankle.Fy(j) * (ankle.x(j) - foot.x(j)) - ankle.Fx(j) * (foot.y(j) - ankle.y(j))...
                      - grf.Fx(j) * ( foot.y(j) - grf.y ) - grf.Fy(j) * (grf.x(j) - foot.x(j))

            //knee.Fx(j) = leg.mass * leg.acc.x(j) - ankle.Fx(j) * (-1)
            knee.Fx(j) = leg.mass * leg.acc.x(j) - ankle.Fx(j) * (-1)
            knee.Fy(j) = leg.mass * (leg.acc.y(j) - g) - ankle.Fy(j) * (-1)
            knee.M(j) = leg.MoI * leg.angacc(j) - ankle.M(j) * (-1)...
                     - knee.Fy(j) * (knee.x(j) - leg.x(j)) - knee.Fx(j) * (leg.y(j) - knee.y(j))...
                     - ankle.Fx(j) * (-1) * (leg.y(j) - ankle.y(j)) - ankle.Fy(j) * (-1) * (ankle.x(j) - leg.x(j))

            hip.Fx(j) = thigh.mass * thigh.acc.x(j) - knee.Fx(j) * (-1)
            hip.Fy(j) = thigh.mass * (thigh.acc.y(j) - g) - knee.Fy(j) * (-1)
            hip.M(j) = thigh.MoI * thigh.angacc(j) - knee.M(j) * (-1)...
                     - hip.Fy(j) * (hip.x(j) - thigh.x(j)) - hip.Fx(j) * (thigh.y(j) - hip.y(j))...
                     - knee.Fx(j) * (-1) * (thigh.y(j) - knee.y(j)) - knee.Fy(j) * (-1) * (knee.x(j) - thigh.x(j))

         end

         body(i).ankle.Fx = ankle.Fx
         body(i).ankle.Fy = ankle.Fy
         body(i).ankle.M = ankle.M

         body(i).knee.Fx = knee.Fx
         body(i).knee.Fy = knee.Fy
         body(i).knee.M = knee.M

         body(i).hip.Fx = hip.Fx
         body(i).hip.Fy = hip.Fy
         body(i).hip.M = hip.M

//        force_window.visible = "on"

//        delete(gca())

        timesteps = contactLength
        time = linspace(0, 1, timesteps)

        sca(axes_results)
        clear_plot(axes_results)

        setAxes(gca(), "Belastungsdauer", 5, "Kraft [N]", 5);
        plot(time, ankle.Fy, 'r')
        plot(time, knee.Fy, 'b')
        plot(time, hip.Fy, 'g')

        legend("Knöchel", "Knie", "Hüfte")

        results_figure.visible = "on"
    end
endfunction


echo off

echo off

//stacksize(40000000)
location = 'C:\cygwin\home\Zhan\repository\graph-classifier\dataset\'
edgelists = [
  'er-8-8.txt',
  'er-9-8.txt',
  'er-10-8.txt',
  'er-11-8.txt',
//  'er-12-8.txt',
  'ba-8-8.txt',
  'ba-9-8.txt',
  'ba-10-8.txt',
  'ba-11-8.txt',
//  'ba-12-8.txt',
  'sw-8-8.txt',
  'sw-9-8.txt',
  'sw-10-8.txt',
  'sw-11-8.txt',
//  'sw-12-8.txt',
  'rmat-8-8.txt',
  'rmat-9-8.txt',
  'rmat-10-8.txt',
  'rmat-11-8.txt'
//  'rmat-12-8.txt'
]

mode(-1)

for i = 1:size(edgelists, 1)
  edges = fscanfMat(location + edgelists(i))
  for e = 1:size(edges, 1)
    u = edges(e, 1)
    v = edges(e, 2)
    m(u + 1, v + 1) = 1
  end
  sv = svd(m)
  mprintf("% 16s %16f %16f %16f\n", edgelists(i), sv(1:3)')
  clear edges m e u v sv
end

//stacksize(40000000)
location = 'C:\cygwin\home\Zhan\repository\graph-classifier\dataset\'
edgelists = [
  'er-8-8.txt',
  'er-9-8.txt',
  'er-10-8.txt',
  'er-11-8.txt',
//  'er-12-8.txt',
  'ba-8-8.txt',
  'ba-9-8.txt',
  'ba-10-8.txt',
  'ba-11-8.txt',
//  'ba-12-8.txt',
  'sw-8-8.txt',
  'sw-9-8.txt',
  'sw-10-8.txt',
  'sw-11-8.txt',
//  'sw-12-8.txt',
  'rmat-8-8.txt',
  'rmat-9-8.txt',
  'rmat-10-8.txt',
  'rmat-11-8.txt'
//  'rmat-12-8.txt'
]

for i = 1:size(edgelists, 1)
  edges = fscanfMat(location + edgelists(i))
  for e = 1:size(edges, 1)
    u = edges(e, 1)
    v = edges(e, 2)
    m(u + 1, v + 1) = 1
  end
  sv = svd(m)
  mprintf("% 16s %16f %16f %16f\n", edgelists(i), sv(1:3)')
  clear edges m e u v sv
end


INTEGRATION: CWS qadev32 (1.6.24); FILE MERGED 2008/05/05 10:53:27 cn 1.6.24.2: #i87216# update lists 2008/04/16 18:10:33 cn 1.6.24.1: #i87216# update lists

#i88276 -o svtools.AccessibleIconChoiceCtrlEntry
#i88647 -o svtools.AccessibleTabBarPage
-o svtools.AccessibleBrowseBox
-o svtools.AccessibleBrowseBoxHeaderBar
-o svtools.AccessibleBrowseBoxHeaderCell
-o svtools.AccessibleBrowseBoxTable
#i85245 -o svtools.AccessibleBrowseBoxTableCell
#i88276 -o svtools.AccessibleIconChoiceCtrl
-o svtools.AccessibleTabBar
#i85246 -o svtools.AccessibleTabBarPageList
-o svtools.AccessibleTreeListBox
-o svtools.AccessibleTreeListBoxEntry

-o svtools.AccessibleIconChoiceCtrlEntry
-o svtools.AccessibleTabBarPage
-o svtools.AccessibleBrowseBox
-o svtools.AccessibleBrowseBoxHeaderBar
-o svtools.AccessibleBrowseBoxHeaderCell
-o svtools.AccessibleBrowseBoxTable
#i85245 -o svtools.AccessibleBrowseBoxTableCell
-o svtools.AccessibleIconChoiceCtrl
-o svtools.AccessibleTabBar
#i85246 -o svtools.AccessibleTabBarPageList
-o svtools.AccessibleTreeListBox
-o svtools.AccessibleTreeListBoxEntry


Limit AI scanning cannels to consecutive starting from first channel

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

    if channels(1) <> 1 then
        disp("ERROR: Scan should start from channel number 1!")
        return;
    end

    if find((channels == (1:max(channels))) == %F) <> [] then
        disp("ERROR: Only consecutive channels can be used!")
        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");

    if result < 0 & result <> -88 then
            if argn(2) == 5 then
                mdaq_close(link_id);
            end
            error(mdaq_error2(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

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

        if result < 0 then
            error(mdaq_error2(result), 10000 + abs(result));
        end

        if result == 1 then
            mprintf("\nWARNING: Your MicroDAQ device does not allow running AI and AO scanning session simultaneously.\n")
        end

        mprintf("\nData 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
endfunction

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");

    if result < 0 & result <> -88 then
            if argn(2) == 5 then
                mdaq_close(link_id);
            end
            error(mdaq_error2(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

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

        if result < 0 then
            error(mdaq_error2(result), 10000 + abs(result));
        end

        if result == 1 then
            mprintf("\nWARNING: Your MicroDAQ device does not allow running AI and AO scanning session simultaneously.\n")
        end

        mprintf("\nData 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
endfunction