【Gorilla】Gorilla平台实现刺激随机呈现
目的:让stimuli能够随机呈现在实验中
Speadsheet:
代码:
//-------------------
// REQUIRED VARIABLES
//-------------------
// These are the variable you may want to change
// Spreadsheet processing
// Collecting and assigning player names to trials
// This variable indicates the spreadsheet metadata column we need to collect player names from
var _requiredDigitsSetColumn: string = ‘digitsSet’;
// This variable indicates the spreadsheet column we need to assign player names to
var _requiredDigitsAssignmentColumn: string = ‘digits’;
// This variable indicates the key in which we’ll store the random number used to shuffle the playerNames
// This way, if we need to rebuild the shuffled names for whatever reason (the participant refreshes the screen for example)
// They’ll get the same spreadsheet setup
var _randomSeedKey: string = ‘randomKeySeed’;
// Dynamic display
// This variable indicates the display name for trials where we want to add the dynamic content
var _requiredDynamicDisplay: string = ‘presentation’;
//------------
// random number
//------------
// The preProcessSpreadsheet hook allows us to define functionality that Gorilla will execute before randomising the
// spreadsheet contents based on randomise trials and randomise blocks
gorillaTaskBuilder.preProcessSpreadsheet((spreadsheet: any) => {
// STAGE ONE
// Collect our set of potential player names
var digitsSet: string[] = [];
// loop through the whole spreadsheet
for(var i = 0; i < spreadsheet.length; i++){// Check that the column exists and that it's contents is more than the empty stringif(spreadsheet[i][_requiredDigitsSetColumn] && spreadsheet[i][_requiredDigitsSetColumn] != ''){// add the contents to our set of player namesdigitsSet.push(spreadsheet[i][_requiredDigitsSetColumn])}
}// STAGE TWO
// Shuffle our set of player names// First, retrieve our random seed from the store
var randomSeed: number = gorilla.retrieve(_randomSeedKey, null, false);
// if we don't have one, create one using the current date timestamp
if(!randomSeed){randomSeed = Date.now();gorilla.store(_randomSeedKey, randomSeed, false);
}var shuffledDigitsSet: string[] = gorilla.shuffle(digitsSet, randomSeed);// STAGE THREE
// Generate a new spreadsheet with the player names from shuffledPlayerNameSet
// To do this, for each row with the required display we find, we'll draw a name from the shuffled list
// While you should have more names than you do trials, we'll still include a check for this
var modifiedSpreadsheet: any = [];
var currentDigitsPosition: number = 0;
// loop through existing spreadsheet
for(var i = 0; i < spreadsheet.length; i++){// check if the display in the current row matches our target displayif(_requiredDynamicDisplay && spreadsheet[i].display == _requiredDynamicDisplay){// check that our current iteration variable is within the range of the shuffled arrayif(currentDigitsPosition < shuffledDigitsSet.length){// add our player name to the spreadsheet row, iterate and push to the modified spreadsheetspreadsheet[i][_requiredDigitsAssignmentColumn] = shuffledDigitsSet[currentDigitsPosition];currentDigitsPosition++;modifiedSpreadsheet.push(spreadsheet[i]);} else { // just push the row as ismodifiedSpreadsheet.push(spreadsheet[i]);}} else { // push the row as ismodifiedSpreadsheet.push(spreadsheet[i]);}
}return modifiedSpreadsheet;
})
【Gorilla】Gorilla平台实现刺激随机呈现相关推荐
- 记一次amd平台win10/win11随机死机蓝屏重启的问题
先说一下这次的平台是 主板:华硕b550m-e wifi, cpu:amd r5 5600G, 内存:金士顿的ddr4 3200hz 16g, 主要硬盘:金士顿 nvme m2接口 512g. 问题是 ...
- 手机制作音乐专辑封面_你如何制作好的专辑封面
手机制作音乐专辑封面 The best-loved albums of all time only seem to stand out in our memories (and the shelves ...
- 路由复用器--gorilla/mux
简介 gorilla/mux是 gorilla Web 开发工具包中的路由管理库.gorilla Web 开发包是 Go 语言中辅助开发 Web 服务器的工具包.它包括 Web 服务器开发的各个方面, ...
- PsychoPy开源免费刺激呈现软件的下载与安装方法
<本文同步发布于"脑之说"微信公众号,欢迎搜索关注~~> 无论是行为学实验还是电生理或脑成像实验,实验程序的编写都是非常重要的系统实现部分.目前,可供研究人员使用的刺激 ...
- Psychtoolbox刺激呈现方式
用完就忘,忘了就查,查完不会.索性这次备注一下. PTB刺激呈现的方式 先讲CRT显示器. CRT显示器的原理可以百度.当电子束扫完最后一行最右边的像素点时,会跳回到第一行最左边的像素点重新开始扫描. ...
- Go 每日一库之 gorilla/mux
简介 gorilla/mux是 gorilla Web 开发工具包中的路由管理库.gorilla Web 开发包是 Go 语言中辅助开发 Web 服务器的工具包.它包括 Web 服务器开发的各个方面, ...
- gin:结合gorilla实现webSocket
gin框架写rest接口特别6,性能也很好. 本文介绍一下gin和gorilla结合创建websocket 文章目录 1. gin 2. gorilla 3. js代码 5. 测试 1. gin gi ...
- 刺激前低的EEG alpha功率增强了视觉知觉,但不是视觉知觉敏感度
刺激前的神经振荡活动与感觉刺激的意识水平有关.更具体地说,刺激开始前的低频振荡(主要在alpha波段,即8-14 Hz)的功率与视觉任务中的主观表现(如信心和视觉知觉[confidence and v ...
- 数字藏品平台搭建需要注意哪些法律风险及资质?
NFT自从2021年火爆出圈以来,受到市场的广泛关注和讨论.然而,海外市场的NFT的产品逻辑与国内市场的数字藏品并不完全一样,所面临监管环境.发展路径.风险敞口也有如云泥.长远来看,产业的健康发展离不 ...
最新文章
- Javascript创建数组的方式你了解了吗
- Java多线程模式-Balking模式
- 中国城市园林绿化行业十四五规划方向与投资前景建议报告2022版
- 序列化的作用_Java 序列化的高级认识
- 怎么样把Java的字符串转化为字节数组?
- java常用23,JAVA基础(23)---数组的常用操作
- Magento 通知朋友 Tell A Friend Extensions
- 如何使用pandas正确读取带有中文的cvs文件
- Spring之RMI 远程方法调用 (Remote Method Invocation)
- 【通信】基于matlab量子密钥分发密钥率仿真【含Matlab源码 1662期】
- selenium-远程调用
- 安卓app里播放youtube视频
- 百度搜索引擎工作原理解读
- mysql insert返回值_各种SQL Insert 返回值
- 华为android o适配名单,华为给出首批升级名单,这8款华为手机率先适配Android Q 10系统...
- js判断苹果ios各类机型
- 瞒不住了,Prefetch 就是一个大谎言
- DirectX11 Direct3D初始化
- matlab 调用摄像头拍照
- 测绘专业计算机编程要求,关于一些测绘圈子的信息,你需要了解!