Skip to content
CARP Docs
Ask AISystemLightDark
On this page

Cognitive tests

Add the 14 Cognition Package tests to a study and sample sensors while the participant does them.

Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor

Add cognitive tests from cognition_package to a study, alone or mixed with survey steps. Each test is a Research Package activity step. It runs in an RPAppTask like any other step, and its result ends up in the same survey measurement.

Choose a test

Every test extends RPActivityStep and takes a required identifier. includeInstructions (default true) shows the test's own instruction screen, and includeResults (default true) shows its result screen. The other parameters configure the test:

ClassTestWhat the participant doesParameters and defaults
RPContinuousVisualTrackingActivityMultiple object trackingFollows the target dots while they move, then taps themlengthOfTest: 90 (s), numberOfTests: 3, amountOfDots: 5, amountOfTargets: 2, dotSize: 100 (pixels), trackingSpeed: Duration(seconds: 5) (per move)
RPCorsiBlockTappingActivityCorsi block tappingTaps highlighted tiles in the same order, with more tiles in each roundNone
RPWordRecallActivityVerbal recognition memoryListens to a list of words, then writes the words recalledlengthOfTest: 90 (s), numberOfTests: 3
RPDelayedRecallActivityDelayed recallWrites the words heard in an earlier verbal recognition memory testlengthOfTest: 90 (s), numberOfTests: 3
RPFlankerActivityFlankerSwipes cards in the direction of the middle arrowlengthOfTest: 90 (s), numberOfCards: 25
RPLetterTappingActivityLetter tappingTaps a button whenever the letter A is spokenNone
RPPairedAssociatesLearningActivityPaired associates learningWatches figures appear under six tiles, then taps the tile that matches the figure in the middlemaxTestDuration: 100 (s)
RPPictureSequenceMemoryActivityPicture sequence memoryMemorizes the positions of pictures and drags them back after they movelengthOfTest: 90 (s), numberOfTests: 3, numberOfPics: 3
RPRapidVisualInfoProcessingActivityRapid visual information processingTaps a button when a target sequence of three digits appears in a stream of digitsinterval: 9, lengthOfTest: 90 (s), sequence: [3, 6, 9]
RPReactionTimeActivityReaction timeTaps the screen as fast as possible when it turns from blue to yellowlengthOfTest: 30 (s), switchInterval: 4 (the change comes after a random 1–4 s)
RPStroopEffectActivityStroop effectTaps the box that names the color of the word on screenlengthOfTest: 40 (s), displayTime: 1000 (ms), delayTime: 750 (ms)
RPTappingActivityFinger tappingTaps two buttons as often as possible with the index and middle fingerlengthOfTest: 30 (s)
RPTrailMakingActivityTrail makingConnects numbered boxes in order, or alternates numbers and letters with TrailType.BtrailType: TrailType.A
RPVisualArrayChangeActivityVisual array changeMemorizes the colors of shapes and tells whether any color changednumberOfShapes: 3, lengthOfTest: 90 (s), waitTime: 2 (s), numberOfTests: 3

Add tests to a study

Import research_package and cognition_package, put the tests in a task and wrap it in an RPAppTask of type AppTask.COGNITIVE_ASSESSMENT_TYPE:

import 'package:research_package/research_package.dart';
import 'package:cognition_package/cognition_package.dart';

final attentionTests = RPOrderedTask(
  identifier: 'attention_tests',
  steps: [
    RPInstructionStep(
      identifier: 'attention_intro',
      title: 'Attention tests',
      text: 'Two short tests. Sit down and hold the phone in one hand.',
    ),
    RPFlankerActivity(identifier: 'flanker', lengthOfTest: 60),
    RPStroopEffectActivity(identifier: 'stroop'),
    RPCompletionStep(
      identifier: 'attention_done',
      title: 'Done',
      text: 'Thank you for completing the tests.',
    ),
  ],
);

protocol.addTaskControl(
  RecurrentScheduledTrigger(
    type: RecurrentType.weekly,
    dayOfWeek: DateTime.saturday,
    time: const TimeOfDay(hour: 10),
  ),
  RPAppTask(
    type: AppTask.COGNITIVE_ASSESSMENT_TYPE,
    name: 'Attention tests',
    title: 'Attention tests',
    description: 'Two short tests, about four minutes',
    minutesToComplete: 4,
    notification: true,
    rpTask: attentionTests,
  ),
  phone,
);

The type only names the completed app task measurement, dk.cachet.carp.completedapptask.cognition; the tests also run in a task of type AppTask.SURVEY_TYPE. Each test shows its own instructions, so the instruction step is optional.

Use RPDelayedRecallActivity only after an RPWordRecallActivity: it asks for the words that the participant heard in that test. Both tests use the same five words in every run.

Sample sensors during a test

Add measures to the RPAppTask to sample them while the participant does the task. This tremor and tapping test records the accelerometer and gyroscope:

protocol.addTaskControl(
  RecurrentScheduledTrigger(
    type: RecurrentType.daily,
    time: const TimeOfDay(hour: 18),
  ),
  RPAppTask(
    type: AppTask.COGNITIVE_ASSESSMENT_TYPE,
    name: 'Tremor and tapping',
    title: 'Tremor and tapping test',
    description: 'Hold the phone still, then tap as fast as you can',
    minutesToComplete: 2,
    notification: true,
    measures: [
      Measure(type: SensorSamplingPackage.ACCELERATION),
      Measure(type: SensorSamplingPackage.ROTATION),
    ],
    rpTask: RPOrderedTask(
      identifier: 'tremor_tapping',
      steps: [
        RPTimerStep(
          identifier: 'tremor_hold',
          title: 'Stand up and hold the phone in your outstretched hand.',
          timeout: const Duration(seconds: 10),
          playSound: true,
        ),
        RPTappingActivity(identifier: 'tapping', lengthOfTest: 20),
        RPCompletionStep(
          identifier: 'tremor_done',
          title: 'Done',
          text: 'Thank you.',
        ),
      ],
    ),
  ),
  phone,
);

The measures start when your app calls onStart() on the task and pause when the participant submits or leaves it. They are stored as ordinary measurements of their own types, so match them to the test by time. The timer step plays its sound after 10 seconds only if the app ships the sound file; see Add optional assets.

Read the test results

Each test adds an RPActivityResult to the task result, under the test's identifier. The test's values are in its results map under the key result, and the keys of these values contain spaces and capitals exactly as listed:

ClassKeys in result
RPContinuousVisualTrackingActivitymistakes, times, score
RPCorsiBlockTappingActivityNone: the value is the Corsi span as a number
RPWordRecallActivitywordlist, resultlist1, resultlist2, times taken, score
RPDelayedRecallActivitywordlist delayed, resultlist3, time taken, score
RPFlankerActivitywrong swipes, right swipes, time, score, meanCongruent, meanIncongruent, numberCardsCongruent, numberCardsIncongruent
RPLetterTappingActivityamount of errors, score
RPPairedAssociatesLearningActivitysuccesses, mistakes
RPPictureSequenceMemoryActivityAmount of moves, Amount of correct pairs, Time taken to memorize, Time taken to move pictures, score
RPRapidVisualInfoProcessingActivityCorrect taps, incorrect taps, passed sequences, Delay on correct taps
RPReactionTimeActivityavg. reaction time (ms), Wrong taps, Correct taps
RPStroopEffectActivitymistakes, correct taps
RPTappingActivityTotal taps
RPTrailMakingActivityCompletion time, score
RPVisualArrayChangeActivityWrong guesses, Right guesses, Time taken to memorize, Time taken to guess, score

Three tests store a different value in some cases:

  • Paired associates learning: stores successes and mistakes when maxTestDuration ends the test, and the number 0 when the participant completes every level first.
  • Picture sequence memory and Visual array change: replace the value with a single Correct swipes key when lengthOfTest passes before the participant leaves the test.

Next to result, the activity result holds stepTimes and interactions. stepTimes records when the instruction and test phases start and end and when the result screen appears, as far as each test logs them. interactions holds one entry for each interaction that the test logs, such as a tap or a drawn path.

See Step results for the fields and an example.

Translate the tests

Cognition Package ships its texts in Danish, English, French and Portuguese. To add CPLocalizations.delegate to the app, see Translate the survey. The spoken letters and words of the Letter tapping and Word recall tests are in English only.

Copyright

The tests may be subject to different copyright terms. Check that you may use each test in your study, and get permission from the copyright holder where needed.

The Cognition Package README names these copyright holders:

TestCopyright
Multiple object tracking, Flanker, Reaction time, Stroop effect, Finger tapping, Visual array changeCopenhagen Center for Health Technology (CACHET), under the package's MIT license
Corsi block tappingPsyToolkit
Verbal recognition memory, Delayed recall, Letter tappingMontreal Cognitive Assessment (MoCA)
Paired associates learning, Rapid visual information processingCambridge Cognition Ltd
Picture sequence memoryNIH Toolbox Cognition Battery (NIHTB-CB)
Trail makingPublic domain

Quick links

Page · DocumentationCARP DocumentationPage · DocumentationIntroductionPage · DocumentationQuickstartPage · DocumentationTerminologyPage · DocumentationArchitecture