@@ -314,29 +314,31 @@ function processLoop(obj)
314314 function e = nextEpoch(obj )
315315 e = symphonyui .core .Epoch(class(obj .currentProtocol ));
316316
317- for i = 1 : numel(obj .rig .devices )
318- d = obj.rig.devices{i };
319- if ~isempty(d .outputStreams )
317+ obj .currentProtocol .prepareEpoch(e );
318+
319+ devices = obj .rig .getOutputDevices();
320+ for i = 1 : numel(devices )
321+ d = devices{i };
322+ if ~e .hasStimulus(d ) && ~e .hasBackground(d )
320323 e .setBackground(d , d .background );
321324 end
322325 end
323-
324- obj .currentProtocol .prepareEpoch(e );
325326 end
326327
327- function i = nextInterval(obj )
328- i = symphonyui .core .Epoch(class(obj .currentProtocol ));
329- i.shouldBePersisted = false ;
330- i .addKeyword(obj .INTERVAL_KEYWORD );
331-
332- for k = 1 : numel(obj .rig .devices )
333- d = obj.rig.devices{k };
334- if ~isempty(d .outputStreams )
335- i .setBackground(d , d .background );
328+ function e = nextInterval(obj )
329+ e = symphonyui .core .Epoch(class(obj .currentProtocol ));
330+ e.shouldBePersisted = false ;
331+ e .addKeyword(obj .INTERVAL_KEYWORD );
332+
333+ obj .currentProtocol .prepareInterval(e );
334+
335+ devices = obj .rig .getOutputDevices();
336+ for i = 1 : numel(devices )
337+ d = devices{i };
338+ if ~e .hasStimulus(d ) && ~e .hasBackground(d )
339+ e .setBackground(d , d .background );
336340 end
337341 end
338-
339- obj .currentProtocol .prepareInterval(i );
340342 end
341343
342344 function enqueueEpoch(obj , epoch )
0 commit comments