Transposing matrices of a Dataset

2 views (last 30 days)
Gianmarco Plutino
Gianmarco Plutino on 2 Jul 2020
Hello! I'm new of the comunity.
I imported a dataset containing the mat files where each of them represents a 3D matrix (43x512x210).
i need to transpose each of these matrices into matrices 210x512x43. The name I associated with the dataset is "imds" and the code to import it is:
digitDatasetPath = fullfile('C:\Users\User\Desktop\DB_BCI\DB');
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'FileExtension', '.mat','LabelSource','foldernames');
the files mat in the dataset are 120:
would anyone be able to help me? Thank you!

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 2 Jul 2020
Take a look at the help and documentation of the matlab-function permute.
HTH
  5 Comments
Gianmarco Plutino
Gianmarco Plutino on 2 Jul 2020
Hello my friend,
i tried this solution:
for i=1:120
imds.Files{i,1}=permute(imds.Files{i,1},[3 2 1]);
end
and the command is executed without errors, but when i try to train the net it gives me the following error:
>> net = trainNetwork(imdsTrain,layers,options);
Error using trainNetwork (line 154)
The training images are of size 43x512x210 but the input layer expects images of size 210x512x43.
Caused by:
Error using nnet.internal.cnn.util.NetworkDataValidator/assertCorrectDataSizeForInputLayer (line 262)
The training images are of size 43x512x210 but the input layer expects images of size 210x512x43.
which makes me understand that the transformation of the matrices has not been successful.
Bjorn Gustavsson
Bjorn Gustavsson on 2 Jul 2020
Check with:
size(imds.Files{i,1})
before and after the permutation.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!