Plotting utility chart classes designed to show data captured on TMSi surface EMG array grids.
- Instructions for setting up your
ssh
credentials can be found at this WTF NML post. - Instructions for tag conventions can be found at this WTF NML post.
To get this submodule in a repo that already has it added as a gitmodule in the .gitattributes
file, use:
git clone --recurse-submodules [email protected]:Neuro-Mechatronics-Interfaces/2TMSi_MATLAB_Interface.git
In this case, 2TMSi_MATLAB_Interface
is a repo that has already initialized the +charts
submodule.
To add this submodule to the gitmodules of an existing repo, use this:
git submodule add [email protected]:Neuro-Mechatronics-Interfaces/matlab_package__charts.git +charts
Note that it's important to the MATLAB workspace conventions that you add it as a folder called +charts
otherwise the namespace conventions in MATLAB fail.
Name | Example |
---|---|
Raster | ![]() |
Snippet | ![]() |
Example: Viewing the "raster" counts as a heatmap.
myRaster = charts.Raster_Array_8_8_L_Chart();
updateTimescale(myRaster, 30);
while isvalid(myRaster);
n = randi([1,50],1,1); % How many timestamps in this time-interval?
ch = [randi([1,32],n,1); randi([1,64],n,1)]; % Which channels were they on?
ts = repmat(datetime('now'),2*n,1) + seconds(randn(2*n,1).*3); % Jitter in timestamps.
myRaster.append(ch, ts);
for ii = 1:4
if isvalid(myRaster)
myRaster.redraw();
drawnow();
pause(0.25);
end
end
end
This would produce a simulated raster heatmap that looks like the gif below.
Example: Let's say we want to visualize putative MUAP waveforms across the array and know how it "looks" in a spatial sense. This example illustrates how we can do this quickly.
load('R:\NMLShare\raw_data\primate\Darcy\Darcy_2022_10_28\Darcy_2022_10_28_A_0.mat'); % Has data in array `samples`
t = (0:((size(samples,2)-1)))./4000;
x = samples(2:33,:); % Taken from single cloth 4x8 grid
% Plot the snippets of interest
z = zscore(x, 0, 2);
z_c = z - mean(z, 1);
iSignal = (t>191.435) & (t<191.46);
figure('Name', 'Original Snippets');
plot(t(iSignal), z_c(:, iSignal));
This should result in a figure which looks like the following image:
Using only two lines of code, we can produce a spatially re-arranged version:
figure('Name', 'Spatial Snippets');
mySnippets = charts.Snippet_Cloth_8_4_L_Chart('XData', t(iSignal)', 'YData', x(:, iSignal)');
This should result in a figure which looks like the following image:
We can also zoom out to see more of the snippets:
figure('Name', 'Spatial Snippets (Zoomed Out)');
iSignal = (t>191.4) & (t<191.5);
set(mySnippets, 'XData', t(iSignal)', 'YData', x(:, iSignal)');
This should result in a figure which looks like the following image:
In config.yaml
, you can modify existing Chart grid layout specifications following the formatting for existing montages as indicated in the file's syntax.
Montage names refer to the spacing ("large - L or small - S", number of rows, and number of columns in the electrode grid). There are 4 default configured montages:
L48
- For cloth arrays if you want to view them in "landscape" orientation.L84
- For cloth arrays if you want to view them in "portrait" orientation.L88
- For the standard 8x8 grids that are most-used in the lab.S88
- For the small 8x8 grids.
You can use the corresponding named subclasses and modify any of the values in theconfig.yaml
corresponding to that name convention in order to change the electrode spacing if you need a different spacing than what exists (or add a category and add a corresponding chart subclass as desired).
get_config
- Returns the config struct for this submodule.
tiled_mean_arrays
- Like tiled_snippet_arrays, but shows per-channel means.tiled_snippet_arrays
- Create tiled snippet array figure(s).
Contour__Base_Chart
- c = Contour__Base_Chart('XData', X, 'YData', Y, 'Name', Value,...).Raster__Base_Chart
- c = Raster__Base_Chart('TLim', seconds(n), 'Name', Value,...) - Shades in a square with an intensity color for every gridded data point.Snippet__Base_Chart
- c = Snippet__Base_Chart('XData', X, 'YData', Y, 'Name', Value,...).
Contour_Array_8_8_L_Chart
- c = Contour_Array_8_8_L_Chart('YData',Y,Name,Value,...).Raster_Array_4_8_L_Chart
- c = Raster_Array_4_8_L_Chart('YData',Y,Name,Value,...).Raster_Array_8_4_L_Chart
- c = Raster_Array_8_4_L_Chart('YData',Y,Name,Value,...).Raster_Array_8_8_L_Chart
- c = Raster_Array_8_8_L_Chart('YData',Y,Name,Value,...).Raster_Array_8_8_S_Chart
- c = Raster_Array_8_8_S_Chart('YData',Y,Name,Value,...).Snippet_Array_8_8_L_Chart
- c = Snippet_Array_8_8_L_Chart('YData',Y,Name,Value,...).Snippet_Array_8_8_S_Chart
- c = Snippet_Array_8_8_S_Chart('YData',Y,Name,Value,...).Snippet_Cloth_4_8_L_Chart
- c = Snippet_Cloth_4_8_L_Chart('YData',Y,Name,Value,...).Snippet_Cloth_8_4_L_Chart
- c = Snippet_Cloth_8_4_L_Chart('YData',Y,Name,Value,...).
example_plotting_tiled_snippets
- Example showing how to plot tiled snippet files.