Doxygen Source Code Documentation
ContrastTest.m
Go to the documentation of this file.00001 function [err,contrfile] = ContrastTest (N_runs, polort, N_basis, Task, N_tasks, N_contr, El, N_base)
00002 %
00003 % [err,] = ContrastTest ()
00004 %
00005 %Purpose:
00006 % Construct the contrast test matrix used in -glt option of 3dDeconvolve.
00007 %
00008 %
00009 %Input Parameters:
00010 %
00011 %
00012 %
00013 %Output Parameters:
00014 % err : 0 No Problem
00015 % : 1 Problems
00016 %
00017 %
00018 %
00019 %Key Terms:
00020 %
00021 %More Info :
00022 %
00023 %
00024 %
00025 %
00026 % Author : Gang Chen
00027 % Date : Tue Jul 29 13:01:05 EDT 2003
00028 % SSCC/NIMH/ National Institutes of Health, Bethesda Maryland
00029
00030
00031 %Define the function name for easy referencing
00032 FuncName = 'ContrastTest';
00033
00034 %Debug Flag
00035 DBG = 1;
00036
00037 %initailize return variables
00038 err = 1;
00039
00040 %Create a matrix so that 3dDeconvolve uses for regressor test.
00041
00042 length = (polort+1)*N_runs+N_base;
00043 for (iT = 1:1:N_tasks),
00044 for (j = 1:1:N_basis) ,
00045 length = length + (Task(iT).BasisOpt_struct(j).maxlag - Task(iT).BasisOpt_struct(j).minlag + 1);
00046 end
00047 end
00048
00049 %mtrx = zeros(N_contr, (polort+1)*N_runs+N_basis*N_tasks); %for each run, there are (polort+1) paramters in the baseline model
00050
00051 mtrx = zeros(N_contr, length);
00052 fprintf(1, '\n\nYour contrast vectors for -glt options are:\n');
00053
00054 for (i = 1:1:N_contr),
00055 for (j = 1:1:El(i).cnt),
00056 for (k = 1:1:N_tasks),
00057 if El(i).order(j) == k,
00058 for (m=1:1:N_basis),
00059 for (p = 1:1:Task(k).BasisOpt_struct(m).maxlag - Task(k).BasisOpt_struct(m).minlag + 1)
00060 % mtrx(i,m+(k-1)*N_basis+(polort+1)*N_runs) = El(i).sign(j);
00061 mtrx(i,p+(m-1)*(Task(k).BasisOpt_struct(m).maxlag - Task(k).BasisOpt_struct(m).minlag + 1)...
00062 +(k-1)*(Task(k).BasisOpt_struct(m).maxlag - Task(k).BasisOpt_struct(m).minlag + 1)*N_basis...
00063 +(polort+1)*N_runs) = El(i).sign(j); %Don't ask me how I worked this out. It is so tedious and nasty
00064 %to housekeep the indices.
00065 %Don't even remember how I figured it out now
00066 end
00067 end
00068 end
00069 end
00070 end
00071 contrfile(i).name = sprintf('%s_contr.1D',El(i).labels);
00072 fid = fopen(contrfile(i).name, 'w');
00073 fprintf(1,'No. %i contrast vector = ', i);
00074 for (n = 1:1:length),
00075 fprintf(1, '%g ', mtrx(i,n));
00076 fprintf(fid, '%g ', mtrx(i,n));
00077 end
00078 fprintf(1, '\n');
00079 fclose(fid);
00080 fprintf(1, '\nThe vector for No. %i contrast is stored in file %s. \n\n', i, contrfile(i).name);
00081 end
00082
00083 err = 0;
00084 return;