psychopy.org | Reference | Downloads | Github

Using previously shuffled array as selection in TrialHandler.importConditions()

Hello,

I have a question regarding the selection in TrialHandler.importConditions(). Because we want to always present the first Item first and the last Item last and only want to shuffle the Items in between, we created an array we want to use as selection during TrialHandler.importConditions():
index = [1, 2, 3, 4, 5];
shuffle(index);
index.unshift(0);
index.push(6);

When using the array as selection however, the list of items just gets presented in the order of the input file. We used the SEQENTIAL Method to make sure the items are presented in the order specified in selection.

TrialsAbruf = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, originPath: undefined,
trialList: TrialHandler.importConditions(psychoJS.serverManager, (AbrufListe + “.xlsx”), index),
seed: undefined, name: ‘TrialsAbruf’

After trying around a little bit, it seems like the array used for the selection gets sorted form 0 to 6 on import,destroying the randomiziation. I am quite new to PsychoPy and PsychoJS, so I cannot find confirmation of this sorting the the TrialHandler code.

Does anybody know if I am correct in my assumption?

Moreover, does anybody haven an Idea how to solve or circumvent the problem of this “half-randomized” import/presentation of stimuli.

Thanks in advance.

Hello guys,

we solved this problem on our own.
If you transform the selection variable into a string (so index.toString()) the shuffle works perfectly.

Best wishes :slight_smile:

1 Like