Home > database > ensemble_pathdata.m

ensemble_pathdata

PURPOSE ^

returns an ensemble pathdata struct, given defs.paths and defs.sinfo

SYNOPSIS ^

function outdata = ensemble_pathdata(indata,defs)

DESCRIPTION ^

 returns an ensemble pathdata struct, given defs.paths and defs.sinfo
 
   outdata = ensemble_pathdata({},defs)
 
 REQUIRES
   indata - empty cell array
   defs.paths - a structure containing path data
   defs.sinfo - a structure containing subject information
 
 FB 2011.04.29

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function outdata = ensemble_pathdata(indata,defs)
0002 
0003 % returns an ensemble pathdata struct, given defs.paths and defs.sinfo
0004 %
0005 %   outdata = ensemble_pathdata({},defs)
0006 %
0007 % REQUIRES
0008 %   indata - empty cell array
0009 %   defs.paths - a structure containing path data
0010 %   defs.sinfo - a structure containing subject information
0011 %
0012 % FB 2011.04.29
0013 
0014 %% init outdata
0015 outdata = ensemble_init_data_struct();
0016 outdata.type = 'paths';
0017 outdata.vars = {'subject_id','session','run','path_type','path'};
0018 pathcol = set_var_col_const(outdata.vars);
0019 outdata.data{pathcol.subject_id} = {};
0020 outdata.data{pathcol.session} = {};
0021 outdata.data{pathcol.run} = [];
0022 outdata.data{pathcol.path_type} = {};
0023 outdata.data{pathcol.path} = {};
0024 
0025 %% iterate over subjects
0026 nsub = length(defs.sinfo);
0027 for k=1:nsub
0028   subid = defs.sinfo(k).id;
0029   
0030   % Deal with directory infrastructure
0031   sub_indir = fullfile(defs.paths.inroot, subid);
0032   sub_outdir = fullfile(defs.paths.outroot, subid);
0033   check_dir(sub_outdir,1);
0034     
0035   % save paths to the path output data structure
0036   % subject source file directory
0037   outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0038       'session',{''},'run',0,'path_type','sub_indir','path',sub_indir);
0039     
0040   % subject destination file directory (often the same as the source)
0041   outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0042       'session',{''},'run',0,'path_type','sub_outdir','path',sub_outdir);
0043 
0044   nsess = length(defs.sinfo(k).sessinfo);
0045   for is=1:nsess
0046     sessid = defs.sinfo(k).sessinfo(is).id;
0047     
0048     % define paths
0049     sess_indir = fullfile(sub_indir,sessid);
0050     sess_outdir = fullfile(sub_outdir,sessid);
0051     behav_indir = fullfile(sess_indir,'behavior');
0052     behav_outdir = fullfile(sess_outdir,'behavior');
0053     physio_indir = fullfile(sess_indir,'physio');
0054     physio_outdir = fullfile(sess_outdir,'physio');
0055     
0056     % check paths
0057     check_dir(sess_indir,1);
0058     check_dir(sess_outdir,1);
0059     check_dir(behav_indir,1);
0060     check_dir(behav_outdir,1);
0061     check_dir(physio_indir,1);
0062     check_dir(physio_outdir,1);
0063   
0064     % save paths
0065     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0066         'session',sessid,'run',0,'path_type','sess_indir',...
0067         'path',sess_indir);
0068     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0069         'session',sessid,'run',0,'path_type','sess_outdir',...
0070         'path',sess_outdir);
0071     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0072         'session',sessid,'run',0,'path_type','behav_indir',...
0073         'path',behav_indir);
0074     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0075         'session',sessid,'run',0,'path_type','behav_outdir',...
0076         'path',behav_outdir);
0077     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0078         'session',sessid,'run',0,'path_type','physio_indir',...
0079         'path',physio_indir);
0080     outdata = ensemble_add_data_struct_row(outdata,'subject_id',subid,...
0081         'session',sessid,'run',0,'path_type','physio_outdir',...
0082         'path',physio_outdir);
0083   end % for is=1:nsess
0084 end % for k=1:nsub

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