Is there a way to save the c3d files using the uigetfile function in the order that you select rather than have them be imported in alphabetical order?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In the following lines I am trying to import .c3d files (which are files that contain 3D data from trials captured with motion capture software (vicon), and processed through the vicon nexus software. See the Trials.zip folder for the c3d jump trials and since I can only upload a max of 5MB of files/data, I have uploaded only 3 unique c3d files.
To read the c3d files I am using the btk (biomechanical toolkit)... I have attached the btk file that you need to add to the path when you run your script.
Now what I have been trying to do is save the .c3d files in the order that I select them from the dialog box for both versions of my script. However what has happened is that neither version imports/saves the files in the order that I select my c3d jumps. For example: if I click on the "Drop Jump.c3d" file, followed by "Reverse Drop Jump01.c3d" file... and finally the "Drop Jump Toe in01.c3d" file, that's how I would like them to be ordered on the
file_list
For the 2nd version I tried implementing the listdlg function but it does not really do much.
So I will restate my question again... Is there a way to either read the c3d files using uigetfile in the order that you select (which would make it the chronological order in my estimation) rather than have them be read/saved/arranged in alphabetical order?
I appreciate any help I can get.
Leo
1st version of my script
%This is the original code I had where I was relying solely on the
%uigetfile to read the c3d files
[file_list, path_n] = uigetfile('.c3d', 'Multiselect', 'on');
if iscell(file_list) ==0
file_list={file_list}
end
for i=1:length(file_list)
filename(i)=btkReadAcquisition(char(file_list(:,i)));
%Get jump type
%parse data
[angles(i), anglesInfo(i)]=btkGetAngles(filename(i));
[moments(i), momentsInfo(i)]=btkGetMoments(filename(i));
% [powers(i), powersInfo(i)]=btkGetPowers(filename(i));
% Events(i)=btkGetEvents(filename(i));
f2(i) = btkGetPointFrequency(filename(i));
[forces(i), forcesInfo(i)] = btkGetForces(filename(i));
% [forceplates{i}, forceplatesInfo{i}] = btkGetForcePlatforms(filename(i));
analog_data(i)= btkGetAnalogs(filename(i));
end
%%
2nd version
[file_list,path_n] = uigetfile('.c3d', 'Select files', 'MultiSelect', 'on');
if iscell(file_list) == 0
file_list = {file_list};
end
% Display custom dialog box to select files in the order they were selected
[file_index,~] = listdlg('PromptString','Select files in the order you want them to appear:',...
'ListString',file_list,...
'ListSize',[300 300],...
'SelectionMode','multiple');
file_list_sorted = file_list(file_index);
for i = 1:length(file_list_sorted)
% Read the file
filename = btkReadAcquisition(fullfile(path_n,file_list_sorted{i}));
% Get angles, moments, forces, etc.
[angles(i), anglesInfo(i)] = btkGetAngles(filename);
[moments(i), momentsInfo(i)] = btkGetMoments(filename);
f2(i) = btkGetPointFrequency(filename);
[forces(i), forcesInfo(i)] = btkGetForces(filename);
analog_data(i) = btkGetAnalogs(filename);
end
8 commentaires
Walter Roberson
le 14 Avr 2023
The Mathworks logic is that it is better to call into the native operating system file selectors, so that you have consistent look-and-feel with the rest of the operating system, and you get to take advantage of whatever facilities the operating system may build in. For example when Microsoft Windows 11 Fall 2023 incorporates Chat-GPT into its file selection boxes, the facility will show up automatically.
Réponses (1)
Walter Roberson
le 12 Avr 2023
uigetfile() calls out to native operating system facilities. There is no control over the order it returns items.
If you do not need to allow directory selection then you can dir() and throw the file names into a selection box, using the selection callbacks to record the order the user clicks. I did pretty much that at some point, to provide an improved multiselect experience, but I do not recall the details right now.
3 commentaires
Walter Roberson
le 13 Avr 2023
h = uicontrol('style', 'listbox', 'max', 2)
Now set Callback . You will get called back for every click on the list. You will not want each selection (even of groups) to overwrite all previous selections, so you will need to track which items have been selected so far, and to un-select you will need the user to click back on the some item -- so when you get a selected item you will need to check if it is already selected and if so remove it from the selection list.
Leutrim Mehmeti
le 16 Avr 2023
Modifié(e) : Leutrim Mehmeti
le 16 Avr 2023
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!