Mind Reading

From CCN Wiki
Jump to navigation Jump to search

Determine Targets

Classifying Task vs Baseline Blocks

If the goal is simply to distinguish task block from rest periods, use findBlockBoundaries as follows:

sample_rate=2.047; %an fMRI study, with a TR=2.047 seconds
b=findBlockBoundaries([], sample_rate);
schedule=zeros(1,b(end)); %1 zero for each volume -- default=baseline
for block=1:size(b,1)
 schedule(b(block,1):b(block,2))=1; %block volumes get a '1'
end

Classifying Task Blocks

If blocks are associated with different tasks or conditions to be classified, the schedule vector, schedule can be created similarly, but with some modification. Here's some examples.

TR=2.047; %the fMRI TR is 2.047 seconds in this example
t=cell2mat({expinfo.data.timestamp});
vols=floor(t/TR)+1; %convert the timestamps into volume numbers
cond=double(cell2mat({expinfo.data.conditon})); %what condition is each trial? 
%p.s., note the typo on "conditon"
b=double(cell2mat({expinfo.data.block})); %what block is each trial? 
bnums=unique(b); %what are the different blocks?
lookup=[0,1;0,2]; %condition codes that make up each block condition
bcodes=[1,2];%code assigned to each block condition
schedule=zeros(1,vols(end));%blank schedule preallocated for each volume

%%This loop will iterate through all the numbered blocks and use the lookup
%%table to determine which block code to assign each block, depending on
%%the individual trial conditions present in that block.
%%Then, all individual volumes that belong to that block will get assigned
%%that condition code. Anything not assigned a block code will remain '0'
%%(or 'rest'/'baseline')
for i=1:length(bnums)
   idx=find(b==bnums(i));%get indices of current block
   codes=unique(cond(idx));%what conditions are represented in this block?
   blockcondition=bcodes(ismember(lookup, codes, 'rows'));%lookup the blockcode (in bcodes) that matches the conditions in this block
   firstvol=vols(idx(1));
   lastvol=vols(idx(end));
   schedule(firstvol:lastvol)=blockcondition;
end

Match Targets to Inputs

Input values will come from time series data, imported and scaled as described here. If any volumes have been discarded from the input time series, the same volumes will need to be deleted from the schedule of targets. Assuming we have a schedule and a set of inputs for a single run, we need to match each input vector to the corresponding condition in the schedule vector. This will use a Matlab function.