Dear Samantha,
On top of Cyril and Colin's excellent suggestions, here is a small
script that should create the text files you need:
% get beta image for all subjects
b = spm_select('FPListRec','/path/to/data','beta_0001.nii');
% read data (you could specify a ROI here, instead of 'all')
[Y,xY] = spm_summarise(b,'all','',true);
% keep only voxels containing data
idx = any(isnan(Y));
Y = Y(:,~idx);
XYZmm = xY.XYZmm(:,~idx);
% save data as text files
save beta.txt Y -ascii
save XYZmm.txt XYZmm -ascii
Best regards,
Guillaume.
On 14/02/17 16:13, Samantha Winter wrote:
> I'm sorry - my earlier question was incomplete!
> I have two questions about readying SPM files for running SVMs in R or
> Python:
>
> 1) Is there a way to easily extract (into a .txt file or otherwise) the
> betas from every voxel in a specified contrast? For example, if I have
> 100 participants and am interested in looking at a specific contrast for
> each participant, I would like to create a text file with each row
> corresponding to the participant and each column corresponding to a
> voxel value. Is this possible in SPM?
>
> 2) Is there a coordinate file with the MNI X, Y and Z for each voxel?
>
> Thank you!
>
> On Tue, Feb 14, 2017 at 11:12 AM, Samantha Winter <[log in to unmask]
> <mailto:[log in to unmask]>> wrote:
>
> I have two questions about readying SPM files for running SVMs in R
> or Python:
>
> 1) Is there a way to easily extract (into a .txt file or otherwise)
> the betas from every voxel in a specified contrast? For example, if
> I have 100 participants and am in
>
> 2) Is there a coordinate file with the MNI X, Y and Z for each voxel?
>
> Thank you!
>
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|