Creating a Batch process for VOI time-series extraction in SPM

Summary of what happened:

I am working on a psychophysiological analysis (PPI) where I have to extract time series data from a specified region of interest (ROI) in a particular contrast. I am using SPM to do so, I have Identified an ROI through MarsBar and created f-contrasts to be used to adjust for data option within the eigenvariate parameters.

The extraction takes a while for a single participant. I am looking for a way to create a eigenvariate time series extraction batch process to apply into a matlab code to process through all the participants I have. I can’t seem to find this option within the Batch GUI in spm12.

Does anyone know if this is an option? or will I have to manually do this process for each participant separately?


Check this link below to see if it helps.

Alternatively, use the gPPI toolbox, it don’t bother extracting the time-series on your own.

I hope this helps.

Hello Yang Xu,

I appreciate you providing some suggested instructions to follow.

I went through the wiki tutorial and pasted the .m code to a matlab script for processing through all my participant data… below:

subjects = [1:14, 16:19, 21:30, 32:43];

%generate folder and model file strings

session = ‘ses-02’;

%main directory
mri_fldr = uigetdir(,‘Select folder containing smoothed data’);

for s=1:length(subjects)

matlabbatch{1}.spm.stats.con.spmmat = {['/Users/jojomartis/Documents/PPI Study/effector_specificity/smooth/sub-'...
  sprintf('%2.2d', subjects(s)) filesep session filesep '1st-level_event_mc' filesep 'SPM.mat']};
matlabbatch{1}.spm.util.voi.adjust = 7;
matlabbatch{1}.spm.util.voi.session = 1;
matlabbatch{1} = 'voi_ips';
matlabbatch{1}.spm.util.voi.roi{1}.spm.spmmat = {[mri_fldr filesep sprintf('sub-%2.2d', subjects(s)) filesep session filesep '1st-level_event_mc' filesep 'SPM.mat']};
matlabbatch{1}.spm.util.voi.roi{1}.spm.contrast = 4;
matlabbatch{1}.spm.util.voi.roi{1}.spm.conjunction = 1;
matlabbatch{1}.spm.util.voi.roi{1}.spm.threshdesc = 'none';
matlabbatch{1}.spm.util.voi.roi{1}.spm.thresh = 0.001;
matlabbatch{1}.spm.util.voi.roi{1}.spm.extent = 0;
matlabbatch{1}.spm.util.voi.roi{1}.spm.mask = struct('contrast', {}, 'thresh', {}, 'mtype', {});
matlabbatch{1}.spm.util.voi.roi{2}.sphere.centre = [-32 -64 52];
matlabbatch{1}.spm.util.voi.roi{2}.sphere.radius = 10;
matlabbatch{1}.spm.util.voi.roi{2}.sphere.move.fixed = 1;
matlabbatch{1}.spm.util.voi.roi{3}.sphere.centre = [0 0 0];
matlabbatch{1}.spm.util.voi.roi{3}.sphere.radius = 6;
matlabbatch{1}.spm.util.voi.roi{3} = 1;
matlabbatch{1}.spm.util.voi.roi{3} = 'i2';
matlabbatch{1}.spm.util.voi.expression = 'i1 & i3';

%% run the jobs
spm('defaults', 'FMRI');
spm_jobman('run', matlabbatch);


though i think there may be an issue with my set path becasue the command window says the spm file is not names?

Contrasts folder : ./ses-02/1st-level_event_mc
Completed : 08:15:53 - 06/11/2023
06-Nov-2023 08:15:53 - Done ‘Contrast Manager’
06-Nov-2023 08:15:53 - Done

Item spm: No field(s) named

Also, when running this batch on a single subject, I see .nii files being created but not .mat for the time series extraction needed for PPI analysis.

Do you have any suggestions on why this may be the case?

Also, you referred to gPPI toolbox, is this a separate function then the PPI button on the initial SPM GUI? If it’s an additional installation, can you please share where I can find this?

Thank you.

As a follow-up,

I figured out the issue was with variables being assigned to paths from a different computer so once I cycled through all the iterations of incorrect paths and replaced it with my own, i was able to run the batch script for time-extraction.