Let’s say, just hypothetically, that you built a first-level analysis pipeline in FSL but are then find you need to run SPM code on it. You might wish there was a way to easily convert your design in to an SPM readable format. Here are a few notes on that process, along with a python script to actually output a timing.mat file:
Inputting 4d data
If you are used to working with FSL, you are probably using 4d .nii files. Fortunately, SPM8 can open these (my understanding is that this didn’t used to be the case). BUT you have to specify which volumes of the files you want to examine. So if your scan selection says ‘Run1.nii,1’ - that means you’ve only selected the first volume. Your batch is going to fail with ‘Cell contents reference from a non-cell array object.’ which might, hypothetically, cause you to spend a few days wondering what is wrong with your timing file. That would be frustrating.
Instead, what you need to do is change the window that reads ‘1’ under the filter box in the file selection window to 1:999, like so:
You will see all the volumes appear in the list. Select them all and press ‘Done’. Now you are ready to go!
Adding your timings
So, using the GUI, you can enter your conditions with names, onsets, and durations as separate vectors, but that’s annoying. You can also specify a .mat file containing three cell arrays with those values, which is less annoying but you still have to transcribe from your carefully produced three column FSL event file. If only you had a script to do that for you…
Here is that script:
To use this, just run this from the command line:
It will create a file ‘output.m’ in the working directory. You need to run this script within matlab and then save the resulting cell matrices as a .mat file, then input that file in matlab.