Hi Jorge,
I understand that you want the (x, y, z) coordinates of each neuron as they appear in the plot generated by “plotsompos”.
The weights of the SOM network are stored in the property “IW” as a cell array. You can execute the following to access the property:
net.IW
The (x, y, z) coordinates of each neuron are taken directly from the weight matrix, depending on the dimensionality of the data:
- If the data is one-dimensional (and thus, the weights are one-dimensional), the x-coordinate of the weight positions are taken from the only column of the weight matrix, the y-coordinate is 0 and the z-coordinate is set to 1.
- If the data is two-dimensional, the x-coordinate and y-coordinates are taken from the two columns of the weight matrix and the z-coordinate is set to 1.
- If the data is three-dimensional, the x-, y- and z-coordinates are taken from the three columns of the weight matrix.
- For higher dimensional data, the x- and y-coordinates are taken from the first two columns of the weight matrix and the z-coordinate is set to 1.
The above behaviour is not documented but can be verified. For example, considering the case of one-dimensional data:
% Create one-dimensional dataset
angles = 0:0.5*pi/99:0.5*pi;
X = sin(angles);
% Create the net
net = selforgmap(10);
% Train the net for 10 epochs
net.trainParam.epochs = 10;
net = train(net, X);
% Plot the net
% TODO: Brush the data from the plot and store it in a variable called brushedData
plotsompos(net, X);
Now you can confirm the above behaviour as follows:
% Check x-coordinate matches first column of weight matrix
all(brushedData(:, 1) == net.IW{1}(:, 1))
% Check y-coordinate is 0
all(brushedData(:, 2) == 0)
% Check z-coordinate is 1
all(brushedData(:, 3) == 1)
All the “all” function calls return "logical" 1, which is the expected behaviour for one-dimensional data.
In your case, assuming the data is three-dimensional, the coordinates can be obtained as follows:
neuronCoords = net.IW{1}(:, [1 2 3]);
Hope this helps!