Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/neuro-mechatronics-interfaces/matlab_package__charts

This should be initialized as gitmodule with name `+charts` to use as a MATLAB package.
https://github.com/neuro-mechatronics-interfaces/matlab_package__charts

Last synced: 24 days ago
JSON representation

This should be initialized as gitmodule with name `+charts` to use as a MATLAB package.

Awesome Lists containing this project

README

        

# TMSi MATLAB Plots #
Plotting utility chart classes designed to show data captured on TMSi surface EMG array grids.

## Installation ##
* Instructions for setting up your `ssh` credentials can be found at this [WTF NML](https://code.nml.wtf/tutorials/2022/06/26/credentials) post.
* Instructions for tag conventions can be found at this [WTF NML](https://code.nml.wtf/sops/2022/10/23/tags_and_submodules) post.

### Shortcut ###
To get this submodule in a repo that already has it added as a gitmodule in the `.gitattributes` file, use:
```(git)
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)
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.

## Chart Types ##

| Name | Example |
| ---- | ----------- |
| [Raster](#raster) | ![Example Raster-Type Chart](docs/Example__Raster_Chart_1.png) |
| [Snippet](#snippet) | ![Example Snippet-Type Chart](docs/Example__Snippet_Chart_3.png) |

---

### Raster ###
_Example:_ Viewing the "raster" counts as a heatmap.
```(matlab)
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 animated Raster Map](docs/Example__Raster_Chart.gif)

### Snippet ###
_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.
```(matlab)
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:
![Original snippet data from recording](docs/Example__Snippet_Chart_1.png)

Using only two lines of code, we can produce a spatially re-arranged version:
```(matlab)
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:
![Original snippet data from recording](docs/Example__Snippet_Chart_2.png)

We can also zoom out to see more of the snippets:
```(matlab)
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:
![Original snippet data from recording](docs/Example__Snippet_Chart_3.png)

## Configuration ##
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 the `config.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).

---

## Content Overview ##
* [Functions](#functions)
+ [Utilities](#utilities)
+ [Helper Functions](#helpers)
* [Classes](#classes)
+ [Base Classes](#base-classes)
+ [Specific Layouts](#specific-layouts)
* [Examples](#examples)

### Functions ###
#### Utilities ####
+ [`get_config`](get_config.m) - Returns the config struct for this submodule.

#### Helpers ####
+ [`tiled_mean_arrays`](tiled_mean_arrays.m) - Like tiled_snippet_arrays, but shows per-channel means.
+ [`tiled_snippet_arrays`](tiled_snippet_arrays.m) - Create tiled snippet array figure(s).

### Classes ###
#### Base Classes ####
+ [`Contour__Base_Chart`](Contour__Base_Chart.m) - c = Contour__Base_Chart('XData', X, 'YData', Y, 'Name', Value,...).
+ [`Raster__Base_Chart`](Raster__Base_Chart.m) - 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`](Snippet__Base_Chart.m) - c = Snippet__Base_Chart('XData', X, 'YData', Y, 'Name', Value,...).

#### Specific Layouts ####
+ [`Contour_Array_8_8_L_Chart`](Contour_Array_8_8_L_Chart.m) - c = Contour_Array_8_8_L_Chart('YData',Y,Name,Value,...).
+ [`Raster_Array_4_8_L_Chart`](Raster_Array_4_8_L_Chart.m) - c = Raster_Array_4_8_L_Chart('YData',Y,Name,Value,...).
+ [`Raster_Array_8_4_L_Chart`](Raster_Array_8_4_L_Chart.m) - c = Raster_Array_8_4_L_Chart('YData',Y,Name,Value,...).
+ [`Raster_Array_8_8_L_Chart`](Raster_Array_8_8_L_Chart.m) - c = Raster_Array_8_8_L_Chart('YData',Y,Name,Value,...).
+ [`Raster_Array_8_8_S_Chart`](Raster_Array_8_8_S_Chart.m) - c = Raster_Array_8_8_S_Chart('YData',Y,Name,Value,...).
+ [`Snippet_Array_8_8_L_Chart`](Snippet_Array_8_8_L_Chart.m) - c = Snippet_Array_8_8_L_Chart('YData',Y,Name,Value,...).
+ [`Snippet_Array_8_8_S_Chart`](Snippet_Array_8_8_S_Chart.m) - c = Snippet_Array_8_8_S_Chart('YData',Y,Name,Value,...).
+ [`Snippet_Cloth_4_8_L_Chart`](Snippet_Cloth_4_8_L_Chart.m) - c = Snippet_Cloth_4_8_L_Chart('YData',Y,Name,Value,...).
+ [`Snippet_Cloth_8_4_L_Chart`](Snippet_Cloth_8_4_L_Chart.m) - c = Snippet_Cloth_8_4_L_Chart('YData',Y,Name,Value,...).

### Examples ###
+ [`example_plotting_tiled_snippets`](example_plotting_tiled_snippets.m) - Example showing how to plot tiled snippet files.