Skip to content

Commit

Permalink
Add plot_generator_sequence using bossapi.
Browse files Browse the repository at this point in the history
  • Loading branch information
pablorcum committed Oct 12, 2024
1 parent 42c57b5 commit d36c155
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Binary file modified docSource/bossdevice_api_functions.mlx
Binary file not shown.
2 changes: 1 addition & 1 deletion toolbox/dependencies/+bossapi
25 changes: 16 additions & 9 deletions toolbox/src/bossdevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,6 @@ function stop(obj)
sequence = getparam(obj, 'GEN', 'sequence_time_duration_port_marker');
end

function set.generator_sequence(obj, sequence)
setparam(obj, 'GEN', 'sequence_time_duration_port_marker', sequence);
end

function n = get.num_eeg_channels(obj)
n = getparam(obj, 'UDP', 'num_eeg_channels');
end
Expand All @@ -340,7 +336,6 @@ function stop(obj)
setparam(obj, 'UDP', 'num_eeg_channels', n);
end


function n = get.num_aux_channels(obj)
n = getparam(obj, 'UDP', 'num_aux_channels');
end
Expand All @@ -362,12 +357,24 @@ function stop(obj)
obj bossdevice
sequence {mustBeNumeric}
end
sizeRefSeq = size(obj.generator_sequence);
bossapi.boss.setGenSequenceOnTarget(obj.targetObject,sequence);
end

function tiledObj = plot_generator_sequence(obj, sequence, figParent)
arguments
obj bossdevice
sequence {mustBeNumeric} = obj.generator_sequence
figParent = figure
end

% Convert generator sequence from array to table
sequence = array2table(sequence, 'VariableNames', {'Time [s]','Pulse Width [s]','Encoded Port','Marker'});

assert(size(sequence, 1) <= sizeRefSeq(1), 'Sequence exceeds maximum number of rows (%i).', sizeRefSeq(1));
assert(size(sequence, 2) == sizeRefSeq(2), 'Sequence must have %i columns.', sizeRefSeq(2));
% Remove rows with all 0 values
sequence(all(sequence{:,:} == 0, 2),:) = [];

obj.generator_sequence = [sequence; zeros(sizeRefSeq(1)-size(sequence,1), sizeRefSeq(2))];
% Plot sequente in figParent
tiledObj = bossapi.app.plotProtocolSequence(sequence, obj.marker_pulse_width_sec, figParent);
end

function generator_running = get.isGeneratorRunning(obj)
Expand Down

0 comments on commit d36c155

Please sign in to comment.