Skip to content

Commit

Permalink
update examples, README.md, docs/index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
calebgeniesse committed Dec 20, 2021
1 parent f024162 commit 66e7eb9
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 79 deletions.
54 changes: 20 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,25 @@ the shape of data sampled from a trefoil knot.

```matlab
%% Configure paths
addpath(genpath('~/neumapper/code/neumapper'));
addpath(genpath('~/neumapper/code/tools'));
addpath(genpath('../../code/'));
%% Load the data
X = create_trefoil_knot(1000,'euclidean');
%% Configure options
%% Use default options
options = struct();
options.binning = 'cball';
options.dimreduce = 'none';
options.resolution = 100;
options.knnparam = 8;
options.gain = 40;
options.save_to = 'trefoil_knot_neumapper.mat';
options.save_plot = 'trefoil_knot_neumapper.png';
options.show_plot = true;
options.show_embed = true;
options.resolution = 40;
%% Run NeuMapper
res = neumapper(X, options);
%% Save outputs
save('trefoil_knot_neumapper.mat','res');
saveas(gcf, 'trefoil_knot_neumapper.png');
```

<p align="center"><img src="https://github.com/braindynamicslab/neumapper/blob/master/examples/trefoil_knot/trefoil_knot_neumapper.png"></p>
Expand Down Expand Up @@ -123,9 +118,7 @@ Now we can simply load the data into Matlab, and run NeuMapper.

```matlab
%% Configure paths
addpath(genpath('~/neumapper/code/neumapper'));
addpath(genpath('~/neumapper/code/dimReducMethods'));
addpath(genpath('~/neumapper/code/tools'));
addpath(genpath('../../code/'));
%% Load the data
Expand All @@ -137,28 +130,21 @@ labels = string(timing.task_name);
%% Configure options
options = struct();
options.binning = 'ball';
options.dimreduce = 'bdl_isomap';
options.dim_embed = 3;
options.resolution = 240;
options.knnparam = 50;
options.metric = 'correlation';
options.k = 30;
options.resolution = 400;
options.gain = 40;
options.labels = timing.task + 1; %reindex to start from 1
options.dXtype = 'correlation';
options.dXgeod = false;
options.dfXtype = 'cityblock';
options.dfXgeod = true;
options.save_to = 'haxby_decoding_neumapper.mat';
options.save_plot = 'haxby_decoding_neumapper.png';
options.show_plot = true;
options.show_embed = true;
options.colors = colors;
options.labels = labels;
%% Run NeuMapper
[c,X_] = pca(X,'NumComponents',50); % Preprocess with PCA
res = neumapper(X_, options);
%% Run NeuMapper
res = neumapper(X, options);
%% Save outputs
save('haxby_decoding_neumapper.mat','res');
saveas(gcf, 'haxby_decoding_neumapper.png');
```

<p align="center"><img src="https://github.com/braindynamicslab/neumapper/blob/master/examples/haxby_decoding/haxby_decoding_neumapper.png"></p>
Expand Down Expand Up @@ -198,7 +184,7 @@ timing_onehot = pd.read_csv('SBJ02_timing_onehot.tsv', sep='\t')


## Convert to KeplerMapper format
membership = res.memberMat.A
membership = res.clusterBins
adjacency = membership @ membership.T
np.fill_diagonal(adjacency, 0)
adjacency = (adjacency > 0).astype(int)
Expand Down
Binary file modified docs/assets/haxby_decoding_neumapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/haxby_decoding_neumapper_dyneusr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/trefoil_knot_neumapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/demo/haxby-decoding/index.html

Large diffs are not rendered by default.

54 changes: 20 additions & 34 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,25 @@ the shape of data sampled from a trefoil knot.

```matlab
%% Configure paths
addpath(genpath('~/neumapper/code/neumapper'));
addpath(genpath('~/neumapper/code/tools'));
addpath(genpath('../../code/'));
%% Load the data
X = create_trefoil_knot(1000,'euclidean');
%% Configure options
%% Use default options
options = struct();
options.binning = 'cball';
options.dimreduce = 'none';
options.resolution = 100;
options.knnparam = 8;
options.gain = 40;
options.save_to = 'trefoil_knot_neumapper.mat';
options.save_plot = 'trefoil_knot_neumapper.png';
options.show_plot = true;
options.show_embed = true;
options.resolution = 40;
%% Run NeuMapper
res = neumapper(X, options);
%% Save outputs
save('trefoil_knot_neumapper.mat','res');
saveas(gcf, 'trefoil_knot_neumapper.png');
```

<p align="center"><img src="./assets/trefoil_knot_neumapper.png?raw=true"></p>
Expand Down Expand Up @@ -136,9 +131,7 @@ Now we can simply load the data into Matlab, and run NeuMapper.

```matlab
%% Configure paths
addpath(genpath('~/neumapper/code/neumapper'));
addpath(genpath('~/neumapper/code/dimReducMethods'));
addpath(genpath('~/neumapper/code/tools'));
addpath(genpath('../../code/'));
%% Load the data
Expand All @@ -150,28 +143,21 @@ labels = string(timing.task_name);
%% Configure options
options = struct();
options.binning = 'ball';
options.dimreduce = 'bdl_isomap';
options.dim_embed = 3;
options.resolution = 240;
options.knnparam = 50;
options.metric = 'correlation';
options.k = 30;
options.resolution = 400;
options.gain = 40;
options.labels = timing.task + 1; %reindex to start from 1
options.dXtype = 'correlation';
options.dXgeod = false;
options.dfXtype = 'cityblock';
options.dfXgeod = true;
options.save_to = 'haxby_decoding_neumapper.mat';
options.save_plot = 'haxby_decoding_neumapper.png';
options.show_plot = true;
options.show_embed = true;
options.colors = colors;
options.labels = labels;
%% Run NeuMapper
[c,X_] = pca(X,'NumComponents',50); % Preprocess with PCA
res = neumapper(X_, options);
%% Run NeuMapper
res = neumapper(X, options);
%% Save outputs
save('haxby_decoding_neumapper.mat','res');
saveas(gcf, 'haxby_decoding_neumapper.png');
```

<p align="center"><img src="./assets/haxby_decoding_neumapper.png?raw=true"></p>
Expand Down Expand Up @@ -211,7 +197,7 @@ timing_onehot = pd.read_csv('SBJ02_timing_onehot.tsv', sep='\t')


## Convert to KeplerMapper format
membership = res.memberMat.A
membership = res.clusterBins
adjacency = membership @ membership.T
np.fill_diagonal(adjacency, 0)
adjacency = (adjacency > 0).astype(int)
Expand Down
7 changes: 6 additions & 1 deletion examples/haxby_decoding/haxby_decoding_neumapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@

%% Run NeuMapper
[c,X_] = pca(X,'NumComponents',50); % Preprocess with PCA
res = neumapper(X_, options);
res = neumapper(X_, options);


%% Save outputs
save('haxby_decoding_neumapper.mat','res');
saveas(gcf, 'haxby_decoding_neumapper.png');
Binary file modified examples/haxby_decoding/haxby_decoding_neumapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions examples/haxby_decoding/haxby_decoding_neumapper_dyneusr.html

Large diffs are not rendered by default.

Binary file modified examples/haxby_decoding/haxby_decoding_neumapper_dyneusr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


## Convert to KeplerMapper format
membership = res.clusterBins.A
membership = res.clusterBins
adjacency = membership @ membership.T
np.fill_diagonal(adjacency, 0)
adjacency = (adjacency > 0).astype(int)
Expand Down
8 changes: 7 additions & 1 deletion examples/trefoil_knot/trefoil_knot_neumapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

%% Use default options
options = struct();
options.resolution = 40;


%% Run NeuMapper
res = neumapper(X, options);
res = neumapper(X, options);


%% Save outputs
save('trefoil_knot_neumapper.mat','res');
saveas(gcf, 'trefoil_knot_neumapper.png');
Binary file modified examples/trefoil_knot/trefoil_knot_neumapper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 66e7eb9

Please sign in to comment.