For each level of analysis (preprocessing,1st level, 2nd level) the main scripts calls sub-scripts that has the code specific for each step of analysis. The scripts require a certain folder structure to run. You can either structure your folder similarly, or change the paths in the scripts.
This is how the folder are structured in my analysis:
The vector_files folder has the .mat files that has the onset and duration information for each subject. I extracted this information from the PsychoPy logfiles using a custom Python script I developed (which will be subject to another post), and used another MATLAB script to convert them to .mat files.
I have the following files in the "scripts" folder.
You will need to change some of the parameters in the code to make these work for your data. You might also need to use functions other than the ones used here. One way to easily create the syntax for the specific type of processing you do is to first create a batch (e.g., for one subject) and then use the "File -> Save batch and script" function in the SPM batch window. Then, you can dig into the script created by SPM and adapt parts of it for your script. I created a considerable portion of these scripts by first creating a sample batch that characterizes the analysis I want to run and then saving the script for the batch, and using parts of it.
You can download the script files from the links at the bottom of the post. I also posted them for easy viewing here.
If you run into any problems or have any questions, please feel free to post comments below. Good luck!