Home > fmri > fsl > make_motion_evs.m

make_motion_evs

PURPOSE ^

Parses the 6 movement parameters in a .par file into separate files so that

SYNOPSIS ^

function ev_info = make_motion_evs(par_fname,outdir,outstub)

DESCRIPTION ^

 Parses the 6 movement parameters in a .par file into separate files so that
 each can be loaded as an explanatory variable (EV) in an FSL model.

 par_fname - name of the parameter file
 outdir - name of directory into which to place the EV files
 ev_info - a structure containing information about the 6 EVs. This structure
           is used by other, e.g. model building, scripts

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ev_info = make_motion_evs(par_fname,outdir,outstub)
0002 % Parses the 6 movement parameters in a .par file into separate files so that
0003 % each can be loaded as an explanatory variable (EV) in an FSL model.
0004 %
0005 % par_fname - name of the parameter file
0006 % outdir - name of directory into which to place the EV files
0007 % ev_info - a structure containing information about the 6 EVs. This structure
0008 %           is used by other, e.g. model building, scripts
0009 
0010 % 03/20/06 Petr Janata
0011 
0012 if nargin < 2
0013   outdir = '';
0014   outstub = '';
0015 end
0016 
0017 ev_info = create_ev_info;
0018 
0019 if ~exist(par_fname)
0020   fprintf('Movement parameter file <%s> does not exist\n', par_fname);
0021   return
0022 end
0023 
0024 % Load the file
0025 data = load(par_fname);
0026 
0027 ncol = size(data,2);
0028 if ncol ~= 6
0029   fprintf('Parameter file <%s> does not have 6 columns\n', par_fname);
0030   return
0031 end
0032 
0033 ev_info.set_type = 'motion';
0034 ev_info.ev_names = {'pitch','roll','yaw','trans_x','trans_y','trans_z'};
0035 ev_info.nev = 6;
0036 
0037 for icol = 1:ncol
0038   outfname = fullfile(outdir,sprintf('%s_motion_ev%d.txt', outstub,icol));
0039   tmp = data(:,icol);
0040   
0041   fprintf('Writing %s\n', outfname);
0042   save(outfname,'tmp','-ascii');  % save the actual file
0043   
0044   % copy the name of the file to the fnames field
0045   ev_info.fnames{icol} = outfname;
0046 end
0047 
0048 return
0049

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003