GetRunOrder: Difference between revisions

From CCN Wiki
Jump to navigation Jump to search
(Created page with "In the event that participants were run on several stimulus lists presented in a non-sequential order that has been since forgotten, the MATLAB function getRunOrder.m can reco...")
 
No edit summary
 
Line 1: Line 1:
In the event that participants were run on several stimulus lists presented in a non-sequential order that has been since forgotten, the MATLAB function getRunOrder.m can recover the order in which a set of experimental data .mat files were created, based on the timestamp field. This sequence it returned in the generated report value.
In the event that participants were run on several stimulus lists presented in a non-sequential order that has been since forgotten, the MATLAB function getRunOrder.m can recover the order in which a set of experimental data .mat files were created based on the timestamp field. This sequence it returned in the generated report value.


  function report=getRunOrder(matfiles)
  function report=getRunOrder(matfiles)

Latest revision as of 15:54, 29 September 2016

In the event that participants were run on several stimulus lists presented in a non-sequential order that has been since forgotten, the MATLAB function getRunOrder.m can recover the order in which a set of experimental data .mat files were created based on the timestamp field. This sequence it returned in the generated report value.

function report=getRunOrder(matfiles)
%Ensure that we know the names of the files to open
if(~exist('matfiles', 'var') || isempty(matfiles))
   [FileName,PathName,~] = uigetfile('*.mat', 'Select a .mat data file','MultiSelect', 'on');
   matfiles=fullfile(PathName, FileName);
end
datafiles=cellfun(@(x) load(x), matfiles);

timestamps=cell(1,length(datafiles));

%for each of the data files
for i=1:length(datafiles)
   d=datafiles(i); %open each data file
   timestamps{i}=d.expinfo.starttime; %extract the start timestamp

%determine which stim list matches the stims appearing in the data file
end
[sorted,tsidx]=sort(todatenum(cdfepoch(timestamps)));
%after sorting the timestamps, tsidx has the order in which the datafiles
%were generated. Can be used to report the filenames in sorted order:
%matfiles(tsidx)
report.matfiles=matfiles(tsidx)';
report.timestamps=timestamps';
end