Maximun length in a cell of data matrix
Hello,
I am using data matrix in order to fill loop in open sesame (I find it more convenient loading first the variable then filling the loop by using data matrix).
Anyway my issue is as follow. I have string of 64 characters made of 0 and 1, because I use this binary coding for filling a matrix of square with various patterns represented by these strings.
So I first created lists of stims, then I create a data matrix object from these lists that I use as a loop.
This strategy worked but not with so long strings apparently:
import numpy as np
from datamatrix import DataMatrix
dmSymPract = DataMatrix(length = 15)
dmPractice_Sym_Stim_Coord = list()
dmPractice_Sym_Stim_Correctness = list()
dmPractice_Sym_Stim_Coord.append('0001100000011000001111000111111011111111011001100011110000011000') #1
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1100001111100111110110111011110110011001101111011100001111111111') #2
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1111111100111100000110000011110000100100001001000011110001011010') #3
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1100001111000011111111110011110000111100111111111100001111000011') #4
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1111111101111110111111110001100000011000111111110111111011111111') #5
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1111111111011011010000101101101111011011010000101101101111111111') #6
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1100001101100110001111001111111111111111001111000110011011000011') #7
dmPractice_Sym_Stim_Correctness.append(True)
dmPractice_Sym_Stim_Coord.append('1111101100100110110000100111111101111111110000100010011011111011') #8
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('0000000111000011111001111111110110000001101111111110011111000011') #9
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('0010010011111111101011011011010110111101101111011111111100100100') #10
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('1011110101011010100110011111111111111111100010010100101010111101') #11
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('1110011110100110111111111010011010100110111111111010011011100111') #12
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('1111111111101011110100111100101111010011010010101101011111111111') #13
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('1111111101000110111001111110011111100111111001110100011011111111') #14
dmPractice_Sym_Stim_Correctness.append(False)
dmPractice_Sym_Stim_Coord.append('1111011111111111110000110111111001111110110000111111111111101111') #15
dmPractice_Sym_Stim_Correctness.append(False)
np_Practice_Sym_Stim_Coord = np.transpose([dmPractice_Sym_Stim_Coord])
np_Practice_Sym_Stim_Correctness = np.transpose([dmPractice_Sym_Stim_Correctness])
np_Practice_Sym_Stim = np.stack((np_Practice_Sym_Stim_Coord, np_Practice_Sym_Stim_Correctness), axis=-1)
np_Practice_Sym_Stim = np.squeeze(np_Practice_Sym_Stim, axis=1)
dmSymPract = DataMatrix(length = 15)
dmSymPract.StimSym = ''
dmSymPract.Correctness = ''
dmSymPract.StimSym[0] = np_Practice_Sym_Stim[0][0] # doesnt work
dmSymPract.StimSym[0] = str(np_Practice_Sym_Stim[0][0]) # doesnt work
dmSymPract.StimSym[0] = '0001100000011000001111000111111011111111011001100011110000011000' # doesnt work
dmSymPract.StimSym[0] = 0001100000011000001111000111111011111111011001100011110000011000 # doesnt work
So the traceback I have everytime is:
Traceback:
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\inline_script.py", line 96, in run
self.experiment.python_workspace._exec(self.crun)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\libopensesame\python_workspace.py", line 174, in _exec
exec(bytecode, self._globals)
Inline script, line 11, in
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\datamatrix_datamatrix_basecolumn.py", line 781, in setitem
self._setintkey(key, value)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\datamatrix_datamatrix_basecolumn.py", line 518, in _setintkey
self._seq[key] = self._checktype(value)
File "C:\Program Files (x86)\OpenSesame\lib\site-packages\datamatrix_datamatrix_basecolumn.py", line 344, in _checktype
raise TypeError('Invalid type: %s' % value)
TypeError: Invalid type: 1100000011000001111000111111011111111011001100011110000011000
Thanks for any help!
Sylvain
Comments
Damn there is a typo in my script ( but it does not change the issue).
The line:
is actually
Sorry!
Hi Sylvain,
Right—what happens here is that DataMatrix tries to process this string as a number. But because it's such a big number, it becomes a
long
type, and DataMatrix doesn't accept that. I'll fix this in an upcoming release of DataMatrix. For now, if this is possible, you could use strings that are clearly not numbers, for example prefixing a '_' character or something.Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Perfect thank you!
Best,
Sylvain