Home > matlabmk > rm_bins.m

rm_bins

PURPOSE ^

rm_bins() - Removes bin from a Mass Univariate ERP Toolbox GND or GRP variable

SYNOPSIS ^

function GNDorGRP=rm_bins(GNDorGRP,bins)

DESCRIPTION ^

 rm_bins() - Removes bin from a Mass Univariate ERP Toolbox GND or GRP variable
             
 Usage:
  >> GNDorGRP=rm_bins(GNDorGRP,bins)

 Required Inputs:
   GNDorGRP - A  GND or GRP struct variable. GND variables are 
              produced by the functions avgs2GND.m or sets2GND.m.  GRP 
              variables are produced by GNDs2GRP.m.  
   bins     - [integer vector] The bin or bins you would like to remove
              from the GND or GRP variable.

 Output:
   GNDorGRP - The GND or GRP struct variable with the specified bins and
              associated permutation test removed.

 Example:
   To remove Bin #41 from a GND variable:
 >> GND=rm_bins(GND,41);

   To remove Bins #3-30 and Bins #40-50 from a GND variable:
 >> GND=rm_bins(GND,[3:30 40:50]);

   To remove Bin #1 from a GRP variable
 >> GRP=rm_bins(GRP,41);

 Author:
 David Groppe
 Kutaslab, 4/2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % rm_bins() - Removes bin from a Mass Univariate ERP Toolbox GND or GRP variable
0002 %
0003 % Usage:
0004 %  >> GNDorGRP=rm_bins(GNDorGRP,bins)
0005 %
0006 % Required Inputs:
0007 %   GNDorGRP - A  GND or GRP struct variable. GND variables are
0008 %              produced by the functions avgs2GND.m or sets2GND.m.  GRP
0009 %              variables are produced by GNDs2GRP.m.
0010 %   bins     - [integer vector] The bin or bins you would like to remove
0011 %              from the GND or GRP variable.
0012 %
0013 % Output:
0014 %   GNDorGRP - The GND or GRP struct variable with the specified bins and
0015 %              associated permutation test removed.
0016 %
0017 % Example:
0018 %   To remove Bin #41 from a GND variable:
0019 % >> GND=rm_bins(GND,41);
0020 %
0021 %   To remove Bins #3-30 and Bins #40-50 from a GND variable:
0022 % >> GND=rm_bins(GND,[3:30 40:50]);
0023 %
0024 %   To remove Bin #1 from a GRP variable
0025 % >> GRP=rm_bins(GRP,41);
0026 %
0027 % Author:
0028 % David Groppe
0029 % Kutaslab, 4/2010
0030 
0031 function GNDorGRP=rm_bins(GNDorGRP,bins)
0032 
0033 fldnms=fieldnames(GNDorGRP);
0034 isGRP=0;
0035 if ismember('group_desc',fldnms),
0036    isGRP=1; 
0037 end
0038 
0039 n_bins=length(GNDorGRP.bin_info);
0040 not_have=setdiff(bins,1:n_bins);
0041 if ~isempty(not_have),
0042     watchit(['This GND or GRP variable does NOT have the following bin(s): ' int2str(not_have)]);
0043 end
0044 bins=intersect(bins,1:n_bins);
0045 if isempty(bins),
0046     fprintf('Not removing any bins.\n');
0047 else
0048     fprintf('Removing the following bin(s): %s\n',int2str(bins));
0049     
0050     %find any permutation tests performed at that bin and remove them
0051     n_ptests=length(GNDorGRP.t_tests);
0052     rm_ptest=[];
0053     for a=1:n_ptests,
0054         if ismember(GNDorGRP.t_tests(a).bin,bins)
0055             rm_ptest=[rm_ptest a];
0056         end
0057     end
0058     if ~isempty(rm_ptest),
0059         fprintf('Removing the following permutation test results because they were performed on bins being deleted: %s\n',int2str(rm_ptest))
0060     end
0061     use_ptests=setdiff(1:n_ptests,rm_ptest);
0062     GNDorGRP.t_tests=GNDorGRP.t_tests(use_ptests);
0063     
0064     use_bins=setdiff(1:n_bins,bins);
0065     
0066     GNDorGRP.grands=GNDorGRP.grands(:,:,use_bins);
0067     GNDorGRP.grands_stder=GNDorGRP.grands_stder(:,:,use_bins);
0068     GNDorGRP.grands_t=GNDorGRP.grands_t(:,:,use_bins);
0069     GNDorGRP.bin_info=GNDorGRP.bin_info(use_bins);
0070     
0071     if isGRP,
0072         %fields unique to GRP variables
0073         n_group=length(GNDorGRP.group_desc);
0074         for a=1:n_group,
0075             GNDorGRP.indiv_bin_ct{a}=GNDorGRP.indiv_bin_ct{a}(:,use_bins);
0076             GNDorGRP.indiv_bin_raw_ct{a}=GNDorGRP.indiv_bin_raw_ct{a}(:,use_bins);
0077         end
0078     else
0079         %fields unique to GND variables
0080         GNDorGRP.sub_ct=GNDorGRP.sub_ct(use_bins);
0081         GNDorGRP.indiv_bin_ct=GNDorGRP.indiv_bin_ct(:,use_bins);
0082         GNDorGRP.indiv_bin_raw_ct=GNDorGRP.indiv_bin_raw_ct(:,use_bins);
0083         GNDorGRP.indiv_erps=GNDorGRP.indiv_erps(:,:,use_bins,:);
0084     end
0085 end

Generated on Tue 10-May-2016 16:37:45 by m2html © 2005