compileprofile-spacetests
v0.3.0
Published
A package for evaluating cognitive test results from
Maintainers
Readme
compileprofile-spacetests
A package for evaluating cognitive test results from "Vzhuru do vesmiru" (To Space) cognitive testing platform. This package analyzes performance data from four different cognitive tests: N-back memory tests, spatial cognition tests, Go/No-Go response inhibition tests, and emotion recognition tests.
Installation
npm install compileprofile-spacetestsUsage
import {
NbackResults,
SpatialCognitionResults,
GonogoResults,
EmotionResults
} from 'compileprofile-spacetests';
// Analyze N-back memory test
const nbackResults = NbackResults(nbackData);
// Analyze spatial cognition test
const spatialResults = SpatialCognitionResults(spatialData);
// Analyze Go/No-Go test
const gonogoResults = GonogoResults(gonogoData);
// Analyze emotion recognition test
const emotionResults = EmotionResults(emotionData);Test Results
All cognitive tests return results in two parts: common metrics (same for all tests) and special metrics (specific to each test type).
Common Metrics (All Tests)
Every test provides these basic performance measures:
- n_trials - Total number of test trials completed
- n_correct_trials - How many responses were correct
- n_incorrect_trials - How many responses were wrong
- avg_rt_total - Average reaction time across all trials (milliseconds)
- avg_rt_correct - Average reaction time for correct answers only
- avg_rt_incorrect - Average reaction time for wrong answers only
- performance_score - Overall performance score (0-100, higher is better)
Special Metrics by Test Type
N-back Memory Test
Analyzes working memory by comparing performance on different trial types:
- target_trials - Performance when participant should respond (saw matching stimulus)
- Number of target trials, average reaction time, accuracy rate
- non_target_trials - Performance when participant should not respond
- Number of non-target trials, average reaction time, accuracy rate
Spatial Cognition Test
Analyzes spatial reasoning by breaking down performance across map characteristics:
- by_distance - Performance grouped by how far the destination is (1, 2, 3 units)
- by_angle - Performance grouped by map rotation angle (90°, 180°, 270°)
- by_rotation - Performance grouped by how much the view was rotated
Each group shows number of trials, average reaction time, and accuracy rate.
Go/No-Go Response Inhibition Test
Analyzes impulse control by examining when to respond vs. when to inhibit:
- by_block - Performance in each test phase (blocks 1-4 have different rules)
- go_trials - Trials where participant should press the button
- Number of trials, average reaction time, accuracy rate
- nogo_trials - Trials where participant should NOT press the button
- Number of trials, average reaction time, accuracy rate
Emotion Recognition Test
Analyzes emotion processing by examining recognition patterns:
- by_emotion - Performance for each emotion type (neutral, sad, happy, surprised, angry)
- For each emotion: number of trials, average reaction time, accuracy rate
- confusion_matrix - Shows which emotions get confused with which others
- Rows = actual emotion, columns = what participant guessed
Performance Scoring
Each test uses a specific algorithm to calculate the performance score (0-100):
- N-back: Raw accuracy percentage
- Spatial Cognition: RT/(accuracy) formula with 1000-10000ms bounds
- Go/No-Go: RT/(accuracy^5) formula with 300-5000ms bounds
- Emotions: RT/(accuracy^5) formula with 1000-10000ms bounds
Input Data Format
Each test expects an array of trial objects with specific fields:
N-back Test Data
Each trial object should have:
- is_target -
trueif participant should respond,falseif they shouldn't - rt - Reaction time in milliseconds
- correct -
trueif response was correct,falseif wrong - response - What the participant pressed (0 or 1, or null if no response)
Spatial Cognition Test Data
Each trial object should have:
- stimulus - HTML image tag containing the map image
- rt - Reaction time in milliseconds
- response - Direction chosen (0 = left, 1 = right)
Go/No-Go Test Data
Each trial object should have:
- image - URL to the stimulus image (astronaut, alien, or rocket)
- rt - Reaction time in milliseconds
- response - Button press (any number = pressed, null = no press)
- block_number - Which test phase (1, 2, 3, or 4)
Emotion Recognition Test Data
Each trial object should have:
- emotion - URL to the emotion face image
- rt - Reaction time in milliseconds
- response - Emotion chosen (0=neutral, 1=sad, 2=happy, 3=surprised, 4=angry)
Development
Build the package:
npm run build # Build both CommonJS and ESM
npm run build:cjs # Build CommonJS only
npm run build:esm # Build ESM onlyRun tests:
npm test # Run all tests
npm test -- emotions.test.ts # Run specific test file