To convert .continuous to .mat

6 vues (au cours des 30 derniers jours)
Felicia DE CAPUA
Felicia DE CAPUA le 26 Déc 2022
Modifié(e) : Jan le 26 Déc 2022
Hi everyone,
I need to convert my files ".continuous" in file ".mat", my code is this:
cd(path of directory where there are the files)
dir = dir('*continuous');
cell = struct2cell(dir);
stringa = string(cell);
channels = [];
for i = 1:size(dir,1);
channels(:,i)=load_open_ephys_data_faster([stringa]);
end
But the error is: Error using strcmp
Inputs must be the same size or either one can be a scalar.
How can I resolve this?
Thank you so much!

Réponses (1)

Voss
Voss le 26 Déc 2022
Try this:
% you'll need to clear the variable dir (and you might as well clear the
% variable cell too) if this is a script and you still have them in your
% workspace (see more below):
clear dir cell
% store your directory as path_name
path_name = 'path\of\directory\where\the\files\are\';
% - use path_name in call to dir() (no need to cd())
% - don't make a variable called dir (or cell) - that conflicts with the
% built-in function dir() (cell())
% - use '*.continuous' to match files with .continuous extension
d_info = dir(fullfile(path_name,'*.continuous'));
% no need to convert the struct array returned by dir() into a cell
% array and then a string array; just use the struct array directly.
file_names = fullfile({d_info.folder},{d_info.name});
channels = [];
for ii = 1:numel(file_names)
channels(:,ii) = load_open_ephys_data_faster(file_names{ii});
end
  1 commentaire
Voss
Voss le 26 Déc 2022
Another thing to consider is that you can take advantage of the struct array of file info you already have (which was returned from dir()), and use it to store the data from each file as well ...
d_info = dir(fullfile(path_name,'*.continuous'));
file_names = fullfile({d_info.folder},{d_info.name});
for ii = 1:numel(file_names)
d_info(ii).data = load_open_ephys_data_faster(file_names{ii});
end
... instead of storing all the data in a single matrix, which wouldn't even work if the data returned by load_open_ephys_data_faster is not the same length for each file, or if it's not a vector, etc.

Connectez-vous pour commenter.

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by