Back to the main page.

Bug 55 - speed up read_event for realtime reading from CTF shm

Status CLOSED WONTFIX
Reported 2010-03-17 09:40:00 +0100
Modified 2011-01-05 12:01:07 +0100
Product: FieldTrip
Component: forward
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2010-03-17 09:40:01 +0100

reading triggers from shm takes a lot of time in the following section, which can be avoided. 26 % generate 'trial' events for each packet < 0.01 100 27 if isempty(type) || any(strcmp('trial', type)) 28 % there seems to be a bug in Acq, causing the messageId to wrap around 29 % hence it cannot be used as index into the packets, so construct a new trial numbering vector < 0.01 100 30 trlNum = nan(size(msgId)); 0.01 100 31 trlNum(msgType==1) = sampleNumber(msgType==1)./numSamples(msgType==1); 32 % make an event for each data packet < 0.01 100 33 sel = find(msgType==1); < 0.01 100 34 for i=1:length(sel) 1.39 56948 35 event(end+1).type = 'trial'; 0.79 56948 36 event(end ).value = []; 1.70 56948 37 event(end ).sample = double(sampleNumber(sel(i))+1); % offset by one 1.29 56948 38 event(end ).duration = double(numSamples(sel(i))); 0.78 56948 39 event(end ).offset = 0; 0.05 56948 40 end < 0.01 100 41 end


Robert Oostenveld - 2010-07-04 12:11:33 +0200

This should be solved in more general. All cases where the event structure-array is growing one at a time should be replaced by a preallocation of the event structure, followed by assigning the values. This pertains to MacBook> grep 'event(end+1)' *.m */*.m ft_read_event.m: event(end+1).type = 'trial'; ft_read_event.m: event(end+1).type = channel; ft_read_event.m: event(end+1).type = channel; ft_read_event.m: event(end+1).type = [channel '_up']; % distinguish between up and down flank ft_read_event.m: event(end+1).type = [channel '_down']; % distinguish between up and down flank ft_read_event.m: event(end+1).type = 'average'; ft_read_event.m: event(end+1).type = 'STATUS'; ft_read_event.m: event(end+1).type = 'Epoch'; ft_read_event.m: event(end+1).type = 'CM_in_range'; ft_read_event.m: event(end+1).type = 'CM_out_of_range'; ft_read_event.m: event(end+1).type = 'Battery_low'; ft_read_event.m: event(end+1).type = 'Battery_ok'; ft_read_event.m: event(end+1).type = tok{1}; ft_read_event.m: event(end+1).type = 'backpanel trigger'; ft_read_event.m: event(end+1).type = 'frontpanel trigger'; ft_read_event.m: event(end+1).type = 'trial'; ft_read_event.m: event(end+1).type = 'classification'; ft_read_event.m: event(end+1).type = mrk.marker_names{i}; ft_read_event.m: event(end+1).type = 'average'; ft_read_event.m: event(end+1).type = 'INPUT'; ft_read_event.m: event(end+1).type = 'trigger'; ft_read_event.m: event(end+1).type = 'trial'; ft_read_event.m: event(end+1).type = 'average'; ft_read_event.m: event(end+1).type = 'trial'; ft_read_event.m: event(end+1).type = 'trigger'; ft_read_event.m: event(end+1).type = 'average'; ft_read_event.m: event(end+1).type = 'trial'; ft_read_event.m: event(end+1).type = 'accept'; private/read_eeglabevent.m: event(end+1).type = 'trial'; private/read_nexstim_event.m: event(end+1).type = 'rising'; private/read_nexstim_event.m: event(end+1).type = 'falling'; private/read_shm_event.m: event(end+1).type = 'trial'; private/read_shm_event.m: event(end+1).type = hdr.label{trg(1,i)+1}; % zero-offset private/read_shm_event.m: event(end+1).type = hdr.label{i}; private/read_trigger.m: event(end+1).type = channel; private/read_trigger.m: event(end+1).type = channel; private/read_trigger.m: event(end+1).type = [channel '_up']; % distinguish between up and down flank private/read_trigger.m: event(end+1).type = [channel '_down']; % distinguish between up and down flank private/read_yokogawa_event.m: event(end+1).type = 'trial';


Robert Oostenveld - 2010-09-11 10:53:34 +0200

Some improvements have already been implemented >6 months ago. This request has been obsoleted by the ctf2ft command-line implementation.


Robert Oostenveld - 2011-01-05 11:57:02 +0100

selected a long list of resolved bugs from roboos and changed the status into "RESOLVED"


Robert Oostenveld - 2011-01-05 12:01:07 +0100

selected all old bugs from roboos with status RESOLVED and changed it into CLOSED