User Tools

Site Tools


processing_stream_-_scripted

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
processing_stream_-_scripted [2010/06/09 20:45] jochenprocessing_stream_-_scripted [2010/06/09 21:09] – added link/reference to MDM::ComputeGLM jochen
Line 168: Line 168:
     end     end
 end</code> end</code>
 +
 +===== Semi-automatic logfile parsing and PRT creation =====
 +The onsets have supposedly already been transformed into a tabular structure (e.g. in Microsoft Excel), so that they look like this:
 +
 +<file>SUBJ_ID INST_on CUE1_on CUE2_on INST_of CUE1_of CUE2_of
 +20216 3 nan nan 5003 nan nan
 +20216 nan 3003 nan nan 18003 nan
 +20216 18000 nan nan 23000 nan nan
 +20216 nan nan 21000 nan nan 26000
 +20216 74057 nan nan 79057 nan nan
 +20216 nan 77057 nan nan 92057 nan
 +20216 92068 nan nan 97068 nan nan
 +20216 nan nan 95067 nan nan 100067
 +20216 148112 nan nan 153112 nan nan
 +20216 nan 151112 nan nan 166112 nan
 +20216 166122 nan nan 171122 nan nan
 +20216 nan nan 169122 nan nan 174122
 +20216 1 nan nan 5001 nan nan
 +20216 nan 3001 nan nan 18001 nan
 +20216 17999 nan nan 22999 nan nan
 +20216 nan nan 21011 nan nan 26011
 +20216 74056 nan nan 79056 nan nan
 +20216 nan 77056 nan nan 92056 nan
 +20216 92066 nan nan 97066 nan nan
 +20216 nan nan 95065 nan nan 100065
 +20216 148110 nan nan 153110 nan nan
 +20216 nan 151110 nan nan 166110 nan
 +20216 166120 nan nan 171120 nan nan
 +20216 nan nan 169120 nan nan 174120 </file>
 +
 +In this table, the first column codes for the subject ID (which is used to detect when next subject occurs, in this sample there is only one subject!). The next three columns code the onset and the final three columns the offset of the three conditions used in this experiment (INST = Instruction, CUE1 = cue type 1, CUE2 = cue type 2).
 +
 +The following script will then create a set of PRT files out of this table (which can be copied into Matlab):
 +
 +<code matlab SCANUnit_CPU_prtfromtable.m>% make sure the onset table is available in variable ot !!
 +
 +% configuration
 +conds = {'INST', 'CUE1', 'CUE2'};
 +condcol = [255, 0, 0; 0, 255, 0; 0, 0, 255];
 +
 +% find unique subject IDs
 +subjid = unique(ot(:, 1));
 +
 +% for each subject ID
 +for sc = 1:numel(subjid)
 +
 +    % get this subject's sub-table
 +    sot = ot(ot(:, 1) == subjid(sc), :);
 +    
 +    % set NaNs to zero (for now)
 +    sot(isnan(sot)) = 0;
 +    
 +    % get onsets and offsets of any trial
 +    onsets = sum(sot(:, 2:2+numel(conds)-1), 2);
 +    
 +    % get table with NaNs (again) for condition detection
 +    sot = ot(ot(:, 1) == subjid(sc), :);
 +    
 +    % find run-separators
 +    runseps = 1 + [0; find(diff(onsets) < 0)];
 +    runseps(end+1) = numel(onsets) + 1;
 +    
 +    % for each run
 +    for rc = 1:numel(runseps)-1
 +    
 +        % get part of table we need
 +        rot = sot(runseps(rc):runseps(rc+1)-1, 2:end);
 +        
 +        % create new PRT
 +        prt = xff('new:prt');
 +        
 +        % for each condition
 +        for cc = 1:numel(conds)
 +        
 +            % add to PRT
 +            prt.AddCond(conds{cc}, rot(~isnan(rot(:, cc)), [cc, cc + numel(conds)]), condcol(cc, :));
 +        end
 +        
 +        % save PRT
 +        prt.SaveAs(sprintf('%d_%d.prt', subjid(sc), rc));
 +        
 +        % clear object
 +        prt.ClearObject;
 +    end
 +end</code>
 +
 +**Note: the PRT files will be written into the present working directory (unless the SaveAs line is appropriately altered), and they need to be moved or copied into their respective subject's folder!**
 +
 +===== Computing an RFX-GLM with VTCs and PRTs =====
 +Once all files are in place, the Protocol and VTC files can be used to compute an RFX-GLM. Please follow the instructions given in the example of the [[mdm.ComputeGLM]] method reference page.
processing_stream_-_scripted.txt · Last modified: 2010/06/17 19:42 by jochen