Skip to content

mwmaclean/my_new_experiment

Repository files navigation

Template repository for matlab PTB project

Content

This repo is for students who want to design a new PsychToolbox(PTB) experiment using an existing script template and a library of functions.

This repo used the template from the CPP Lab developpers here. It was adapted to be used as a teaching example and includes:

.
├── dev
├── exampleScripts  # where you will find demos
│   ├── PsychExampleExperiments    
│   └── simple_demos.m
├── lib # where you will find useful functions for your experiment from the CPP Lab
│   ├── CPP_BIDS
│   ├── CPP_PTB
├── src # where you put your code
├── LICENSE  
├── README.md
├── initEnv.m # a .m file to set up your project (adds the right folder to the path)
├── mainScript.m # a .m file to be used as a template script
└── setParameters.m # a .m file to initialize your parameters and configuration variables

Ressources to help structure your code

PsychDemos that are in the exampleScripts folder here were taken from the PTB code: C:\PATH\to\PTB\toolboxPsychtoolbox\PsychDemos (change path to where you downloaded PTB)

GitHub: Search for PTB repos/scripts

Peter Scarf PTB Tutorials. The simple_demos.m in the exampleScripts folder are a compilation of some of these tutorials. You can simply run each.

Forum PTB

Bug Report

Art of readable code

Quick PTB coding tips for designing your experiment

  1. Avoid long scripts- use fonctions : it's easier to read

    • Check if you can start from available functions from CPP_PTB here
  2. Avoid 'hard coding', centralize all your parameters in a function or structure

    • Save everything in the structure (configuration: cfg) & save in a .tsv file so other softwares can read it.
  3. Use 'try-catch' in case an error/bug happens in your code

    • See example in MullerLyler demos of PTB
  4. Use a seperate file for the order of trials/conditions

    • Should be independant of your code/main script.
  5. If an error occurs, enable debug mode in MATLAB:

    • Add breakpoints & run code

How to install and use this repo

For the intro course, fork this current repo to your github account with all the files, folders and submodules. You only have to then clone the repository and you are good to go.

This repo originally comes from this template PTB experiment repository from the CPP Lab.

How to install and run

Install

git clone --recurse-submodules https://github.com/your_github_account/the_name_of_your_new_experiment.git

Set parameters in setParameters.m

Run

mainScript

Basic steps of the mainScript (template experiment)

  • Clear screen,
  • Set parameters,
  • Prompt user input,
  • Initialize PTB,
  • Display instructions,
  • Start experiment,
  • Design blocks/trials, Collect responses, Save events,
  • Goodbye screen,
  • Close.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages