Creating Your First Cognitive Task

Now that you're familiar with Cognition's basics, let's dive deeper and create your first cognitive task. This guide will focus on developing a task from scratch using the online code editor, offering a hands-on introduction to the platform.

1. Initiating a New Task

Starting a new task is simple:

  • From your Cognition dashboard, click on "+New task".

  • Enter a name for your task.

  • Save your entry. This action will create a placeholder for your task.

2. Accessing the Code Editor

Your new task is empty at this point. Let’s bring it to life:

  • Click on "Source code" to open the online code editor. This is where the magic happens.

3. Crafting Your Task

Instead of diving into code immediately, we'll utilize a tried-and-true example from the official JsPsych website:

const jsPsych = initJsPsych();

const hello_trial = {
  type: jsPsychHtmlKeyboardResponse,
  stimulus: 'Hello world!'
  • Return to the Cognition code editor and paste the code.

4. Live Preview and Auto-save

As you work in the code editor:

  • The embedded live preview will dynamically update, providing real-time feedback on your task's appearance and functionality.

  • Rest easy knowing the editor auto-saves your code, ensuring your progress is preserved.

5. Enhancing Task Flexibility

While our simple "Hello World" task doesn't require additional stimuli or third-party libraries, understanding how to add them is crucial for more complex experiments:

  • Uploading stimuli or third-party libraries (both CSS and JS) can significantly enhance your task's functionality and aesthetics.

  • For now, just remember this feature when you progress to more intricate tasks.

6. Testing Your Task

With your task coded, it’s time to see it in action:

  • Return to your Cognition dashboard.

  • Every task you create has a unique URL. Click on this URL to run your task.

  • Complete the task as a participant would.

7. Accessing Your Data

After completing a run:

  • The data generated will be stored on the platform.

  • Access and download this data directly from your dashboard.

In summary, creating a cognitive task in Cognition is straightforward. With tools like the online code editor, live preview, and the ability to integrate complex stimuli and libraries, your experimental potential is vast. While this guide covered task creation from scratch, remember that Cognition also supports importing tasks from GitHub—a topic we'll delve into in future tutorials. Until then, enjoy experimenting!

Last updated