@m2c2kit/assessment-color-shapes 0.8.32 → 0.8.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/data.d.ts +3 -0
- package/dist/__tests__/data.d.ts.map +1 -0
- package/dist/__tests__/python-code.d.ts +2 -0
- package/dist/__tests__/python-code.d.ts.map +1 -0
- package/dist/__tests__/scoring.test.d.ts +2 -0
- package/dist/__tests__/scoring.test.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1347 -48
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/package.json +12 -10
- package/schemas.json +247 -1
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Game as de,RandomDraws as v,Sprite as me,Scene as B,M2Error as ne,WebColors as S,Transition as $,Shape as w,Label as oe,Action as y,Timer as H,Easings as fe,TransitionDirection as ge}from"@m2c2kit/core";import{LocalePicker as _e,Instructions as Z,CountdownScene as Te,Grid as ie,Button as Y}from"@m2c2kit/addons";class T extends Error{constructor(...e){super(...e),this.name="M2Error",Object.setPrototypeOf(this,T.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,T)}}class f{constructor(e,t){if(this._groups=new Array,!Array.isArray(e))throw new T("DataCalc constructor expects an array of observations as first argument");for(let r=0;r<e.length;r++)if(e[r]===null||typeof e[r]!="object"||Array.isArray(e[r]))throw new T(`DataCalc constructor expects all elements to be objects (observations). Element at index ${r} is ${typeof e[r]}. Element: ${JSON.stringify(e[r])}`);this._observations=this.deepCopy(e);const o=new Set;for(const r of e)for(const s of Object.keys(r))o.add(s);for(const r of this._observations)for(const s of o)s in r||(r[s]=null);t?.groups&&(this._groups=Array.from(t.groups))}get groups(){return this._groups}get observations(){return this._observations}get rows(){return this._observations}pull(e){if(this._observations.length===0)return console.warn(`DataCalc.pull(): No observations available to pull variable "${e}" from. Returning null.`),null;this.verifyObservationsContainVariable(e);const t=this._observations.map(o=>o[e]);return t.length===1?t[0]:t}get length(){return this._observations.length}filter(e){if(this._groups.length>0)throw new T(`filter() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);return new f(this._observations.filter(e),{groups:this._groups})}groupBy(...e){return e.forEach(t=>{this.verifyObservationsContainVariable(t)}),new f(this._observations,{groups:e})}ungroup(){return new f(this._observations)}mutate(e){if(this._groups.length>0)throw new T(`mutate() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const t=this._observations.map(o=>{let r={...o};for(const[s,n]of Object.entries(e))r={...r,[s]:n(o)};return r});return new f(t,{groups:this._groups})}summarize(e){if(this._groups.length===0){const t={};for(const[o,r]of Object.entries(e))if(typeof r=="object"&&r!==null&&"summarizeFunction"in r){const s=r;t[o]=s.summarizeFunction(this,s.parameters,s.options)}else t[o]=r;return new f([t],{groups:this._groups})}return this.summarizeByGroups(e)}summarizeByGroups(e){const t=new Map;this._observations.forEach(r=>{const s=this._groups.map(i=>typeof r[i]=="object"?JSON.stringify(r[i]):r[i]).join("|");t.has(s)||t.set(s,[]);const n=t.get(s);n?n.push(r):t.set(s,[r])});const o=[];return t.forEach((r,s)=>{const n=s.split("|"),i=r[0],a={};this._groups.forEach((h,m)=>{const _=n[m],I=typeof i[h];if(I==="number")a[h]=Number(_);else if(I==="boolean")a[h]=_==="true";else if(_.startsWith("{")||_.startsWith("["))try{a[h]=JSON.parse(_)}catch{throw new T(`Failed to parse group value ${_} as JSON for group ${h}`)}else a[h]=_});const l=new f(r);for(const[h,m]of Object.entries(e))if(typeof m=="object"&&m!==null&&"summarizeFunction"in m){const _=m;a[h]=_.summarizeFunction(l,_.parameters,_.options)}else a[h]=m;o.push(a)}),new f(o,{groups:this._groups})}select(...e){const t=[],o=[];e.forEach(i=>{i.startsWith("-")?o.push(i.substring(1)):t.push(i)}),[...t.length>0?t:Object.keys(this._observations[0]||{}),...o].forEach(i=>{this.verifyObservationsContainVariable(i)});const s=new Set(o),n=this._observations.map(i=>{const a={};return t.length>0?t.forEach(l=>{s.has(l)||(a[l]=i[l])}):Object.keys(i).forEach(l=>{s.has(l)||(a[l]=i[l])}),a});return new f(n,{groups:this._groups})}arrange(...e){if(this._groups.length>0)throw new T(`arrange() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const t=[...this._observations].sort((o,r)=>{for(const s of e){let n=s,i=1;if(s.startsWith("-")&&(n=s.substring(1),i=-1),!(n in o)||!(n in r))throw new T(`arrange(): variable ${n} does not exist in all observations`);const a=o[n],l=r[n];if(typeof a!=typeof l)return i*(String(a)<String(l)?-1:1);if(a<l)return-1*i;if(a>l)return 1*i}return 0});return new f(t,{groups:this._groups})}distinct(){const e=new Set,t=this._observations.filter(o=>{const r=JSON.stringify(this.normalizeForComparison(o));return e.has(r)?!1:(e.add(r),!0)});return new f(t,{groups:this._groups})}rename(e){if(this._observations.length===0)throw new T("Cannot rename variables on an empty dataset");Object.values(e).forEach(o=>{this.verifyObservationsContainVariable(o)});const t=this._observations.map(o=>{const r={};for(const[s,n]of Object.entries(o)){const i=Object.entries(e).find(([,a])=>a===s)?.[0];i?r[i]=n:Object.values(e).includes(s)||(r[s]=n)}return r});return new f(t,{groups:this._groups})}innerJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("innerJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(s=>{this.verifyObservationsContainVariable(s),e.verifyObservationsContainVariable(s)});const o=new Map;e.observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.push(s),o.set(n,i)});const r=[];return this._observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.length>0&&i.forEach(a=>{const l={...s};Object.entries(a).forEach(([h,m])=>{t.includes(h)||(l[h]=m)}),r.push(l)})}),new f(r)}leftJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("leftJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(s=>{this.verifyObservationsContainVariable(s),e.verifyObservationsContainVariable(s)});const o=new Map;e.observations.forEach(s=>{if(this.hasNullJoinKeys(s,t))return;const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.push(s),o.set(n,i)});const r=[];return this._observations.forEach(s=>{if(this.hasNullJoinKeys(s,t)){r.push({...s});return}const n=t.map(a=>JSON.stringify(this.normalizeForComparison(s[a]))).join("|"),i=o.get(n)||[];i.length>0?i.forEach(a=>{const l={...s};Object.entries(a).forEach(([h,m])=>{t.includes(h)||(l[h]=m)}),r.push(l)}):r.push({...s})}),new f(r)}rightJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("rightJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(n=>{this.verifyObservationsContainVariable(n),e.verifyObservationsContainVariable(n)});const o=new Map;e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.push(n),o.set(i,a)});const r=[],s=new Set;return this._observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.length>0&&(a.forEach(l=>{const h={...n};Object.entries(l).forEach(([m,_])=>{t.includes(m)||(h[m]=_)}),r.push(h)}),s.add(i))}),e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(a=>JSON.stringify(this.normalizeForComparison(n[a]))).join("|");s.has(i)||(r.push({...n}),s.add(i))}),new f(r)}fullJoin(e,t){if(this._groups.length>0||e._groups.length>0)throw new T("fullJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");t.forEach(n=>{this.verifyObservationsContainVariable(n),e.verifyObservationsContainVariable(n)});const o=new Map;e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t))return;const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.push(n),o.set(i,a)});const r=[],s=new Set;return this._observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(l=>JSON.stringify(this.normalizeForComparison(n[l]))).join("|"),a=o.get(i)||[];a.length>0?(a.forEach(l=>{const h={...n};Object.entries(l).forEach(([m,_])=>{t.includes(m)||(h[m]=_)}),r.push(h)}),s.add(i)):r.push({...n})}),e.observations.forEach(n=>{if(this.hasNullJoinKeys(n,t)){r.push({...n});return}const i=t.map(a=>JSON.stringify(this.normalizeForComparison(n[a]))).join("|");s.has(i)||(r.push({...n}),s.add(i))}),new f(r)}slice(e,t){if(this._groups.length>0)throw new T("slice() cannot be used on grouped data. Ungroup the data first using ungroup().");let o;if(e>=this._observations.length)return new f([],{groups:this._groups});if(t===void 0){const r=e<0?this._observations.length+e:e;o=[this._observations[r]]}else o=this._observations.slice(e,t);return new f(o,{groups:this._groups})}bindRows(e){if(this._observations.length>0&&e.observations.length>0){const t=new Set(Object.keys(this._observations[0])),o=new Set(Object.keys(e.observations[0]));[...t].filter(s=>o.has(s)).forEach(s=>{const n=this.getVariableType(s),i=e.getVariableType(s);n!==i&&console.warn(`Warning: bindRows() is combining datasets with different data types for variable '${s}'. Left dataset has type '${n}' and right dataset has type '${i}'.`)})}return new f([...this._observations,...e.observations])}getVariableType(e){if(this._observations.length===0)return"unknown";const t={};this._observations.forEach(s=>{if(e in s){const n=s[e],i=n===null?"null":Array.isArray(n)?"array":typeof n;t[i]=(t[i]||0)+1}});let o=0,r="unknown";for(const[s,n]of Object.entries(t))n>o&&(o=n,r=s);return r}verifyObservationsContainVariable(e){if(!this._observations.every(t=>e in t))throw new T(`Variable ${e} does not exist for each item (row) in the data array.`)}variableExists(e){return this._observations.some(t=>e in t)}isNonMissingNumeric(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}isMissingNumeric(e){return typeof e=="number"&&(isNaN(e)||!isFinite(e))||e===null||typeof e>"u"}normalizeForComparison(e){return e===null||typeof e!="object"?e:Array.isArray(e)?e.map(t=>this.normalizeForComparison(t)):Object.keys(e).sort().reduce((t,o)=>(t[o]=this.normalizeForComparison(e[o]),t),{})}deepCopy(e,t=new WeakMap){if(e===null||typeof e!="object")return e;if(t.has(e))return t.get(e);const o=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));t.set(e,o);const r=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of r){const n=Object.getOwnPropertyDescriptor(e,s);n&&Object.defineProperty(o,s,{...n,value:this.deepCopy(e[s],t)})}return o}hasNullJoinKeys(e,t){return t.some(o=>e[o]===null||e[o]===void 0)}}console.log("\u26AA @m2c2kit/data-calc version 0.8.5 (d289d12c)");class be extends de{constructor(){const e={fixation_duration_ms:{default:500,description:"How long fixation scene is shown, milliseconds.",type:"number"},shape_colors:{type:"array",description:"Array of colors for shapes.",items:{type:"object",properties:{colorName:{type:"string",description:"Human-friendly name of color."},rgbaColor:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}}}},default:[{colorName:"black",rgbaColor:[0,0,0,1]},{colorName:"green",rgbaColor:[0,158,115,1]},{colorName:"yellow",rgbaColor:[240,228,66,1]},{colorName:"blue",rgbaColor:[0,114,178,1]},{colorName:"orange",rgbaColor:[213,94,0,1]},{colorName:"pink",rgbaColor:[204,121,167,1]}]},number_of_shapes_shown:{default:3,description:"How many shapes to show on the grid at one time.",type:"integer"},number_of_shapes_changing_color:{default:2,description:"If a different color trial, how many shapes should change color (minimum is 2, because changes are swaps with other shapes).",type:"integer"},shapes_presented_duration_ms:{default:2e3,description:"How long the shapes are shown, milliseconds.",type:"number"},shapes_removed_duration_ms:{default:1e3,description:"How long to show a blank square after shapes are removed, milliseconds.",type:"number"},cells_per_side:{default:3,description:"How many cell positions for each side of the square grid (e.g., 3 is a 3x3 grid; 4 is a 4x4 grid).",type:"integer"},number_of_different_colors_trials:{default:6,type:"integer",description:"Number of trials where the shapes have different colors."},number_of_trials:{default:12,description:"How many trials to run.",type:"integer"},show_trials_complete_scene:{default:!0,type:"boolean",description:"After the final trial, should a completion scene be shown? Otherwise, the game will immediately end."},instruction_type:{default:"long",description:"Type of instructions to show, 'short' or 'long'.",type:"string",enum:["short","long"]},instructions:{default:null,type:["object","null"],description:"When non-null, an InstructionsOptions object that will completely override the built-in instructions."},show_quit_button:{type:"boolean",default:!1,description:"Should the activity quit button be shown?"},show_fps:{type:"boolean",default:!1,description:"Should the FPS be shown?"},show_locale_picker:{type:"boolean",default:!1,description:"Should the icon that allows the participant to switch the locale be shown?"},seed:{type:["string","null"],default:null,description:"Optional seed for the seeded pseudo-random number generator. When null, the default Math.random() is used."},scoring:{type:"boolean",default:!1,description:"Should scoring data be generated? Default is false."}},t={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the trial. Null if trial was skipped."},trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the trial (when user presses 'Same' or 'Different'). Null if trial was skipped."},trial_index:{type:["integer","null"],description:"Index of the trial within this assessment, 0-based."},present_shapes:{description:"Configuration of shapes shown to the user in the presentation phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_shapes:{description:"Configuration of shapes shown to the user in the response phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_time_duration_ms:{type:["number","null"],description:"Milliseconds from when the response configuration of shapes is shown until the user taps a response. Null if trial was skipped."},user_response:{type:["string","null"],enum:["same","different"],description:"User's response to whether the shapes are same colors or different."},user_response_correct:{type:["boolean","null"],description:"Was the user's response correct?"},quit_button_pressed:{type:"boolean",description:"Was the quit button pressed?"}},o={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},first_trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the first trial. Null if no trials were completed."},last_trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the last trial. Null if no trials were completed."},n_trials:{type:"integer",description:"Number of trials completed."},flag_trials_match_expected:{type:"integer",description:"Does the number of completed and expected trials match? 1 = true, 0 = false."},n_trials_correct:{type:"integer",description:"Number of correct trials."},n_trials_incorrect:{type:"integer",description:"Number of incorrect trials."},participant_score:{type:["number","null"],description:"Participant-facing score, calculated as (number of correct trials / number of trials attempted) * 100. This is a simple metric to provide feedback to the participant. Null if no trials attempted."}},s={name:"Color Shapes",id:"color-shapes",publishUuid:"394cb010-2ccf-4a87-9d23-cda7fb07a960",version:"0.8.32 (d289d12c)",moduleMetadata:{name:"@m2c2kit/assessment-color-shapes",version:"0.8.32",dependencies:{"@m2c2kit/addons":"0.3.33","@m2c2kit/core":"0.3.34"}},translation:{configuration:{baseLocale:"en-US"},"en-US":{localeName:"English",INSTRUCTIONS_TITLE:"Color Shapes",SHORT_INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear. When the shapes reappear, answer whether they have the SAME or DIFFERENT colors as they had before",INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear.",INSTRUCTIONS_TEXT_PAGE_2:"Next you will see the same shapes reappear.",INSTRUCTIONS_TEXT_PAGE_3:"Answer whether the shapes have the SAME or DIFFERENT colors as they had before.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Next",BACK_BUTTON_TEXT:"Back",GET_READY_COUNTDOWN_TEXT:"GET READY!",SAME_BUTTON_TEXT:"Same",DIFFERENT_BUTTON_TEXT:"Different",TRIALS_COMPLETE_SCENE_TEXT:"This activity is complete.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"es-MX":{localeName:"Espa\xF1ol",INSTRUCTIONS_TITLE:"Formas de Color",INSTRUCTIONS_TEXT_PAGE_1:"Intenta recordar el color de las 3 formas, porque pronto desaparecer\xE1n.",INSTRUCTIONS_TEXT_PAGE_2:"Luego ver\xE1s reaparecer las mismas formas.",INSTRUCTIONS_TEXT_PAGE_3:"Responde si las formas tienen el MISMO o DIFERENTE color que antes.",START_BUTTON_TEXT:"COMENZAR",NEXT_BUTTON_TEXT:"Siguiente",BACK_BUTTON_TEXT:"Atr\xE1s",GET_READY_COUNTDOWN_TEXT:"PREP\xC1RESE",SAME_BUTTON_TEXT:"Mismo",DIFFERENT_BUTTON_TEXT:"Diferente",TRIALS_COMPLETE_SCENE_TEXT:"Esta actividad est\xE1 completa.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"de-DE":{localeName:"Deutsch",INSTRUCTIONS_TITLE:"Farb-Formen",INSTRUCTIONS_TEXT_PAGE_1:"Oben und unten sehen Sie Symbolpaare.",INSTRUCTIONS_TEXT_PAGE_2:"Ihre Aufgabe wird es sein, auf dasjenige untere Paar zu tippen, welches mit einem der obigen Paare exakt \xFCbereinstimmt.",INSTRUCTIONS_TEXT_PAGE_3:"Versuchen Sie bitte, so schnell und korrekt wie m\xF6glich zu sein.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Weiter",BACK_BUTTON_TEXT:"Vorherige",GET_READY_COUNTDOWN_TEXT:"BEREIT MACHEN",SAME_BUTTON_TEXT:"Gleich",DIFFERENT_BUTTON_TEXT:"Unterschiedlich",TRIALS_COMPLETE_SCENE_TEXT:"Die Aufgabe ist beendet.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"}},shortDescription:"Color Shapes is a visual array change detection task, measuring intra-item feature binding, where participants determine if shapes change color across two sequential presentations of shape stimuli.",longDescription:'Color Shapes is a change detection paradigm used to measure visual short-term memory binding (Parra et al., 2009). Participants are asked to memorize the shapes and colors of three different polygons for 3 seconds. The three polygons are then removed from the screen and re-displayed at different locations, either having the same or different colors. Participants are then asked to decide whether the combination of colors and shapes are the "Same" or "Different" between the study and test phases.',showFps:e.show_fps.default,width:400,height:800,trialSchema:t,scoringSchema:o,parameters:e,fonts:[{fontName:"roboto",url:"fonts/roboto/Roboto-Regular.ttf"}],images:[{imageName:"instructions-1",height:256,width:256,url:"images/cs-instructions-1.png"},{imageName:"instructions-2",height:256,width:256,url:"images/cs-instructions-2.png"},{imageName:"instructions-3",height:350,width:300,url:"images/cs-instructions-3.png",localize:!0},{imageName:"circle-x",height:32,width:32,url:"images/circle-x.svg"}]};super(s)}async initialize(){await super.initialize();const e=this,t=e.getParameter("seed");typeof t=="string"&&v.setSeed(t);const o=96,r=350,s=e.getParameter("number_of_shapes_shown"),n=this.makeShapes(o);if(e.getParameter("show_quit_button")){const u=new me({imageName:"circle-x",position:{x:380,y:20},isUserInteractionEnabled:!0});e.addFreeNode(u),u.onTapDown(d=>{e.removeAllFreeNodes(),d.handled=!0;const g=new B;if(e.addScene(g),e.presentScene(g),e.addTrialData("quit_button_pressed",!0),e.trialComplete(),e.getParameter("scoring")){const C=e.calculateScores([],{numberOfTrials:e.getParameter("number_of_trials")});e.addScoringData(C),e.scoringComplete()}e.cancel()})}let i;e.getParameter("show_locale_picker")&&(i=new _e,e.addFreeNode(i));let a;const l=e.getParameter("instructions");if(l)a=Z.create(l);else switch(e.getParameter("instruction_type")){case"short":{a=Z.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"SHORT_INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:S.Green,nextSceneTransition:$.none()}]});break}case"long":{a=Z.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_2",imageName:"instructions-2",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_3",imageName:"instructions-3",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:S.Green,backButtonText:"BACK_BUTTON_TEXT"}]});break}default:throw new ne("invalid value for instruction_type")}a[0].onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp)}),e.addScenes(a);const h=new Te({milliseconds:3e3,text:"GET_READY_COUNTDOWN_TEXT",zeroDwellMilliseconds:1e3,transition:$.none()});e.addScene(h);const m=e.getParameter("cells_per_side"),_=e.getParameter("cells_per_side"),I=e.getParameter("number_of_trials"),j=e.getParameter("shape_colors"),X=[],W=e.getParameter("cells_per_side"),Q=W,ae=e.getParameter("number_of_different_colors_trials"),le=v.fromRangeWithoutReplacement(ae,0,I-1);for(let u=0;u<I;u++){const d=new Array,g=new Array,C=v.fromRangeWithoutReplacement(s,0,n.length-1),P=v.fromRangeWithoutReplacement(s,0,j.length-1),D=p=>!!(p.map(c=>c.row===0&&c.column===0).some(c=>c===!0)&&p.map(c=>c.row===1&&c.column===1).some(c=>c===!0)&&p.map(c=>c.row===2&&c.column===2).some(c=>c===!0)||p.map(c=>c.row===2&&c.column===0).some(c=>c===!0)&&p.map(c=>c.row===1&&c.column===1).some(c=>c===!0)&&p.map(c=>c.row===0&&c.column===2).some(c=>c===!0)),b=p=>{const c=new Set(p.map(k=>k.row)).size,R=new Set(p.map(k=>k.column)).size;return!(c!==1&&R!==1)};let K=!1,V;do V=v.fromGridWithoutReplacement(s,W,Q),!b(V)&&!D(V)?K=!0:K=!1;while(!K);for(let p=0;p<s;p++){const c={shape:n[C[p]],shapeIndex:C[p],color:j[P[p]].rgbaColor,colorName:j[P[p]].colorName,location:V[p]};d.push(c)}let q=!1,G;do G=v.fromGridWithoutReplacement(s,W,Q),!b(G)&&!D(G)?q=!0:q=!1;while(!q);for(let p=0;p<s;p++){const c={shape:d[p].shape,shapeIndex:C[p],color:d[p].color,colorName:j[P[p]].colorName,location:G[p]};g.push(c)}let se=0;if(le.includes(u)){const p=e.getParameter("number_of_shapes_changing_color");if(p>s)throw new ne(`number_of_shapes_changing_color is ${p}, but it must be less than or equal to number_of_shapes_shown (which is ${s}).`);const R=v.fromRangeWithoutReplacement(p,0,s-1).map(O=>g[O]);se=R.length;const k=R[0].color;for(let O=0;O<p;O++){const re=R[O];O+1<p?re.color=R[O+1].color:re.color=k}}X.push({presentShapes:d,responseShapes:g,numberOfShapesWithDifferentColors:se})}const U=new B;e.addScene(U);const ee=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});U.addChild(ee);const ce=new oe({text:"+",fontSize:32,fontColor:S.Black,localize:!1});ee.addChild(ce),U.onAppear(()=>{e.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp),e.addTrialData("trial_begin_iso8601_timestamp",new Date().toISOString()),U.run(y.sequence([y.wait({duration:e.getParameter("fixation_duration_ms")}),y.custom({callback:()=>{e.presentScene(x)}})]))});const x=new B;e.addScene(x);const pe=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});x.addChild(pe);const F=new ie({rows:m,columns:_,size:{width:r,height:r},position:{x:200,y:300},backgroundColor:S.Transparent,gridLineColor:S.Transparent});x.addChild(F),x.onAppear(()=>{const u=X[e.trialIndex];for(let d=0;d<u.presentShapes.length;d++){const g=u.presentShapes[d].shape;g.fillColor=u.presentShapes[d].color,g.position={x:0,y:0},F.addAtCell(g,u.presentShapes[d].location.row,u.presentShapes[d].location.column)}x.run(y.sequence([y.wait({duration:e.getParameter("shapes_presented_duration_ms")}),y.custom({callback:()=>{F.removeAllGridChildren()}}),y.wait({duration:e.getParameter("shapes_removed_duration_ms")}),y.custom({callback:()=>{F.removeAllGridChildren(),e.presentScene(N)}})]))});const N=new B;e.addScene(N);const he=new w({rect:{size:{width:r,height:r}},fillColor:S.Transparent,strokeColor:S.Gray,lineWidth:4,position:{x:200,y:300}});N.addChild(he);const J=new ie({rows:m,columns:_,size:{width:r,height:r},position:{x:200,y:300},backgroundColor:S.Transparent,gridLineColor:S.Transparent});N.addChild(J),N.onAppear(()=>{const u=X[e.trialIndex];for(let d=0;d<u.responseShapes.length;d++){const g=u.responseShapes[d].shape;g.fillColor=u.responseShapes[d].color,g.position={x:0,y:0},J.addAtCell(g,u.responseShapes[d].location.row,u.responseShapes[d].location.column)}M.isUserInteractionEnabled=!0,z.isUserInteractionEnabled=!0,H.startNew("rt")});const M=new Y({text:"SAME_BUTTON_TEXT",position:{x:100,y:700},size:{width:150,height:50}});N.addChild(M),M.onTapDown(()=>{M.isUserInteractionEnabled=!1,te(!1)});const z=new Y({text:"DIFFERENT_BUTTON_TEXT",position:{x:300,y:700},size:{width:150,height:50}});N.addChild(z),z.onTapDown(()=>{z.isUserInteractionEnabled=!1,te(!0)});const te=u=>{const d=H.elapsed("rt");H.remove("rt"),J.removeAllGridChildren(),e.addTrialData("trial_end_iso8601_timestamp",new Date().toISOString());const g=X[e.trialIndex];e.addTrialData("response_time_duration_ms",d),e.addTrialData("user_response",u?"different":"same");const C=g.numberOfShapesWithDifferentColors===0&&!u||g.numberOfShapesWithDifferentColors>0&&u;e.addTrialData("user_response_correct",C);const P=g.presentShapes.map(b=>({shape_index:b.shapeIndex,color_name:b.colorName,rgba_color:b.color,location:b.location}));e.addTrialData("present_shapes",P),e.addTrialData("quit_button_pressed",!1);const D=g.responseShapes.map(b=>({shape_index:b.shapeIndex,color_name:b.colorName,rgba_color:b.color,location:b.location}));if(e.addTrialData("response_shapes",D),e.addTrialData("trial_index",e.trialIndex),e.trialComplete(),e.trialIndex<I)e.presentScene(U);else{if(e.getParameter("scoring")){const b=e.calculateScores(e.data.trials,{numberOfTrials:e.getParameter("number_of_trials")});e.addScoringData(b),e.scoringComplete()}e.getParameter("show_trials_complete_scene")?e.presentScene(A,$.slide({direction:ge.Left,duration:500,easing:fe.sinusoidalInOut})):e.end()}},A=new B;e.addScene(A);const ue=new oe({text:"TRIALS_COMPLETE_SCENE_TEXT",position:{x:200,y:400}});A.addChild(ue);const L=new Y({text:"TRIALS_COMPLETE_SCENE_BUTTON_TEXT",position:{x:200,y:650}});L.isUserInteractionEnabled=!0,L.onTapDown(()=>{L.isUserInteractionEnabled=!1,A.removeAllChildren(),e.end()}),A.addChild(L),A.onSetup(()=>{e.removeAllFreeNodes()})}calculateScores(e,t){const o=new f(e);return o.summarize({activity_begin_iso8601_timestamp:this.beginIso8601Timestamp,first_trial_begin_iso8601_timestamp:o.arrange("trial_begin_iso8601_timestamp").slice(0).pull("trial_begin_iso8601_timestamp"),last_trial_end_iso8601_timestamp:o.arrange("-trial_end_iso8601_timestamp").slice(0).pull("trial_end_iso8601_timestamp"),n_trials:o.length,flag_trials_match_expected:o.length===t.numberOfTrials?1:0,n_trials_correct:o.filter(s=>s.user_response_correct===!0).length,n_trials_incorrect:o.filter(s=>s.user_response_correct===!1).length}).mutate({participant_score:s=>s.n_trials>0?s.n_trials_correct/s.n_trials*100:null}).observations}makeShapes(e){const t=new w({path:{pathString:E[0],height:e},lineWidth:0}),o=new w({path:{pathString:E[1],height:e},lineWidth:0}),r=new w({path:{pathString:E[2],height:e*.8},lineWidth:0}),s=new w({path:{pathString:E[3],height:e},lineWidth:0}),n=new w({path:{pathString:E[4],height:e*.8},lineWidth:0}),i=new w({path:{pathString:E[5],height:e},lineWidth:0}),a=new w({path:{pathString:E[6],height:e},lineWidth:0}),l=new w({path:{pathString:E[7],height:e},lineWidth:0});return[t,o,r,s,n,i,a,l]}}const E=["M0 89.94v-2L131.95 0h2v88.7c2.34 1.6 4.47 3.11 6.65 4.55 42.77 28.22 85.54 56.42 128.3 84.63v2c-44.65 29.65-89.3 59.29-133.95 88.94h-1v-90.84C89.44 148.72 44.72 119.33 0 89.94Z","M162 188c-.33 27-.67 54-1 81-26.87-26.18-53.74-52.35-80-77.94V269H0C0 180.83 0 92.67.04 4.5.04 3 .67 1.5 1 0c24.64 29.1 49.15 58.31 73.96 87.26 28.88 33.7 58.01 67.17 87.04 100.74Z","M3 148.86V61.12C41.76 40.75 80.52 20.37 119.28 0h2.91c21.32 20.7 42.64 41.4 63.96 62.11v89.71c-38.44 20.04-76.88 40.09-115.31 60.13h-2.91L3.01 148.86Z","M134 0h2c7.26 22.31 14.38 44.67 21.86 66.9 3.91 11.61 5.47 29.91 13.25 33.27C203 113.94 236.86 123.13 270 134v1L136 269h-1c-11.04-33.58-22.08-67.16-33.21-101.03C67.87 156.98 33.93 145.99 0 135v-1L134 0Z","M107 0h1l108 108v1c-26.67 35.33-53.33 70.66-80 106h-1c-8.82-35.03-17.64-70.07-27-107.28C98.62 145.01 89.81 180 81.01 215h-1C53.33 179.66 26.67 144.33 0 109v-2L107 0Z","M0 1C2.17.67 4.33.05 6.5.04 58.33-.01 110.17 0 162 0v270H2c26.2-22.17 52.41-44.33 78.86-66.71V67.4c-3.85-3.22-7.35-6.2-10.9-9.11C46.64 39.18 23.32 20.09 0 1Z","M95 268.99h-1C62.66 238.66 31.33 208.33 0 178V88C26.67 58.67 53.33 29.33 80 0h1c0 29.45 0 58.89-.01 88.38 35.99 29.57 72 59.09 108.01 88.61v1l-94 91Z","M13 0h67l135 135v1L81 270c-27-.33-54-.67-81-1 11.73-12.51 23.61-24.87 35.16-37.54 33.14-36.35 66.14-72.82 100.23-110.38C94.4 80.52 53.7 40.26 13 0Z"];export{be as ColorShapes};
|
|
1
|
+
import{Game as Me,RandomDraws as L,Sprite as Fe,Scene as J,M2Error as ye,WebColors as I,Transition as ue,Shape as R,Label as Te,Action as x,Timer as pe,Easings as Be,TransitionDirection as ke}from"@m2c2kit/core";import{LocalePicker as xe,Instructions as de,CountdownScene as Ue,Grid as we,Button as _e}from"@m2c2kit/addons";class _ extends Error{constructor(...t){super(...t),this.name="M2Error",Object.setPrototypeOf(this,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,_)}}const me=new Map;let Pe=0;function ie(u){return me.get(u)}function q(u){me.delete(u)}function ve(){const u=(r=>{if(!r)return;let n=r;for(const s of u.ops){const i=n[s.name];if(typeof i!="function")throw new _(`chain: method ${s.name} does not exist on DataCalc`);const e=i.apply(n,s.args);if(e instanceof b){n=e;continue}return e}});u.ops=[];const t=(r,n)=>(u.ops.push({name:r,args:n}),u);return u.arrange=(...r)=>t("arrange",r),u.slice=(r,n)=>t("slice",[r,n]),u.pull=r=>t("pull",[r]),u.filter=r=>t("filter",[r]),u.mutate=r=>t("mutate",[r]),u.select=(...r)=>t("select",r),u.groupBy=(...r)=>t("groupBy",r),u.ungroup=()=>t("ungroup",[]),u.rename=r=>t("rename",[r]),u.distinct=()=>t("distinct",[]),Object.defineProperty(u,"length",{configurable:!0,get:function(){try{const r=`c${++Pe}`;return me.set(r,(u.ops||[]).map(n=>({...n}))),`__CHAIN_EXPR__[${r}]`}catch{return}}}),u}function Se(...u){return ve().arrange(...u)}function h(u){return ve().filter(u)}class b{constructor(t,r){if(this._groups=new Array,this._warnings=!1,!Array.isArray(t))throw new _("DataCalc constructor expects an array of observations as first argument");for(let s=0;s<t.length;s++)if(t[s]===null||typeof t[s]!="object"||Array.isArray(t[s]))throw new _(`DataCalc constructor expects all elements to be objects (observations). Element at index ${s} is ${typeof t[s]}. Element: ${JSON.stringify(t[s])}`);this._observations=this.deepCopy(t);const n=new Set;for(const s of t)for(const i of Object.keys(s))n.add(i);for(const s of this._observations)for(const i of n)i in s||(s[i]=null);r?.groups&&(this._groups=Array.from(r.groups)),r?.warnings&&(this._warnings=!0)}get groups(){return this._groups}get observations(){return this._observations}get rows(){return this._observations}pull(t){if(this._observations.length===0)return this._warnings&&console.warn(`DataCalc.pull(): No observations available to pull variable "${t}" from. Returning null.`),null;this.verifyObservationsContainVariable(t);const r=this._observations.map(n=>n[t]);return r.length===1?r[0]:r}get length(){return this._observations.length}filter(t){if(this._groups.length>0)throw new _(`filter() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);return new b(this._observations.filter(t),{groups:this._groups,warnings:this._warnings})}groupBy(...t){return t.forEach(r=>{this.verifyObservationsContainVariable(r);for(let n=0;n<this._observations.length;n++){const s=this._observations[n][r];if(s===null)continue;const i=typeof s;if(i!=="number"&&i!=="string"&&i!=="boolean")throw new _(`groupBy(): variable "${r}" contains non-primitive value at index ${n} (type=${i}). Only number, string, boolean, or null are allowed for grouping.`)}}),new b(this._observations,{groups:t})}ungroup(){return new b(this._observations)}mutate(t){if(this._groups.length>0)throw new _(`mutate() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const r=this._observations.map(n=>{let s={...n};for(const[i,e]of Object.entries(t))s={...s,[i]:e(n)};return s});return new b(r,{groups:this._groups,warnings:this._warnings})}summarize(t){if(this._groups.length===0){const r={};for(const[n,s]of Object.entries(t))if(typeof s=="object"&&s!==null&&"summarizeFunction"in s){const i=s;r[n]=i.summarizeFunction(this,i.parameters,i.options)}else if(typeof s=="function")try{const i=s(this);if(typeof i=="function")throw new _(`summarize(): lazy callback for ${n} returned a function; expected a value or array of values.`);if(i instanceof b)throw new _(`summarize(): lazy callback for ${n} returned a DataCalc; expected a value or array of values.`);r[n]=i}catch(i){throw new _(`summarize(): lazy callback for ${n} threw an error: ${i&&i.message?i.message:String(i)}`)}else{if(typeof s=="string"){const i=/__CHAIN_EXPR__\[(.*?)\]/g,e=Array.from(s.matchAll(i));if(e.length>0){let a=0;for(const l of e){const p=l[1];let d=ie(p);if(!d)try{d=JSON.parse(decodeURIComponent(p))}catch{throw new _(`summarize(): failed to parse chain payload for ${n}`)}let m=this,g;if(!d)throw new _(`summarize(): empty chain ops for ${n}`);for(const v of d){const C=m[v.name];if(typeof C!="function")throw new _(`summarize(): chain method ${v.name} does not exist on DataCalc`);const N=C.apply(m,v.args);if(N instanceof b){m=N;continue}if(Array.isArray(N)){g=N.length;break}if(typeof N=="boolean"){g=N?1:0;break}g=typeof N=="number"?N:Number(N);break}g===void 0&&(g=m instanceof b?m.length:0),a+=g}let o=s;for(const l of e)o=o.replace(l[0],"");const c=Number(o);Number.isNaN(c)||(a+=c),r[n]=a;for(const l of e)q(l[1]);continue}}r[n]=s}return new b([r],{groups:this._groups,warnings:this._warnings})}return this.summarizeByGroups(t)}summarizeByGroups(t){const r=new Map;this._observations.forEach(s=>{const i=this._groups.map(a=>String(s[a])).join("|");r.has(i)||r.set(i,[]);const e=r.get(i);e?e.push(s):r.set(i,[s])});const n=[];return r.forEach((s,i)=>{const e=i.split("|"),a=s[0],o={};this._groups.forEach((l,p)=>{const d=e[p];if(a[l]===null)o[l]=null;else{const m=typeof a[l];m==="number"?o[l]=Number(d):m==="boolean"?o[l]=d==="true":o[l]=d}});const c=new b(s);for(const[l,p]of Object.entries(t))if(typeof p=="object"&&p!==null&&"summarizeFunction"in p){const d=p;o[l]=d.summarizeFunction(c,d.parameters,d.options)}else if(typeof p=="function")try{const d=p(c);if(typeof d=="function")throw new _(`summarize(): lazy callback for ${l} returned a function; expected a value or array of values.`);if(d instanceof b)throw new _(`summarize(): lazy callback for ${l} returned a DataCalc; expected a value or array of values.`);o[l]=d}catch(d){throw new _(`summarize(): lazy callback for ${l} threw an error: ${d&&d.message?d.message:String(d)}`)}else{if(typeof p=="string"){const d=/__CHAIN_EXPR__\[(.*?)\]/g,m=Array.from(p.matchAll(d));if(m.length>0){let g=0;for(const N of m){const K=N[1];let V=ie(K);if(!V)try{V=JSON.parse(decodeURIComponent(K))}catch{throw new _(`summarize(): failed to parse chain payload for ${l}`)}let O=c,B;if(!V)throw new _(`summarize(): empty chain ops for ${l}`);for(const D of V){const k=O[D.name];if(typeof k!="function")throw new _(`summarize(): chain method ${D.name} does not exist on DataCalc`);const A=k.apply(O,D.args);if(A instanceof b){O=A;continue}if(Array.isArray(A)){B=A.length;break}if(typeof A=="boolean"){B=A?1:0;break}B=typeof A=="number"?A:Number(A);break}B===void 0&&(B=O instanceof b?O.length:0),g+=B}let v=p;for(const N of m)v=v.replace(N[0],"");const C=Number(v);Number.isNaN(C)||(g+=C),o[l]=g;for(const N of m)q(N[1]);continue}}o[l]=p}n.push(o)}),new b(n,{groups:this._groups,warnings:this._warnings})}select(...t){const r=[],n=[];t.forEach(a=>{a.startsWith("-")?n.push(a.substring(1)):r.push(a)}),[...r.length>0?r:Object.keys(this._observations[0]||{}),...n].forEach(a=>{this.verifyObservationsContainVariable(a)});const i=new Set(n),e=this._observations.map(a=>{const o={};return r.length>0?r.forEach(c=>{i.has(c)||(o[c]=a[c])}):Object.keys(a).forEach(c=>{i.has(c)||(o[c]=a[c])}),o});return new b(e,{groups:this._groups,warnings:this._warnings})}arrange(...t){if(this._groups.length>0)throw new _(`arrange() cannot be used on grouped data. The data are currently grouped by ${this._groups.join(", ")}. Ungroup the data first using ungroup().`);const r=[...this._observations].sort((n,s)=>{for(const i of t){let e=i,a=1;if(i.startsWith("-")&&(e=i.substring(1),a=-1),!(e in n)||!(e in s))throw new _(`arrange(): variable ${e} does not exist in all observations`);const o=n[e],c=s[e];if(typeof o!=typeof c)return a*(String(o)<String(c)?-1:1);if(o<c)return-1*a;if(o>c)return 1*a}return 0});return new b(r,{groups:this._groups,warnings:this._warnings})}distinct(){const t=new Set,r=this._observations.filter(n=>{const s=JSON.stringify(this.normalizeForComparison(n));return t.has(s)?!1:(t.add(s),!0)});return new b(r,{groups:this._groups,warnings:this._warnings})}rename(t){if(this._observations.length===0)throw new _("Cannot rename variables on an empty dataset");if(Object.values(t).forEach(n=>{this.verifyObservationsContainVariable(n)}),this._observations.length>0){const n=new Set(Object.keys(this._observations[0])),s=new Set(Object.values(t)),i=Object.keys(t).filter(e=>n.has(e)&&!s.has(e));i.length>0&&this._warnings&&console.warn(`DataCalc.rename(): renaming will overwrite existing variables: ${i.join(", ")}`)}const r=this._observations.map(n=>{const s={},i=new Set(Object.keys(t));for(const[e,a]of Object.entries(n)){const o=Object.entries(t).find(([,c])=>c===e)?.[0];o?s[o]=a:i.has(e)||(s[e]=a)}return s});return new b(r,{groups:this._groups,warnings:this._warnings})}innerJoin(t,r){if(this._groups.length>0||t._groups.length>0)throw new _("innerJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");r.forEach(i=>{this.verifyObservationsContainVariable(i),t.verifyObservationsContainVariable(i)});const n=new Map;t.observations.forEach(i=>{if(this.hasNullJoinKeys(i,r))return;const e=r.map(o=>JSON.stringify(this.normalizeForComparison(i[o]))).join("|"),a=n.get(e)||[];a.push(i),n.set(e,a)});const s=[];return this._observations.forEach(i=>{if(this.hasNullJoinKeys(i,r))return;const e=r.map(o=>JSON.stringify(this.normalizeForComparison(i[o]))).join("|"),a=n.get(e)||[];a.length>0&&a.forEach(o=>{const c={...i};Object.entries(o).forEach(([l,p])=>{r.includes(l)||(c[l]=p)}),s.push(c)})}),new b(s)}leftJoin(t,r){if(this._groups.length>0||t._groups.length>0)throw new _("leftJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");r.forEach(i=>{this.verifyObservationsContainVariable(i),t.verifyObservationsContainVariable(i)});const n=new Map;t.observations.forEach(i=>{if(this.hasNullJoinKeys(i,r))return;const e=r.map(o=>JSON.stringify(this.normalizeForComparison(i[o]))).join("|"),a=n.get(e)||[];a.push(i),n.set(e,a)});const s=[];return this._observations.forEach(i=>{if(this.hasNullJoinKeys(i,r)){s.push({...i});return}const e=r.map(o=>JSON.stringify(this.normalizeForComparison(i[o]))).join("|"),a=n.get(e)||[];a.length>0?a.forEach(o=>{const c={...i};Object.entries(o).forEach(([l,p])=>{r.includes(l)||(c[l]=p)}),s.push(c)}):s.push({...i})}),new b(s)}rightJoin(t,r){if(this._groups.length>0||t._groups.length>0)throw new _("rightJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");r.forEach(e=>{this.verifyObservationsContainVariable(e),t.verifyObservationsContainVariable(e)});const n=new Map;t.observations.forEach(e=>{if(this.hasNullJoinKeys(e,r))return;const a=r.map(c=>JSON.stringify(this.normalizeForComparison(e[c]))).join("|"),o=n.get(a)||[];o.push(e),n.set(a,o)});const s=[],i=new Set;return this._observations.forEach(e=>{if(this.hasNullJoinKeys(e,r))return;const a=r.map(c=>JSON.stringify(this.normalizeForComparison(e[c]))).join("|"),o=n.get(a)||[];o.length>0&&(o.forEach(c=>{const l={...e};Object.entries(c).forEach(([p,d])=>{r.includes(p)||(l[p]=d)}),s.push(l)}),i.add(a))}),t.observations.forEach(e=>{if(this.hasNullJoinKeys(e,r)){s.push({...e});return}const a=r.map(o=>JSON.stringify(this.normalizeForComparison(e[o]))).join("|");i.has(a)||(s.push({...e}),i.add(a))}),new b(s)}fullJoin(t,r){if(this._groups.length>0||t._groups.length>0)throw new _("fullJoin() cannot be used on grouped data. Ungroup the data first using ungroup().");r.forEach(e=>{this.verifyObservationsContainVariable(e),t.verifyObservationsContainVariable(e)});const n=new Map;t.observations.forEach(e=>{if(this.hasNullJoinKeys(e,r))return;const a=r.map(c=>JSON.stringify(this.normalizeForComparison(e[c]))).join("|"),o=n.get(a)||[];o.push(e),n.set(a,o)});const s=[],i=new Set;return this._observations.forEach(e=>{if(this.hasNullJoinKeys(e,r)){s.push({...e});return}const a=r.map(c=>JSON.stringify(this.normalizeForComparison(e[c]))).join("|"),o=n.get(a)||[];o.length>0?(o.forEach(c=>{const l={...e};Object.entries(c).forEach(([p,d])=>{r.includes(p)||(l[p]=d)}),s.push(l)}),i.add(a)):s.push({...e})}),t.observations.forEach(e=>{if(this.hasNullJoinKeys(e,r)){s.push({...e});return}const a=r.map(o=>JSON.stringify(this.normalizeForComparison(e[o]))).join("|");i.has(a)||(s.push({...e}),i.add(a))}),new b(s)}slice(t,r){if(this._groups.length>0)throw new _("slice() cannot be used on grouped data. Ungroup the data first using ungroup().");let n;if(t>=this._observations.length)return new b([],{groups:this._groups,warnings:this._warnings});if(r===void 0){const s=t<0?this._observations.length+t:t;n=[this._observations[s]]}else n=this._observations.slice(t,r);return new b(n,{groups:this._groups,warnings:this._warnings})}bindRows(t){if(this._observations.length>0&&t.observations.length>0){const r=new Set(Object.keys(this._observations[0])),n=new Set(Object.keys(t.observations[0]));[...r].filter(i=>n.has(i)).forEach(i=>{const e=this.getVariableType(i),a=t.getVariableType(i);e!==a&&console.warn(`Warning: bindRows() is combining datasets with different data types for variable '${i}'. Left dataset has type '${e}' and right dataset has type '${a}'.`)})}return new b([...this._observations,...t.observations])}getVariableType(t){if(this._observations.length===0)return"unknown";const r={};this._observations.forEach(i=>{if(t in i){const e=i[t],a=e===null?"null":Array.isArray(e)?"array":typeof e;r[a]=(r[a]||0)+1}});let n=0,s="unknown";for(const[i,e]of Object.entries(r))e>n&&(n=e,s=i);return s}verifyObservationsContainVariable(t){if(!this._observations.every(r=>t in r))throw new _(`Variable ${t} does not exist for each item (row) in the data array.`)}variableExists(t){return this._observations.some(r=>t in r)}isNonMissingNumeric(t){return typeof t=="number"&&!isNaN(t)&&isFinite(t)}isMissingNumeric(t){return typeof t=="number"&&(isNaN(t)||!isFinite(t))||t===null||typeof t>"u"}normalizeForComparison(t){return t===null||typeof t!="object"?t:Array.isArray(t)?t.map(r=>this.normalizeForComparison(r)):Object.keys(t).sort().reduce((r,n)=>(r[n]=this.normalizeForComparison(t[n]),r),{})}deepCopy(t,r=new WeakMap){const n=globalThis.structuredClone;if(typeof n=="function")try{const e=t&&typeof t=="object"?Object.getPrototypeOf(t):null;if(Array.isArray(t)||e===Object.prototype||e===null){const o=Object.getOwnPropertyDescriptors(t);if(!Object.values(o).some(l=>typeof l.get=="function"||typeof l.set=="function"))return n(t)}}catch{}if(t===null||typeof t!="object")return t;if(r.has(t))return r.get(t);const s=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));r.set(t,s);const i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const e of i){const a=Object.getOwnPropertyDescriptor(t,e);if(a){const{get:o,set:c,...l}=a;Object.defineProperty(s,e,{...l,value:this.deepCopy(t[e],r)})}}return s}hasNullJoinKeys(t,r){return r.some(n=>t[n]===null||t[n]===void 0)}}const Ne={"+":1,"-":1,"*":2,"/":2,"^":3};class X{constructor(t,r,n,s){this.leafFn=t,this.parameters=r,this.options=n,s&&s.length>0?this.tokens=s.slice():t?this.tokens=[{t:"operand",v:this}]:this.tokens=[],this.summarizeFunction=i=>this.evaluateAsValue(i)}static leaf(t,r,n){return new X(t,r,n)}cloneWithTokens(t){return new X(void 0,void 0,void 0,t)}appendOp(t,r){const n=this.tokens.slice();return n.push({t:"op",v:t}),n.push({t:"operand",v:r}),this.cloneWithTokens(n)}add(t){return this.appendOp("+",t)}sub(t){return this.appendOp("-",t)}mul(t){return this.appendOp("*",t)}div(t){return this.appendOp("/",t)}pow(t){return this.appendOp("^",t)}evaluateOperandToNumber(t,r){if(this._usedChainIds||(this._usedChainIds=new Set),typeof t=="number")return t;if(typeof t=="string"){const a=/^__CHAIN_EXPR__\[(.*?)\]$/.exec(t);if(a){const o=a[1];let c=ie(o);if(c&&this._usedChainIds?.add(o),!c)try{c=JSON.parse(decodeURIComponent(o))}catch{c=void 0}if(!c)return NaN;let l=r,p;for(const d of c){const m=l[d.name];if(typeof m!="function")return NaN;const g=m.apply(l,d.args);if(g instanceof b){l=g;continue}if(Array.isArray(g)){p=g.length;break}if(typeof g=="boolean")if(this.options&&typeof this.options.coerceBooleans=="boolean"?this.options.coerceBooleans:!0){p=g?1:0;break}else return NaN;p=typeof g=="number"?g:Number(g);break}return p===void 0&&(p=l instanceof b?l.length:NaN),typeof p=="number"&&!isNaN(p)?p:NaN}}const n=Array.isArray(t.parameters)?t.parameters:t.parameters===void 0?void 0:[t.parameters],s=t.leafFn?t.leafFn(r,n,t.options):t.evaluateAsValue(r);if(s==null)return NaN;const i=Number(s);return typeof i=="number"&&!isNaN(i)?i:NaN}evaluateFlatTokens(t,r){const n=[],s=[];for(const a of t)a.t==="operand"?n.push(a.v):s.push(a.v);if(n.length===0)return NaN;for(;s.length>0;){let a=0,o=Ne[s[0]]??0;for(let v=1;v<s.length;v++){const C=Ne[s[v]]??0;(C>o||C===o&&s[v]==="^")&&(o=C,a=v)}const c=s.splice(a,1)[0],l=n.splice(a,1)[0],p=n.splice(a,1)[0],d=this.evaluateOperandToNumber(l,r),m=this.evaluateOperandToNumber(p,r);let g=NaN;c==="+"?g=d+m:c==="-"?g=d-m:c==="*"?g=d*m:c==="/"?g=m===0?NaN:d/m:c==="^"&&(g=Math.pow(d,m)),n.splice(a,0,g)}const i=n[0];if(typeof i=="number"){if(this._usedChainIds){for(const a of this._usedChainIds)q(a);this._usedChainIds=void 0}return i}const e=this.evaluateOperandToNumber(i,r);if(this._usedChainIds){for(const a of this._usedChainIds)q(a);this._usedChainIds=void 0}return e}parens(){return Ee(this)}evaluateAsValue(t){if(this.leafFn){const n=Array.isArray(this.parameters)?this.parameters:this.parameters===void 0?void 0:[this.parameters],s=this.leafFn(t,n,this.options);return typeof s=="number"&&Number.isNaN(s)?null:s}if(!this.tokens||this.tokens.length===0)return NaN;const r=this.evaluateFlatTokens(this.tokens,t);return typeof r=="number"&&Number.isNaN(r)?null:r}}function Ee(u){const t=[{t:"operand",v:u}];return new X(void 0,void 0,void 0,t)}const ze={coerceBooleans:!0,skipMissing:!1};function se(u){return{...ze,...u}}function fe(u,t,r){if(typeof u!="function")return u;try{const n=u(t);if(typeof n=="function")throw new _(`${r||"summarize()"}: lazy callback returned a function; expected a value or array of values.`);if(n instanceof b)throw new _(`${r||"summarize()"}: lazy callback returned a DataCalc instance; expected a value or array of values.`);return n}catch(n){throw new _(`summarize(): lazy callback threw an error: ${n&&n.message?n.message:String(n)}`)}}function Ce(u,t,r,n,s,i){const e=se(r);u.verifyObservationsContainVariable(t);let a=0,o=i,c=!1;return u.observations.forEach(l=>{if(u.isNonMissingNumeric(l[t])){o=n(l[t],o),a++;return}if(typeof l[t]=="boolean"&&e.coerceBooleans){o=n(l[t]?1:0,o),a++;return}if(u.isMissingNumeric(l[t])){c=!0;return}throw new _(`${s}: variable ${t} has non-numeric value ${l[t]} in this observation: ${JSON.stringify(l)}`)}),{state:o,count:a,containsMissing:c}}function Ie(u,t,r){const n=se(t);if(typeof u=="number"&&!isNaN(u)&&isFinite(u))return{value:u,isMissing:!1};if(typeof u=="boolean"&&n.coerceBooleans)return{value:u?1:0,isMissing:!1};if(u==null||typeof u=="number"&&(isNaN(u)||!isFinite(u)))return{value:0,isMissing:!0};throw new _(`${r}: has non-numeric value ${u}`)}const Oe=(u,t,r)=>{let n=t?t[0]:void 0;n=fe(n,u);const s=se(r);if(typeof n=="string"){if(!u.variableExists(n))return null;const i=n,e=Ce(u,i,r,(c,l)=>l+c,"variance()",0);if(e.containsMissing&&!s.skipMissing||e.count<=1)return null;const a=e.state/e.count;return Ce(u,i,r,(c,l)=>{const p=typeof c=="boolean"&&s.coerceBooleans?c?1:0:c;return l+Math.pow(p-a,2)},"variance()",0).state/(e.count-1)}else if(Array.isArray(n)){const i=[];let e=!1;for(const l of n)if(typeof l=="number"&&!isNaN(l)&&isFinite(l))i.push(l);else if(typeof l=="boolean"&&s.coerceBooleans)i.push(l?1:0);else if(l==null||typeof l=="number"&&(isNaN(l)||!isFinite(l)))e=!0;else throw new _(`variance(): has non-numeric value ${l}`);if(e&&!s.skipMissing||i.length<=1)return null;const o=i.reduce((l,p)=>l+p,0)/i.length;return i.reduce((l,p)=>l+Math.pow(p-o,2),0)/(i.length-1)}else return null},je=(u,t,r)=>{let n=t?t[0]:void 0;n=fe(n,u);const s=se(r);if(typeof n=="string"){if(!u.variableExists(n))return null;const i=n;u.verifyObservationsContainVariable(i);const e=[];let a=!1;if(u.observations.forEach(c=>{if(u.isNonMissingNumeric(c[i]))e.push(c[i]);else if(typeof c[i]=="boolean"&&s.coerceBooleans)e.push(c[i]?1:0);else if(u.isMissingNumeric(c[i]))a=!0;else throw new _(`median(): variable ${i} has non-numeric value ${c[i]} in this observation: ${JSON.stringify(c)}`)}),a&&!s.skipMissing||e.length===0)return null;e.sort((c,l)=>c-l);const o=Math.floor(e.length/2);return e.length%2===0?(e[o-1]+e[o])/2:e[o]}else if(Array.isArray(n)){const i=[];let e=!1;for(const o of n)if(typeof o=="number"&&!isNaN(o)&&isFinite(o))i.push(o);else if(typeof o=="boolean"&&s.coerceBooleans)i.push(o?1:0);else if(o==null||typeof o=="number"&&(isNaN(o)||!isFinite(o)))e=!0;else throw new _(`median(): has non-numeric value ${o}`);if(e&&!s.skipMissing||i.length===0)return null;i.sort((o,c)=>o-c);const a=Math.floor(i.length/2);return i.length%2===0?(i[a-1]+i[a])/2:i[a]}else{const i=Ie(n,r,"median()");return i.isMissing&&!s.skipMissing||i.isMissing?null:i.value}};function M(u,t){return X.leaf(je,[u],t)}const Le=(u,t,r)=>{let n=t?t[0]:void 0;if(n=fe(n,u),typeof n=="string"){if(!u.variableExists(n))return null;const s=Oe(u,t,r);return s===null?null:Math.sqrt(s)}else if(Array.isArray(n)){const s=t?[...t]:[n],i=Oe(u,s,r);return i===null?null:Math.sqrt(i)}else return null};function F(u,t){return X.leaf(Le,[u],t)}const Xe=(u,t,r)=>{let n=t?t[0]:void 0;if(typeof n=="function"&&(n=n(u)),typeof n=="string"){const e=/^__CHAIN_EXPR__\[(.*?)\]$/.exec(n);if(e){const a=e[1];let o=ie(a);if(!o)try{o=JSON.parse(decodeURIComponent(a))}catch{o=void 0}if(o){let c=u,l;for(const p of o){const d=c[p.name];if(typeof d!="function"){l=NaN;break}const m=d.apply(c,p.args);if(m instanceof b){c=m;continue}if(Array.isArray(m)){l=m.length;break}if(typeof m=="boolean"){l=m;break}l=typeof m=="number"?m:Number(m);break}l===void 0&&(l=c instanceof b?c.length:NaN),Number.isNaN(l)?n=null:n=l;try{q(a)}catch{}}}}if(typeof n=="object"&&n!==null&&"summarizeFunction"in n)try{const i=n,e=Array.isArray(i.parameters)?i.parameters:i.parameters===void 0?void 0:[i.parameters];n=i.summarizeFunction(u,e,i.options)}catch{n=null}const s=Ie(n,r,"scalar()");return s.isMissing?null:s.value};function oe(u){return X.leaf(Xe,[u],void 0)}console.log("\u26AA @m2c2kit/data-calc version 0.8.7 (38a5862e)");class Ve extends Me{constructor(){const t={fixation_duration_ms:{default:500,description:"How long fixation scene is shown, milliseconds.",type:"number"},shape_colors:{type:"array",description:"Array of colors for shapes.",items:{type:"object",properties:{colorName:{type:"string",description:"Human-friendly name of color."},rgbaColor:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}}}},default:[{colorName:"black",rgbaColor:[0,0,0,1]},{colorName:"green",rgbaColor:[0,158,115,1]},{colorName:"yellow",rgbaColor:[240,228,66,1]},{colorName:"blue",rgbaColor:[0,114,178,1]},{colorName:"orange",rgbaColor:[213,94,0,1]},{colorName:"pink",rgbaColor:[204,121,167,1]}]},number_of_shapes_shown:{default:3,description:"How many shapes to show on the grid at one time.",type:"integer"},number_of_shapes_changing_color:{default:2,description:"If a different color trial, how many shapes should change color (minimum is 2, because changes are swaps with other shapes).",type:"integer"},shapes_presented_duration_ms:{default:2e3,description:"How long the shapes are shown, milliseconds.",type:"number"},shapes_removed_duration_ms:{default:1e3,description:"How long to show a blank square after shapes are removed, milliseconds.",type:"number"},cells_per_side:{default:3,description:"How many cell positions for each side of the square grid (e.g., 3 is a 3x3 grid; 4 is a 4x4 grid).",type:"integer"},number_of_different_colors_trials:{default:6,type:"integer",description:"Number of trials where the shapes have different colors."},number_of_trials:{default:12,description:"How many trials to run.",type:"integer"},show_trials_complete_scene:{default:!0,type:"boolean",description:"After the final trial, should a completion scene be shown? Otherwise, the game will immediately end."},instruction_type:{default:"long",description:"Type of instructions to show, 'short' or 'long'.",type:"string",enum:["short","long"]},instructions:{default:null,type:["object","null"],description:"When non-null, an InstructionsOptions object that will completely override the built-in instructions."},show_quit_button:{type:"boolean",default:!1,description:"Should the activity quit button be shown?"},show_fps:{type:"boolean",default:!1,description:"Should the FPS be shown?"},show_locale_picker:{type:"boolean",default:!1,description:"Should the icon that allows the participant to switch the locale be shown?"},seed:{type:["string","null"],default:null,description:"Optional seed for the seeded pseudo-random number generator. When null, the default Math.random() is used."},scoring:{type:"boolean",default:!1,description:"Should scoring data be generated? Default is false."},scoring_filter_response_time_duration_ms:{type:"array",items:{type:"number"},default:[100,1e4],description:"When scoring, values of response_time_duration_ms less than the lower bound or greater than the upper bound are discarded. This array contains two numbers, the lower and upper bounds."}},r={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the trial. Null if trial was skipped."},trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the trial (when user presses 'Same' or 'Different'). Null if trial was skipped."},trial_index:{type:["integer","null"],description:"Index of the trial within this assessment, 0-based."},present_shapes:{description:"Configuration of shapes shown to the user in the presentation phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_shapes:{description:"Configuration of shapes shown to the user in the response phase. Null if trial was skipped.",type:["array","null"],items:{type:"object",properties:{shape_index:{type:"integer",description:"Index of the shape within the library of shapes, 0-based"},color_name:{type:"string",description:"Human-friendly name of color."},rgba_color:{type:"array",description:"Color as array, [r,g,b,a].",items:{type:"number"}},location:{type:"object",description:"Location of shape.",properties:{row:{type:"number",description:"Row of the shape, 0-based."},column:{type:"number",description:"Column of the shape, 0-based."}}}}}},response_time_duration_ms:{type:["number","null"],description:"Milliseconds from when the response configuration of shapes is shown until the user taps a response. Null if trial was skipped."},user_response:{type:["string","null"],enum:["same","different"],description:"User's response to whether the shapes are same colors or different."},user_response_correct:{type:["boolean","null"],description:"Was the user's response correct?"},quit_button_pressed:{type:"boolean",description:"Was the quit button pressed?"}},n={activity_begin_iso8601_timestamp:{type:"string",format:"date-time",description:"ISO 8601 timestamp at the beginning of the game activity."},first_trial_begin_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the beginning of the first trial. Null if no trials were completed."},last_trial_end_iso8601_timestamp:{type:["string","null"],format:"date-time",description:"ISO 8601 timestamp at the end of the last trial. Null if no trials were completed."},response_time_filter_lower_bound:{type:"number",description:"Response times less than this lower bound were discarded when calculating filtered response times."},response_time_filter_upper_bound:{type:"number",description:"Response times greater than this upper bound were discarded when calculating filtered response times."},n_trials:{type:"integer",description:"Number of trials completed."},flag_trials_match_expected:{type:"integer",description:"Does the number of completed and expected trials match? 1 = true, 0 = false."},n_trials_correct:{type:"integer",description:"Number of correct trials."},n_trials_incorrect:{type:"integer",description:"Number of incorrect trials."},participant_score:{type:["number","null"],description:"Participant-facing score, calculated as (number of correct trials / number of trials attempted) * 100. This is a simple metric to provide feedback to the participant. Null if no trials attempted."},flag_trials_lt_expected:{type:"number",description:"Is the number of completed trials fewer than expected? 1 = true, 0 = false."},flag_trials_gt_expected:{type:"number",description:"Is the number of completed trials greater than expected? 1 = true, 0 = false."},n_trials_HIT:{type:"number",description:"Number of HIT trials (correctly identified a 'different' trial)"},n_trials_MISS:{type:"number",description:"Number of MISS trials (failed to detect a 'different' trial, responded 'same')"},n_trials_FA:{type:"number",description:"Number of False Alarm trials (incorrectly responded 'different' on a 'same' trial)"},n_trials_CR:{type:"number",description:"Number of Correct Rejection trials (correctly responded 'same' on a 'same' trial)"},n_trials_type_same:{type:"number",description:"Number of trials where the true signal type was 'SAME' (presented and response shapes were identical)"},n_trials_type_different:{type:"number",description:"Number of trials where the true signal type was 'DIFFERENT' (response shapes differed from presented)"},HIT_rate:{type:["number","null"],description:"Proportion of 'different' trials correctly identified as different. Calculated as n_trials_HIT / n_trials_type_different"},MISS_rate:{type:["number","null"],description:"Proportion of 'different' trials incorrectly identified as same. Calculated as 1 - HIT_rate"},FA_rate:{type:["number","null"],description:"Proportion of 'same' trials incorrectly identified as different. Calculated as n_trials_FA / n_trials_type_same"},CR_rate:{type:["number","null"],description:"Proportion of 'same' trials correctly identified as same. Calculated as 1 - FA_rate"},n_trials_rt_invalid:{type:"number",description:"Number of trials with null or non-positive response times (excluded from RT calculations)"},median_rt_overall_valid:{type:["number","null"],description:"Median response time (ms) across all trials with valid (non-null, positive) response times. No outlier filtering applied"},sd_rt_overall_valid:{type:["number","null"],description:"Standard deviation of response time (ms) across all trials with valid response times. No outlier filtering applied"},median_rt_HIT_valid:{type:["number","null"],description:"Median response time (ms) for HIT trials with valid response times. No outlier filtering"},sd_rt_HIT_valid:{type:["number","null"],description:"Standard deviation of response time (ms) for HIT trials with valid response times. No outlier filtering"},median_rt_MISS_valid:{type:["number","null"],description:"Median response time (ms) for MISS trials with valid response times. No outlier filtering"},sd_rt_MISS_valid:{type:["number","null"],description:"Standard deviation of response time (ms) for MISS trials with valid response times. No outlier filtering"},median_rt_FA_valid:{type:["number","null"],description:"Median response time (ms) for False Alarm trials with valid response times. No outlier filtering"},sd_rt_FA_valid:{type:["number","null"],description:"Standard deviation of response time (ms) for False Alarm trials with valid response times. No outlier filtering"},median_rt_CR_valid:{type:["number","null"],description:"Median response time (ms) for Correct Rejection trials with valid response times. No outlier filtering"},sd_rt_CR_valid:{type:["number","null"],description:"Standard deviation of response time (ms) for Correct Rejection trials with valid response times. No outlier filtering"},median_rt_overall_valid_filtered:{type:["number","null"],description:"Median response time (ms) across all valid trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},sd_rt_overall_valid_filtered:{type:["number","null"],description:"Standard deviation of response time (ms) across all valid trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},n_outliers_rt_overall_valid:{type:"number",description:"Number of valid trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},median_rt_HIT_valid_filtered:{type:["number","null"],description:"Median response time (ms) for HIT trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},sd_rt_HIT_valid_filtered:{type:["number","null"],description:"Standard deviation of response time (ms) for HIT trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},n_outliers_rt_HIT_valid:{type:"number",description:"Number of HIT trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},median_rt_MISS_valid_filtered:{type:["number","null"],description:"Median response time (ms) for MISS trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},sd_rt_MISS_valid_filtered:{type:["number","null"],description:"Standard deviation of response time (ms) for MISS trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},n_outliers_rt_MISS_valid:{type:"number",description:"Number of MISS trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},median_rt_FA_valid_filtered:{type:["number","null"],description:"Median response time (ms) for False Alarm trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},sd_rt_FA_valid_filtered:{type:["number","null"],description:"Standard deviation of response time (ms) for False Alarm trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},n_outliers_rt_FA_valid:{type:"number",description:"Number of False Alarm trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},median_rt_CR_valid_filtered:{type:["number","null"],description:"Median response time (ms) for Correct Rejection trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},sd_rt_CR_valid_filtered:{type:["number","null"],description:"Standard deviation of response time (ms) for Correct Rejection trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."},n_outliers_rt_CR_valid:{type:["number","null"],description:"Number of Correct Rejection trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."}},i={name:"Color Shapes",id:"color-shapes",publishUuid:"394cb010-2ccf-4a87-9d23-cda7fb07a960",version:"0.8.34 (38a5862e)",moduleMetadata:{name:"@m2c2kit/assessment-color-shapes",version:"0.8.34",dependencies:{"@m2c2kit/addons":"0.3.35","@m2c2kit/core":"0.3.36","@m2c2kit/data-calc":"0.8.7"}},translation:{configuration:{baseLocale:"en-US"},"en-US":{localeName:"English",INSTRUCTIONS_TITLE:"Color Shapes",SHORT_INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear. When the shapes reappear, answer whether they have the SAME or DIFFERENT colors as they had before",INSTRUCTIONS_TEXT_PAGE_1:"Try to remember the color of 3 shapes, because they will soon disappear.",INSTRUCTIONS_TEXT_PAGE_2:"Next you will see the same shapes reappear.",INSTRUCTIONS_TEXT_PAGE_3:"Answer whether the shapes have the SAME or DIFFERENT colors as they had before.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Next",BACK_BUTTON_TEXT:"Back",GET_READY_COUNTDOWN_TEXT:"GET READY!",SAME_BUTTON_TEXT:"Same",DIFFERENT_BUTTON_TEXT:"Different",TRIALS_COMPLETE_SCENE_TEXT:"This activity is complete.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"es-MX":{localeName:"Espa\xF1ol",INSTRUCTIONS_TITLE:"Formas de Color",INSTRUCTIONS_TEXT_PAGE_1:"Intenta recordar el color de las 3 formas, porque pronto desaparecer\xE1n.",INSTRUCTIONS_TEXT_PAGE_2:"Luego ver\xE1s reaparecer las mismas formas.",INSTRUCTIONS_TEXT_PAGE_3:"Responde si las formas tienen el MISMO o DIFERENTE color que antes.",START_BUTTON_TEXT:"COMENZAR",NEXT_BUTTON_TEXT:"Siguiente",BACK_BUTTON_TEXT:"Atr\xE1s",GET_READY_COUNTDOWN_TEXT:"PREP\xC1RESE",SAME_BUTTON_TEXT:"Mismo",DIFFERENT_BUTTON_TEXT:"Diferente",TRIALS_COMPLETE_SCENE_TEXT:"Esta actividad est\xE1 completa.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"},"de-DE":{localeName:"Deutsch",INSTRUCTIONS_TITLE:"Farb-Formen",INSTRUCTIONS_TEXT_PAGE_1:"Oben und unten sehen Sie Symbolpaare.",INSTRUCTIONS_TEXT_PAGE_2:"Ihre Aufgabe wird es sein, auf dasjenige untere Paar zu tippen, welches mit einem der obigen Paare exakt \xFCbereinstimmt.",INSTRUCTIONS_TEXT_PAGE_3:"Versuchen Sie bitte, so schnell und korrekt wie m\xF6glich zu sein.",START_BUTTON_TEXT:"START",NEXT_BUTTON_TEXT:"Weiter",BACK_BUTTON_TEXT:"Vorherige",GET_READY_COUNTDOWN_TEXT:"BEREIT MACHEN",SAME_BUTTON_TEXT:"Gleich",DIFFERENT_BUTTON_TEXT:"Unterschiedlich",TRIALS_COMPLETE_SCENE_TEXT:"Die Aufgabe ist beendet.",TRIALS_COMPLETE_SCENE_BUTTON_TEXT:"OK"}},shortDescription:"Color Shapes is a visual array change detection task, measuring intra-item feature binding, where participants determine if shapes change color across two sequential presentations of shape stimuli.",longDescription:'Color Shapes is a change detection paradigm used to measure visual short-term memory binding (Parra et al., 2009). Participants are asked to memorize the shapes and colors of three different polygons for 3 seconds. The three polygons are then removed from the screen and re-displayed at different locations, either having the same or different colors. Participants are then asked to decide whether the combination of colors and shapes are the "Same" or "Different" between the study and test phases.',showFps:t.show_fps.default,width:400,height:800,trialSchema:r,scoringSchema:n,parameters:t,fonts:[{fontName:"roboto",url:"fonts/roboto/Roboto-Regular.ttf"}],images:[{imageName:"instructions-1",height:256,width:256,url:"images/cs-instructions-1.png"},{imageName:"instructions-2",height:256,width:256,url:"images/cs-instructions-2.png"},{imageName:"instructions-3",height:350,width:300,url:"images/cs-instructions-3.png",localize:!0},{imageName:"circle-x",height:32,width:32,url:"images/circle-x.svg"}]};super(i)}async initialize(){await super.initialize();const t=this,r=t.getParameter("seed");typeof r=="string"&&L.setSeed(r);const n=96,s=350,i=t.getParameter("number_of_shapes_shown"),e=this.makeShapes(n);if(t.getParameter("show_quit_button")){const T=new Fe({imageName:"circle-x",position:{x:380,y:20},isUserInteractionEnabled:!0});t.addFreeNode(T),T.onTapDown(w=>{t.removeAllFreeNodes(),w.handled=!0;const S=new J;if(t.addScene(S),t.presentScene(S),t.addTrialData("quit_button_pressed",!0),t.trialComplete(),t.getParameter("scoring")){const z=t.calculateScores([],{rtLowerBound:t.getParameter("scoring_filter_response_time_duration_ms")[0],rtUpperBound:t.getParameter("scoring_filter_response_time_duration_ms")[1],numberOfTrials:t.getParameter("number_of_trials")});t.addScoringData(z),t.scoringComplete()}t.cancel()})}let a;t.getParameter("show_locale_picker")&&(a=new xe,t.addFreeNode(a));let o;const c=t.getParameter("instructions");if(c)o=de.create(c);else switch(t.getParameter("instruction_type")){case"short":{o=de.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"SHORT_INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:I.Green,nextSceneTransition:ue.none()}]});break}case"long":{o=de.create({instructionScenes:[{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_1",imageName:"instructions-1",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_2",imageName:"instructions-2",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"NEXT_BUTTON_TEXT",backButtonText:"BACK_BUTTON_TEXT"},{title:"INSTRUCTIONS_TITLE",text:"INSTRUCTIONS_TEXT_PAGE_3",imageName:"instructions-3",imageAboveText:!1,imageMarginTop:32,textFontSize:24,titleFontSize:30,textVerticalBias:.2,nextButtonText:"START_BUTTON_TEXT",nextButtonBackgroundColor:I.Green,backButtonText:"BACK_BUTTON_TEXT"}]});break}default:throw new ye("invalid value for instruction_type")}o[0].onAppear(()=>{t.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp)}),t.addScenes(o);const l=new Ue({milliseconds:3e3,text:"GET_READY_COUNTDOWN_TEXT",zeroDwellMilliseconds:1e3,transition:ue.none()});t.addScene(l);const p=t.getParameter("cells_per_side"),d=t.getParameter("cells_per_side"),m=t.getParameter("number_of_trials"),g=t.getParameter("shape_colors"),v=[],C=t.getParameter("cells_per_side"),N=C,K=t.getParameter("number_of_different_colors_trials"),V=L.fromRangeWithoutReplacement(K,0,m-1);for(let T=0;T<m;T++){const w=new Array,S=new Array,z=L.fromRangeWithoutReplacement(i,0,e.length-1),G=L.fromRangeWithoutReplacement(i,0,g.length-1),te=y=>!!(y.map(f=>f.row===0&&f.column===0).some(f=>f===!0)&&y.map(f=>f.row===1&&f.column===1).some(f=>f===!0)&&y.map(f=>f.row===2&&f.column===2).some(f=>f===!0)||y.map(f=>f.row===2&&f.column===0).some(f=>f===!0)&&y.map(f=>f.row===1&&f.column===1).some(f=>f===!0)&&y.map(f=>f.row===0&&f.column===2).some(f=>f===!0)),E=y=>{const f=new Set(y.map(W=>W.row)).size,H=new Set(y.map(W=>W.column)).size;return!(f!==1&&H!==1)};let le=!1,re;do re=L.fromGridWithoutReplacement(i,C,N),!E(re)&&!te(re)?le=!0:le=!1;while(!le);for(let y=0;y<i;y++){const f={shape:e[z[y]],shapeIndex:z[y],color:g[G[y]].rgbaColor,colorName:g[G[y]].colorName,location:re[y]};w.push(f)}let ce=!1,ne;do ne=L.fromGridWithoutReplacement(i,C,N),!E(ne)&&!te(ne)?ce=!0:ce=!1;while(!ce);for(let y=0;y<i;y++){const f={shape:w[y].shape,shapeIndex:z[y],color:w[y].color,colorName:g[G[y]].colorName,location:ne[y]};S.push(f)}let ge=0;if(V.includes(T)){const y=t.getParameter("number_of_shapes_changing_color");if(y>i)throw new ye(`number_of_shapes_changing_color is ${y}, but it must be less than or equal to number_of_shapes_shown (which is ${i}).`);const H=L.fromRangeWithoutReplacement(y,0,i-1).map(j=>S[j]);ge=H.length;const W=H[0].color;for(let j=0;j<y;j++){const be=H[j];j+1<y?be.color=H[j+1].color:be.color=W}}v.push({presentShapes:w,responseShapes:S,numberOfShapesWithDifferentColors:ge})}const O=new J;t.addScene(O);const B=new R({rect:{size:{width:s,height:s}},fillColor:I.Transparent,strokeColor:I.Gray,lineWidth:4,position:{x:200,y:300}});O.addChild(B);const D=new Te({text:"+",fontSize:32,fontColor:I.Black,localize:!1});B.addChild(D),O.onAppear(()=>{t.addTrialData("activity_begin_iso8601_timestamp",this.beginIso8601Timestamp),t.addTrialData("trial_begin_iso8601_timestamp",new Date().toISOString()),O.run(x.sequence([x.wait({duration:t.getParameter("fixation_duration_ms")}),x.custom({callback:()=>{t.presentScene(k)}})]))});const k=new J;t.addScene(k);const A=new R({rect:{size:{width:s,height:s}},fillColor:I.Transparent,strokeColor:I.Gray,lineWidth:4,position:{x:200,y:300}});k.addChild(A);const Z=new we({rows:p,columns:d,size:{width:s,height:s},position:{x:200,y:300},backgroundColor:I.Transparent,gridLineColor:I.Transparent});k.addChild(Z),k.onAppear(()=>{const T=v[t.trialIndex];for(let w=0;w<T.presentShapes.length;w++){const S=T.presentShapes[w].shape;S.fillColor=T.presentShapes[w].color,S.position={x:0,y:0},Z.addAtCell(S,T.presentShapes[w].location.row,T.presentShapes[w].location.column)}k.run(x.sequence([x.wait({duration:t.getParameter("shapes_presented_duration_ms")}),x.custom({callback:()=>{Z.removeAllGridChildren()}}),x.wait({duration:t.getParameter("shapes_removed_duration_ms")}),x.custom({callback:()=>{Z.removeAllGridChildren(),t.presentScene(P)}})]))});const P=new J;t.addScene(P);const Ae=new R({rect:{size:{width:s,height:s}},fillColor:I.Transparent,strokeColor:I.Gray,lineWidth:4,position:{x:200,y:300}});P.addChild(Ae);const ae=new we({rows:p,columns:d,size:{width:s,height:s},position:{x:200,y:300},backgroundColor:I.Transparent,gridLineColor:I.Transparent});P.addChild(ae),P.onAppear(()=>{const T=v[t.trialIndex];for(let w=0;w<T.responseShapes.length;w++){const S=T.responseShapes[w].shape;S.fillColor=T.responseShapes[w].color,S.position={x:0,y:0},ae.addAtCell(S,T.responseShapes[w].location.row,T.responseShapes[w].location.column)}Y.isUserInteractionEnabled=!0,Q.isUserInteractionEnabled=!0,pe.startNew("rt")});const Y=new _e({text:"SAME_BUTTON_TEXT",position:{x:100,y:700},size:{width:150,height:50}});P.addChild(Y),Y.onTapDown(()=>{Y.isUserInteractionEnabled=!1,he(!1)});const Q=new _e({text:"DIFFERENT_BUTTON_TEXT",position:{x:300,y:700},size:{width:150,height:50}});P.addChild(Q),Q.onTapDown(()=>{Q.isUserInteractionEnabled=!1,he(!0)});const he=T=>{const w=pe.elapsed("rt");pe.remove("rt"),ae.removeAllGridChildren(),t.addTrialData("trial_end_iso8601_timestamp",new Date().toISOString());const S=v[t.trialIndex];t.addTrialData("response_time_duration_ms",w),t.addTrialData("user_response",T?"different":"same");const z=S.numberOfShapesWithDifferentColors===0&&!T||S.numberOfShapesWithDifferentColors>0&&T;t.addTrialData("user_response_correct",z);const G=S.presentShapes.map(E=>({shape_index:E.shapeIndex,color_name:E.colorName,rgba_color:E.color,location:E.location}));t.addTrialData("present_shapes",G),t.addTrialData("quit_button_pressed",!1);const te=S.responseShapes.map(E=>({shape_index:E.shapeIndex,color_name:E.colorName,rgba_color:E.color,location:E.location}));if(t.addTrialData("response_shapes",te),t.addTrialData("trial_index",t.trialIndex),t.trialComplete(),t.trialIndex<m)t.presentScene(O);else{if(t.getParameter("scoring")){const E=t.calculateScores(t.data.trials,{rtLowerBound:t.getParameter("scoring_filter_response_time_duration_ms")[0],rtUpperBound:t.getParameter("scoring_filter_response_time_duration_ms")[1],numberOfTrials:t.getParameter("number_of_trials")});t.addScoringData(E),t.scoringComplete()}t.getParameter("show_trials_complete_scene")?t.presentScene($,ue.slide({direction:ke.Left,duration:500,easing:Be.sinusoidalInOut})):t.end()}},$=new J;t.addScene($);const Re=new Te({text:"TRIALS_COMPLETE_SCENE_TEXT",position:{x:200,y:400}});$.addChild(Re);const ee=new _e({text:"TRIALS_COMPLETE_SCENE_BUTTON_TEXT",position:{x:200,y:650}});ee.isUserInteractionEnabled=!0,ee.onTapDown(()=>{ee.isUserInteractionEnabled=!1,$.removeAllChildren(),t.end()}),$.addChild(ee),$.onSetup(()=>{t.removeAllFreeNodes()})}calculateScores(t,r){const n=new b(t),s=n.filter(e=>e.quit_button_pressed===!1).length;return n.mutate({metric_accuracy:e=>{const a=e.user_response,o=e.user_response_correct;return a==="same"&&o===!0?"CR":a==="same"&&o===!1?"MISS":a==="different"&&o===!0?"HIT":a==="different"&&o===!1?"FA":null},metric_trial_type:e=>{const a=e.user_response,o=e.user_response_correct;return a==="same"&&o===!0?"SAME":a==="same"&&o===!1||a==="different"&&o===!0?"DIFFERENT":a==="different"&&o===!1?"SAME":null},is_valid:e=>typeof e.response_time_duration_ms=="number"&&e.response_time_duration_ms>0}).summarize({activity_begin_iso8601_timestamp:this.beginIso8601Timestamp,first_trial_begin_iso8601_timestamp:Se("trial_begin_iso8601_timestamp").slice(0).pull("trial_begin_iso8601_timestamp"),last_trial_end_iso8601_timestamp:Se("-trial_end_iso8601_timestamp").slice(0).pull("trial_end_iso8601_timestamp"),n_trials:s,flag_trials_match_expected:s===r.numberOfTrials?1:0,flag_trials_lt_expected:s<r.numberOfTrials?1:0,flag_trials_gt_expected:s>r.numberOfTrials?1:0,n_trials_HIT:h(e=>e.metric_accuracy==="HIT").length,n_trials_MISS:h(e=>e.metric_accuracy==="MISS").length,n_trials_FA:h(e=>e.metric_accuracy==="FA").length,n_trials_CR:h(e=>e.metric_accuracy==="CR").length,n_trials_type_same:h(e=>e.metric_trial_type==="SAME").length,n_trials_type_different:h(e=>e.metric_trial_type==="DIFFERENT").length,HIT_rate:e=>{const a=e.filter(o=>o.metric_trial_type==="DIFFERENT").length;return a>0?e.filter(o=>o.metric_accuracy==="HIT").length/a:null},MISS_rate:e=>{const a=e.filter(o=>o.metric_trial_type==="DIFFERENT").length;return a>0?1-e.filter(o=>o.metric_accuracy==="HIT").length/a:null},FA_rate:e=>{const a=e.filter(o=>o.metric_trial_type==="SAME").length;return a>0?e.filter(o=>o.metric_accuracy==="FA").length/a:null},CR_rate:e=>{const a=e.filter(o=>o.metric_trial_type==="SAME").length;return a>0?1-e.filter(o=>o.metric_accuracy==="FA").length/a:null},median_rt_overall_valid:M(h(e=>e.is_valid).pull("response_time_duration_ms")),sd_rt_overall_valid:F(h(e=>e.is_valid).pull("response_time_duration_ms")),median_rt_overall_valid_filtered:M(h(e=>e.is_valid).filter(e=>e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),sd_rt_overall_valid_filtered:F(h(e=>e.is_valid).filter(e=>e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),n_trials_rt_invalid:h(e=>!e.is_valid).length,n_outliers_rt_overall_valid:h(e=>e.is_valid).filter(e=>e.response_time_duration_ms<r.rtLowerBound||e.response_time_duration_ms>r.rtUpperBound).length,response_time_filter_lower_bound:r.rtLowerBound,response_time_filter_upper_bound:r.rtUpperBound,median_rt_HIT_valid:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="HIT").pull("response_time_duration_ms")),sd_rt_HIT_valid:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="HIT").pull("response_time_duration_ms")),median_rt_HIT_valid_filtered:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="HIT"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),sd_rt_HIT_valid_filtered:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="HIT"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),n_outliers_rt_HIT_valid:h(e=>e.is_valid).filter(e=>e.metric_accuracy==="HIT").filter(e=>e.response_time_duration_ms<r.rtLowerBound||e.response_time_duration_ms>r.rtUpperBound).length,median_rt_MISS_valid:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="MISS").pull("response_time_duration_ms")),sd_rt_MISS_valid:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="MISS").pull("response_time_duration_ms")),median_rt_MISS_valid_filtered:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="MISS"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),sd_rt_MISS_valid_filtered:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="MISS"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),n_outliers_rt_MISS_valid:h(e=>e.is_valid).filter(e=>e.metric_accuracy==="MISS").filter(e=>e.response_time_duration_ms<r.rtLowerBound||e.response_time_duration_ms>r.rtUpperBound).length,median_rt_FA_valid:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="FA").pull("response_time_duration_ms")),sd_rt_FA_valid:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="FA").pull("response_time_duration_ms")),median_rt_FA_valid_filtered:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="FA"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),sd_rt_FA_valid_filtered:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="FA"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),n_outliers_rt_FA_valid:h(e=>e.is_valid).filter(e=>e.metric_accuracy==="FA").filter(e=>e.response_time_duration_ms<r.rtLowerBound||e.response_time_duration_ms>r.rtUpperBound).length,median_rt_CR_valid:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="CR").pull("response_time_duration_ms")),sd_rt_CR_valid:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="CR").pull("response_time_duration_ms")),median_rt_CR_valid_filtered:M(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="CR"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),sd_rt_CR_valid_filtered:F(h(e=>e.is_valid).filter(e=>e.metric_accuracy==="CR"&&e.response_time_duration_ms>=r.rtLowerBound&&e.response_time_duration_ms<=r.rtUpperBound).pull("response_time_duration_ms")),n_outliers_rt_CR_valid:h(e=>e.is_valid).filter(e=>e.metric_accuracy==="CR").filter(e=>e.response_time_duration_ms<r.rtLowerBound||e.response_time_duration_ms>r.rtUpperBound).length,n_trials_correct:h(e=>e.metric_accuracy==="HIT"||e.metric_accuracy==="CR").length,n_trials_incorrect:h(e=>e.metric_accuracy==="MISS"||e.metric_accuracy==="FA").length,participant_score:e=>{const a=e.length;return a===0?null:e.summarize({correct:Ee(oe(e.filter(o=>o.metric_accuracy==="HIT").length).add(oe(e.filter(o=>o.metric_accuracy==="CR").length))).div(oe(a)).mul(oe(100))}).pull("correct")}}).observations}makeShapes(t){const r=new R({path:{pathString:U[0],height:t},lineWidth:0}),n=new R({path:{pathString:U[1],height:t},lineWidth:0}),s=new R({path:{pathString:U[2],height:t*.8},lineWidth:0}),i=new R({path:{pathString:U[3],height:t},lineWidth:0}),e=new R({path:{pathString:U[4],height:t*.8},lineWidth:0}),a=new R({path:{pathString:U[5],height:t},lineWidth:0}),o=new R({path:{pathString:U[6],height:t},lineWidth:0}),c=new R({path:{pathString:U[7],height:t},lineWidth:0});return[r,n,s,i,e,a,o,c]}}const U=["M0 89.94v-2L131.95 0h2v88.7c2.34 1.6 4.47 3.11 6.65 4.55 42.77 28.22 85.54 56.42 128.3 84.63v2c-44.65 29.65-89.3 59.29-133.95 88.94h-1v-90.84C89.44 148.72 44.72 119.33 0 89.94Z","M162 188c-.33 27-.67 54-1 81-26.87-26.18-53.74-52.35-80-77.94V269H0C0 180.83 0 92.67.04 4.5.04 3 .67 1.5 1 0c24.64 29.1 49.15 58.31 73.96 87.26 28.88 33.7 58.01 67.17 87.04 100.74Z","M3 148.86V61.12C41.76 40.75 80.52 20.37 119.28 0h2.91c21.32 20.7 42.64 41.4 63.96 62.11v89.71c-38.44 20.04-76.88 40.09-115.31 60.13h-2.91L3.01 148.86Z","M134 0h2c7.26 22.31 14.38 44.67 21.86 66.9 3.91 11.61 5.47 29.91 13.25 33.27C203 113.94 236.86 123.13 270 134v1L136 269h-1c-11.04-33.58-22.08-67.16-33.21-101.03C67.87 156.98 33.93 145.99 0 135v-1L134 0Z","M107 0h1l108 108v1c-26.67 35.33-53.33 70.66-80 106h-1c-8.82-35.03-17.64-70.07-27-107.28C98.62 145.01 89.81 180 81.01 215h-1C53.33 179.66 26.67 144.33 0 109v-2L107 0Z","M0 1C2.17.67 4.33.05 6.5.04 58.33-.01 110.17 0 162 0v270H2c26.2-22.17 52.41-44.33 78.86-66.71V67.4c-3.85-3.22-7.35-6.2-10.9-9.11C46.64 39.18 23.32 20.09 0 1Z","M95 268.99h-1C62.66 238.66 31.33 208.33 0 178V88C26.67 58.67 53.33 29.33 80 0h1c0 29.45 0 58.89-.01 88.38 35.99 29.57 72 59.09 108.01 88.61v1l-94 91Z","M13 0h67l135 135v1L81 270c-27-.33-54-.67-81-1 11.73-12.51 23.61-24.87 35.16-37.54 33.14-36.35 66.14-72.82 100.23-110.38C94.4 80.52 53.7 40.26 13 0Z"];export{Ve as ColorShapes};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/assessment-color-shapes",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.34",
|
|
4
4
|
"m2c2kit": {
|
|
5
5
|
"assessmentId": "color-shapes",
|
|
6
6
|
"locales": [
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"build": "npm run clean && tsc && rollup -c && npm run schemas",
|
|
15
15
|
"serve": "concurrently \"rollup -c rollup.config.runner.mjs --watch --configServe\" \"tsc --project tsconfig.runner.json --watch\" --names rollup,typescript --prefix-colors auto,red",
|
|
16
16
|
"schemas": "node ../schema-util/build/index.js list --schema=all --files=src/index.ts --format=json-schema --title=\"Color Shapes version __VERSION__\" > schemas.json",
|
|
17
|
-
"clean": "rimraf build dist .rollup.cache tsconfig.tsbuildinfo tsconfig.runner.tsbuildinfo"
|
|
17
|
+
"clean": "rimraf build dist .rollup.cache tsconfig.tsbuildinfo tsconfig.runner.tsbuildinfo",
|
|
18
|
+
"test": "cd ../.. && npx env-cmd -f .env.jest jest --selectProjects @m2c2kit/assessment-color-shapes"
|
|
18
19
|
},
|
|
19
20
|
"main": "./dist/index.js",
|
|
20
21
|
"module": "./dist/index.js",
|
|
@@ -43,22 +44,23 @@
|
|
|
43
44
|
},
|
|
44
45
|
"homepage": "https://m2c2-project.github.io/m2c2kit",
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@m2c2kit/addons": "0.3.
|
|
47
|
-
"@m2c2kit/core": "0.3.
|
|
47
|
+
"@m2c2kit/addons": "0.3.35",
|
|
48
|
+
"@m2c2kit/core": "0.3.36",
|
|
49
|
+
"@m2c2kit/data-calc": "0.8.7"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@m2c2kit/build-helpers": "0.3.
|
|
51
|
-
"@m2c2kit/schema-util": "0.1.
|
|
52
|
-
"@m2c2kit/session": "0.3.
|
|
52
|
+
"@m2c2kit/build-helpers": "0.3.32",
|
|
53
|
+
"@m2c2kit/schema-util": "0.1.26",
|
|
54
|
+
"@m2c2kit/session": "0.3.18",
|
|
53
55
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
54
56
|
"concurrently": "9.2.1",
|
|
55
|
-
"rimraf": "6.
|
|
56
|
-
"rollup": "4.
|
|
57
|
+
"rimraf": "6.1.3",
|
|
58
|
+
"rollup": "4.59.0",
|
|
57
59
|
"rollup-plugin-copy": "3.5.0",
|
|
58
60
|
"rollup-plugin-esbuild": "6.2.1",
|
|
59
61
|
"typescript": "5.9.3"
|
|
60
62
|
},
|
|
61
63
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
64
|
+
"node": ">=22"
|
|
63
65
|
}
|
|
64
66
|
}
|
package/schemas.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"title": "Color Shapes version 0.8.
|
|
3
|
+
"title": "Color Shapes version 0.8.34, 38a5862e",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"description": "All game schemas",
|
|
6
6
|
"properties": {
|
|
@@ -173,6 +173,17 @@
|
|
|
173
173
|
"type": "boolean",
|
|
174
174
|
"default": false,
|
|
175
175
|
"description": "Should scoring data be generated? Default is false."
|
|
176
|
+
},
|
|
177
|
+
"scoring_filter_response_time_duration_ms": {
|
|
178
|
+
"type": "array",
|
|
179
|
+
"items": {
|
|
180
|
+
"type": "number"
|
|
181
|
+
},
|
|
182
|
+
"default": [
|
|
183
|
+
100,
|
|
184
|
+
10000
|
|
185
|
+
],
|
|
186
|
+
"description": "When scoring, values of response_time_duration_ms less than the lower bound or greater than the upper bound are discarded. This array contains two numbers, the lower and upper bounds."
|
|
176
187
|
}
|
|
177
188
|
}
|
|
178
189
|
},
|
|
@@ -470,6 +481,14 @@
|
|
|
470
481
|
"format": "date-time",
|
|
471
482
|
"description": "ISO 8601 timestamp at the end of the last trial. Null if no trials were completed."
|
|
472
483
|
},
|
|
484
|
+
"response_time_filter_lower_bound": {
|
|
485
|
+
"type": "number",
|
|
486
|
+
"description": "Response times less than this lower bound were discarded when calculating filtered response times."
|
|
487
|
+
},
|
|
488
|
+
"response_time_filter_upper_bound": {
|
|
489
|
+
"type": "number",
|
|
490
|
+
"description": "Response times greater than this upper bound were discarded when calculating filtered response times."
|
|
491
|
+
},
|
|
473
492
|
"n_trials": {
|
|
474
493
|
"type": "integer",
|
|
475
494
|
"description": "Number of trials completed."
|
|
@@ -492,6 +511,233 @@
|
|
|
492
511
|
"null"
|
|
493
512
|
],
|
|
494
513
|
"description": "Participant-facing score, calculated as (number of correct trials / number of trials attempted) * 100. This is a simple metric to provide feedback to the participant. Null if no trials attempted."
|
|
514
|
+
},
|
|
515
|
+
"flag_trials_lt_expected": {
|
|
516
|
+
"type": "number",
|
|
517
|
+
"description": "Is the number of completed trials fewer than expected? 1 = true, 0 = false."
|
|
518
|
+
},
|
|
519
|
+
"flag_trials_gt_expected": {
|
|
520
|
+
"type": "number",
|
|
521
|
+
"description": "Is the number of completed trials greater than expected? 1 = true, 0 = false."
|
|
522
|
+
},
|
|
523
|
+
"n_trials_HIT": {
|
|
524
|
+
"type": "number",
|
|
525
|
+
"description": "Number of HIT trials (correctly identified a 'different' trial)"
|
|
526
|
+
},
|
|
527
|
+
"n_trials_MISS": {
|
|
528
|
+
"type": "number",
|
|
529
|
+
"description": "Number of MISS trials (failed to detect a 'different' trial, responded 'same')"
|
|
530
|
+
},
|
|
531
|
+
"n_trials_FA": {
|
|
532
|
+
"type": "number",
|
|
533
|
+
"description": "Number of False Alarm trials (incorrectly responded 'different' on a 'same' trial)"
|
|
534
|
+
},
|
|
535
|
+
"n_trials_CR": {
|
|
536
|
+
"type": "number",
|
|
537
|
+
"description": "Number of Correct Rejection trials (correctly responded 'same' on a 'same' trial)"
|
|
538
|
+
},
|
|
539
|
+
"n_trials_type_same": {
|
|
540
|
+
"type": "number",
|
|
541
|
+
"description": "Number of trials where the true signal type was 'SAME' (presented and response shapes were identical)"
|
|
542
|
+
},
|
|
543
|
+
"n_trials_type_different": {
|
|
544
|
+
"type": "number",
|
|
545
|
+
"description": "Number of trials where the true signal type was 'DIFFERENT' (response shapes differed from presented)"
|
|
546
|
+
},
|
|
547
|
+
"HIT_rate": {
|
|
548
|
+
"type": [
|
|
549
|
+
"number",
|
|
550
|
+
"null"
|
|
551
|
+
],
|
|
552
|
+
"description": "Proportion of 'different' trials correctly identified as different. Calculated as n_trials_HIT / n_trials_type_different"
|
|
553
|
+
},
|
|
554
|
+
"MISS_rate": {
|
|
555
|
+
"type": [
|
|
556
|
+
"number",
|
|
557
|
+
"null"
|
|
558
|
+
],
|
|
559
|
+
"description": "Proportion of 'different' trials incorrectly identified as same. Calculated as 1 - HIT_rate"
|
|
560
|
+
},
|
|
561
|
+
"FA_rate": {
|
|
562
|
+
"type": [
|
|
563
|
+
"number",
|
|
564
|
+
"null"
|
|
565
|
+
],
|
|
566
|
+
"description": "Proportion of 'same' trials incorrectly identified as different. Calculated as n_trials_FA / n_trials_type_same"
|
|
567
|
+
},
|
|
568
|
+
"CR_rate": {
|
|
569
|
+
"type": [
|
|
570
|
+
"number",
|
|
571
|
+
"null"
|
|
572
|
+
],
|
|
573
|
+
"description": "Proportion of 'same' trials correctly identified as same. Calculated as 1 - FA_rate"
|
|
574
|
+
},
|
|
575
|
+
"n_trials_rt_invalid": {
|
|
576
|
+
"type": "number",
|
|
577
|
+
"description": "Number of trials with null or non-positive response times (excluded from RT calculations)"
|
|
578
|
+
},
|
|
579
|
+
"median_rt_overall_valid": {
|
|
580
|
+
"type": [
|
|
581
|
+
"number",
|
|
582
|
+
"null"
|
|
583
|
+
],
|
|
584
|
+
"description": "Median response time (ms) across all trials with valid (non-null, positive) response times. No outlier filtering applied"
|
|
585
|
+
},
|
|
586
|
+
"sd_rt_overall_valid": {
|
|
587
|
+
"type": [
|
|
588
|
+
"number",
|
|
589
|
+
"null"
|
|
590
|
+
],
|
|
591
|
+
"description": "Standard deviation of response time (ms) across all trials with valid response times. No outlier filtering applied"
|
|
592
|
+
},
|
|
593
|
+
"median_rt_HIT_valid": {
|
|
594
|
+
"type": [
|
|
595
|
+
"number",
|
|
596
|
+
"null"
|
|
597
|
+
],
|
|
598
|
+
"description": "Median response time (ms) for HIT trials with valid response times. No outlier filtering"
|
|
599
|
+
},
|
|
600
|
+
"sd_rt_HIT_valid": {
|
|
601
|
+
"type": [
|
|
602
|
+
"number",
|
|
603
|
+
"null"
|
|
604
|
+
],
|
|
605
|
+
"description": "Standard deviation of response time (ms) for HIT trials with valid response times. No outlier filtering"
|
|
606
|
+
},
|
|
607
|
+
"median_rt_MISS_valid": {
|
|
608
|
+
"type": [
|
|
609
|
+
"number",
|
|
610
|
+
"null"
|
|
611
|
+
],
|
|
612
|
+
"description": "Median response time (ms) for MISS trials with valid response times. No outlier filtering"
|
|
613
|
+
},
|
|
614
|
+
"sd_rt_MISS_valid": {
|
|
615
|
+
"type": [
|
|
616
|
+
"number",
|
|
617
|
+
"null"
|
|
618
|
+
],
|
|
619
|
+
"description": "Standard deviation of response time (ms) for MISS trials with valid response times. No outlier filtering"
|
|
620
|
+
},
|
|
621
|
+
"median_rt_FA_valid": {
|
|
622
|
+
"type": [
|
|
623
|
+
"number",
|
|
624
|
+
"null"
|
|
625
|
+
],
|
|
626
|
+
"description": "Median response time (ms) for False Alarm trials with valid response times. No outlier filtering"
|
|
627
|
+
},
|
|
628
|
+
"sd_rt_FA_valid": {
|
|
629
|
+
"type": [
|
|
630
|
+
"number",
|
|
631
|
+
"null"
|
|
632
|
+
],
|
|
633
|
+
"description": "Standard deviation of response time (ms) for False Alarm trials with valid response times. No outlier filtering"
|
|
634
|
+
},
|
|
635
|
+
"median_rt_CR_valid": {
|
|
636
|
+
"type": [
|
|
637
|
+
"number",
|
|
638
|
+
"null"
|
|
639
|
+
],
|
|
640
|
+
"description": "Median response time (ms) for Correct Rejection trials with valid response times. No outlier filtering"
|
|
641
|
+
},
|
|
642
|
+
"sd_rt_CR_valid": {
|
|
643
|
+
"type": [
|
|
644
|
+
"number",
|
|
645
|
+
"null"
|
|
646
|
+
],
|
|
647
|
+
"description": "Standard deviation of response time (ms) for Correct Rejection trials with valid response times. No outlier filtering"
|
|
648
|
+
},
|
|
649
|
+
"median_rt_overall_valid_filtered": {
|
|
650
|
+
"type": [
|
|
651
|
+
"number",
|
|
652
|
+
"null"
|
|
653
|
+
],
|
|
654
|
+
"description": "Median response time (ms) across all valid trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
655
|
+
},
|
|
656
|
+
"sd_rt_overall_valid_filtered": {
|
|
657
|
+
"type": [
|
|
658
|
+
"number",
|
|
659
|
+
"null"
|
|
660
|
+
],
|
|
661
|
+
"description": "Standard deviation of response time (ms) across all valid trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
662
|
+
},
|
|
663
|
+
"n_outliers_rt_overall_valid": {
|
|
664
|
+
"type": "number",
|
|
665
|
+
"description": "Number of valid trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
666
|
+
},
|
|
667
|
+
"median_rt_HIT_valid_filtered": {
|
|
668
|
+
"type": [
|
|
669
|
+
"number",
|
|
670
|
+
"null"
|
|
671
|
+
],
|
|
672
|
+
"description": "Median response time (ms) for HIT trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
673
|
+
},
|
|
674
|
+
"sd_rt_HIT_valid_filtered": {
|
|
675
|
+
"type": [
|
|
676
|
+
"number",
|
|
677
|
+
"null"
|
|
678
|
+
],
|
|
679
|
+
"description": "Standard deviation of response time (ms) for HIT trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
680
|
+
},
|
|
681
|
+
"n_outliers_rt_HIT_valid": {
|
|
682
|
+
"type": "number",
|
|
683
|
+
"description": "Number of HIT trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
684
|
+
},
|
|
685
|
+
"median_rt_MISS_valid_filtered": {
|
|
686
|
+
"type": [
|
|
687
|
+
"number",
|
|
688
|
+
"null"
|
|
689
|
+
],
|
|
690
|
+
"description": "Median response time (ms) for MISS trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
691
|
+
},
|
|
692
|
+
"sd_rt_MISS_valid_filtered": {
|
|
693
|
+
"type": [
|
|
694
|
+
"number",
|
|
695
|
+
"null"
|
|
696
|
+
],
|
|
697
|
+
"description": "Standard deviation of response time (ms) for MISS trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
698
|
+
},
|
|
699
|
+
"n_outliers_rt_MISS_valid": {
|
|
700
|
+
"type": "number",
|
|
701
|
+
"description": "Number of MISS trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
702
|
+
},
|
|
703
|
+
"median_rt_FA_valid_filtered": {
|
|
704
|
+
"type": [
|
|
705
|
+
"number",
|
|
706
|
+
"null"
|
|
707
|
+
],
|
|
708
|
+
"description": "Median response time (ms) for False Alarm trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
709
|
+
},
|
|
710
|
+
"sd_rt_FA_valid_filtered": {
|
|
711
|
+
"type": [
|
|
712
|
+
"number",
|
|
713
|
+
"null"
|
|
714
|
+
],
|
|
715
|
+
"description": "Standard deviation of response time (ms) for False Alarm trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
716
|
+
},
|
|
717
|
+
"n_outliers_rt_FA_valid": {
|
|
718
|
+
"type": "number",
|
|
719
|
+
"description": "Number of False Alarm trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
720
|
+
},
|
|
721
|
+
"median_rt_CR_valid_filtered": {
|
|
722
|
+
"type": [
|
|
723
|
+
"number",
|
|
724
|
+
"null"
|
|
725
|
+
],
|
|
726
|
+
"description": "Median response time (ms) for Correct Rejection trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
727
|
+
},
|
|
728
|
+
"sd_rt_CR_valid_filtered": {
|
|
729
|
+
"type": [
|
|
730
|
+
"number",
|
|
731
|
+
"null"
|
|
732
|
+
],
|
|
733
|
+
"description": "Standard deviation of response time (ms) for Correct Rejection trials after removing outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
734
|
+
},
|
|
735
|
+
"n_outliers_rt_CR_valid": {
|
|
736
|
+
"type": [
|
|
737
|
+
"number",
|
|
738
|
+
"null"
|
|
739
|
+
],
|
|
740
|
+
"description": "Number of Correct Rejection trials removed as RT outliers, as specified in response_time_filter_lower_bound and response_time_filter_upper_bound."
|
|
495
741
|
}
|
|
496
742
|
}
|
|
497
743
|
}
|