[nodes] = fiff_dir_tree_find(tree,kind) Find nodes of the given kind from a directory tree structure
0001 function [nodes] = fiff_dir_tree_find(tree, kind) 0002 % 0003 % [nodes] = fiff_dir_tree_find(tree,kind) 0004 % 0005 % Find nodes of the given kind from a directory tree structure 0006 % 0007 0008 % Author : Matti Hamalainen, MGH Martinos Center 0009 % License : BSD 3-clause 0010 % 0011 % Revision 1.4 2006/11/30 05:43:29 msh 0012 % Fixed help text in fiff_dir_tree_find 0013 % Fixed check for the existence of parent MRI block in mne_read_forward_solution 0014 % 0015 % Revision 1.3 2006/04/23 15:29:40 msh 0016 % Added MGH to the copyright 0017 % 0018 % Revision 1.2 2006/04/12 10:29:02 msh 0019 % Made evoked data writing compatible with the structures returned in reading. 0020 % 0021 % Revision 1.1 2006/04/10 23:26:54 msh 0022 % Added fiff reading routines 0023 % 0024 0025 me = 'MNE:fiff_dir_tree_find'; 0026 0027 if nargin ~= 2 0028 error(me, 'Incorrect number of arguments'); 0029 end 0030 0031 nodes = struct('block', {}, 'id', {}, 'parent_id', {}, 'nent', {}, 'nchild', {}, 'dir', {}, 'children', {}); 0032 % 0033 % Am I desirable myself? 0034 % 0035 if tree.block == kind 0036 nodes = [ nodes tree ]; 0037 end 0038 % 0039 % Search the subtrees 0040 % 0041 for k = 1:tree.nchild 0042 nodes = [ nodes fiff_dir_tree_find(tree.children(k), kind) ]; 0043 end 0044 0045 return 0046