-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparticipant_selector.m
More file actions
54 lines (43 loc) · 1.41 KB
/
participant_selector.m
File metadata and controls
54 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% participant_selector() - Creates a list dialog selection box of participants
% in a given (BIDS) directory. Captures folders
% in the form sub*.
%
% Usage:
% >> selection = folder_listdlg(directory)
%
% Required inputs:
% directory - character array specifying a valid directory
%
% Outputs:
% selection - cell array of strings with the selected items from the
% listdlg
% See also:
% DIR, LISTDLG
%
% Create by: Joshua D. Koen, University of Notre Dame
% LICENSE INFO
function selection = participant_selector( directory )
% Check inputs
if ~ischar(directory) || ~isfolder(directory)
error('directory inputs must be the ''char'' class and an existing folder.')
end
% List all files and folder meeting filter
dir_list = dir( fullfile(directory, 'sub-*') );
% Remove hidden directories and entries that are not a directory
dir_list( ismember({dir_list.name}, {'.' '..'}) ) = [];
dir_list( ~[dir_list.isdir] ) = [];
% Reduce to a cell array
dir_names = {dir_list.name};
% Create listdlg object to collect participants
[SELECTION,OK] = listdlg( ...
'PromptString', 'Select participant(s) to process)', ...
'SelectionMode', 'multiple', ...
'ListString', dir_names, ...
'ListSize', [200 500]);
% Return selection
if OK == 0
selection = '';
else
selection = dir_names(SELECTION);
end
end % of function