% This program creates an XML file in the current directory. The file can % be run in OpenCell to simulate the neuron model given on p.400 in Butera % et. al 1999b. g_syn_e is given pseudo-random values from a normal % distribution of user specified mean and standard deviation. % % Note: To run the outputted file in OpenCell, the one cell model from the % repository must be in the same folder, and its name should not have been % changed. % Ask user how many neurons are to be modelled disp (' ') ; neuronCount = input ('How many neurons are to be modelled : ') ; % Prompt user to enter the seed of the random number generation disp (' ') ; SEED = input ('Please enter the seed of the random number generation: ') ; % Prompt user to enter the mean and standard deviation of the normal dist. disp (' ') ; g_syn_e_mean = input ('Please enter the mean of g_syn_e normal distribution : ') ; g_syn_e_stdDev = input ('Please enter the standard deviation of g_syn_e normal distribution : ') ; % Create array of pseudo-random g_syn_e values randn ('seed', SEED) ; g_syn_e = g_syn_e_mean + g_syn_e_stdDev * randn (neuronCount, neuronCount) ; % Begin XML code, and add imports and connections f = [ '\n' ... ' \n\n' ... '\n' ... '\n' ... '\n' ... '\n' ... ]; xmlCode = sprintf (f , neuronCount, neuronCount, SEED, g_syn_e_mean, g_syn_e_stdDev) ; for i = 1 : neuronCount f = [ ... ' \n' ... ' \n' ... ' \n' ... '\n' ... ' \n' ... ' ' ... ' \n' ... ' \n' ... ' \n\n' ... ]; importsConnections = sprintf (f, i, i, i,i) ; xmlCode = [xmlCode importsConnections] ; end % Adding g_syn_e units, and initialising the synaptic component code f = [ ... ' \n' ... ' \n' ... ' \n' ... '\n' ... ' \n' ... ' \n' ... ' \n' ... '\n' ... ' \n' ... ' \n' ... ' \n' ... '\n' ... ' \n' ... ] ; g_syn_e_misc = sprintf (f) ; xmlCode = [xmlCode g_syn_e_misc] ; % Adding sum_g_syn_e_s variables and g_syn_e values for i = 1 : neuronCount sum_g_syn_e_s_variables = sprintf (' \n', i) ; xmlCode = [xmlCode sum_g_syn_e_s_variables] ; end formatting = sprintf ('\n') ; xmlCode = [xmlCode formatting] ; for i = 1 : neuronCount for j = 1 : neuronCount if (i ~= j) g_syn_e_values = sprintf (' \n', g_syn_e (i, j), i, j) ; xmlCode = [xmlCode g_syn_e_values] ; end end end % Adding a variable to represent each neuron and g_syn_e math code xmlCode = [xmlCode formatting] ; for i = 1 : neuronCount neuronVariables = sprintf (' \n', i) ; xmlCode = [xmlCode neuronVariables] ; end xmlCode = [xmlCode formatting] ; initialMath = sprintf (' \n') ; xmlCode = [xmlCode initialMath] ; for j = 1 : neuronCount sum_g_syn_e_s_math = sprintf (' \n sum_g_syn_e_s_%d \n \n', j) ; xmlCode = [xmlCode sum_g_syn_e_s_math] ; for i = 1 : neuronCount if (i ~= j) f = [ ... ' \n' ... ' \n' ... ' g_syn_e_%d_%d \n' ... ' s%d \n' ... ' \n' ... ] ; g_syn_e_math = sprintf (f, i, j, i) ; xmlCode = [xmlCode g_syn_e_math] ; end end mathEnd = sprintf (' \n \n\n') ; xmlCode = [xmlCode mathEnd] ; end ending = sprintf (' \n \n\n') ; xmlCode = [xmlCode ending] ; % Adding code for the component which allows session file creation initialise = sprintf (' \n') ; xmlCode = [xmlCode initialise] ; timeDuplicateA = sprintf (' \n') ; xmlCode = [xmlCode timeDuplicateA] ; timeDuplicateB = sprintf (' \n\n') ; xmlCode = [xmlCode timeDuplicateB] ; for i = 1 : neuronCount f = [ ... ' \n' ... ' \n \n' ... ] ; sessionComponent = sprintf (f, i,i,i) ; xmlCode = [xmlCode sessionComponent] ; end % Adding math for above component xmlCode = [xmlCode initialMath] ; timeDuplicateMath = sprintf( ' timeDuplicatetime \n\n') ; xmlCode = [xmlCode timeDuplicateMath] ; for i = 1 : neuronCount sessionMath = sprintf (' V%dDuplicateV%d \n\n', i,i) ; xmlCode = [xmlCode sessionMath] ; end xmlCode = [xmlCode ending] ; f = [ ... ' \n' ... ' \n' ... ' \n' ... ' \n\n' ... ] ; timeConnection = sprintf (f , i,i,i) ; xmlCode = [xmlCode timeConnection] ; % Adding connections for session file creation for i = 1 : neuronCount f = [ ... ' \n' ... ' \n' ... ' \n' ... ' \n\n' ... ] ; sessionConnections = sprintf (f, i,i) ; xmlCode = [xmlCode sessionConnections] ; end xmlCode = [xmlCode ''] ; % Create XML file myfid = fopen ('buteraModelXML.cellml','w') ; % Write code to file fprintf (myfid, '%s', xmlCode) ; % Close file fclose(myfid) ;