Home > vbmeg > external > mne > fiff_find_evoked.m

fiff_find_evoked

PURPOSE ^

SYNOPSIS ^

function [data_sets] = fiff_find_evoked(fname)

DESCRIPTION ^

 [data_sets] = fiff_find_evoked(fname)

 Find all evoked data sets in a fif file and create a list of descriptors

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [data_sets] = fiff_find_evoked(fname)
0002 %
0003 % [data_sets] = fiff_find_evoked(fname)
0004 %
0005 % Find all evoked data sets in a fif file and create a list of descriptors
0006 %
0007 
0008 
0009 %
0010 %   Author : Matti Hamalainen, MGH Martinos Center
0011 %   License : BSD 3-clause
0012 %
0013 
0014 global FIFF;
0015 if isempty(FIFF)
0016     FIFF = fiff_define_constants();
0017 end
0018 
0019 me = 'MNE:fiff_find_evoked';
0020 
0021 %
0022 %   Open the file
0023 %
0024 [ fid, tree ] = fiff_open(fname);
0025 data_sets = struct('comment',{},'aspect_kind',{},'aspect_name',{});
0026 %
0027 %   Find all evoked data sets
0028 %
0029 evoked = fiff_dir_tree_find(tree, FIFF.FIFFB_EVOKED);
0030 if length(evoked) == 0
0031     fclose(fid);
0032     return
0033 end
0034 %
0035 %   Identify the aspects
0036 %
0037 naspect = 0;
0038 for k = 1:length(evoked)
0039     sets(k).aspects  = fiff_dir_tree_find(evoked(k), FIFF.FIFFB_ASPECT);
0040     sets(k).naspect = length(sets(k).aspects);
0041     naspect = naspect + sets(k).naspect;
0042 end
0043 %
0044 %   Collect the desired information
0045 %
0046 count = 1;
0047 for k = 1:length(evoked)
0048     evoked_comment = find_tag(evoked(k), FIFF.FIFF_COMMENT);
0049     for a = 1:sets(k).naspect
0050         aspect_comment = find_tag(sets(k).aspects(a), FIFF.FIFF_COMMENT);
0051         aspect_kind    = find_tag(sets(k).aspects(a), FIFF.FIFF_ASPECT_KIND);
0052         if ~isempty(aspect_comment)
0053             data_sets(count).comment = aspect_comment.data;
0054         elseif ~isempty(evoked_comment)
0055             data_sets(count).comment = evoked_comment.data;
0056         else
0057             data_sets(count).comment = 'No comment';
0058         end
0059         if ~isempty(aspect_kind)
0060             data_sets(count).aspect_kind = aspect_kind.data;
0061         else
0062             data_sets(count).aspect_kind = -1;
0063         end
0064         switch data_sets(count).aspect_kind
0065         case FIFF.FIFFV_ASPECT_AVERAGE
0066             data_sets(count).aspect_name = 'Average';
0067         case FIFF.FIFFV_ASPECT_STD_ERR
0068             data_sets(count).aspect_name = 'Standard error';
0069         case FIFF.FIFFV_ASPECT_SINGLE
0070             data_sets(count).aspect_name = 'Single';
0071         case FIFF.FIFFV_ASPECT_SUBAVERAGE
0072             data_sets(count).aspect_name = 'Subaverage';
0073         case FIFF.FIFFV_ASPECT_ALTAVERAGE
0074             data_sets(count).aspect_name = 'Alt. subaverage';
0075         case FIFF.FIFFV_ASPECT_SAMPLE
0076             data_sets(count).aspect_name = 'Sample';
0077         case FIFF.FIFFV_ASPECT_POWER_DENSITY
0078             data_sets(count).aspect_name = 'Power density spectrum';
0079         case FIFF.FIFFV_ASPECT_DIPOLE_WAVE
0080             data_sets(count).aspect_name = 'Dipole source waveform';
0081             otherwise
0082             data_sets(count).aspect_name = 'Unknown';
0083         end
0084         count = count + 1;
0085     end
0086 end
0087 
0088 fclose(fid);
0089 
0090 return
0091 
0092 function [tag] = find_tag(node, findkind)
0093 
0094 for p = 1:node.nent
0095     kind = node.dir(p).kind;
0096     pos  = node.dir(p).pos;
0097     if kind == findkind
0098         tag = fiff_read_tag(fid, pos);
0099         return
0100     end
0101 end
0102 tag = [];
0103 return
0104 end
0105 
0106 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005