Home > data-analysis > manip > cstream > cstream_reassign_categories.m

cstream_reassign_categories

PURPOSE ^

old_roi_list = {[1 2 3 10 25]; [4]}

SYNOPSIS ^

function new_cstream = cstream_reassign_categories(cstream, old_roi_list, new_roi_list)

DESCRIPTION ^

 old_roi_list = {[1 2 3 10 25]; [4]}
 new_roi_list = {[1]; [4]}

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function new_cstream = cstream_reassign_categories(cstream, old_roi_list, new_roi_list)
0002 % old_roi_list = {[1 2 3 10 25]; [4]}
0003 % new_roi_list = {[1]; [4]}
0004 
0005 % when old_roi_list is empty, the function sets all non-NaN non-zero
0006 % rois to be new_roi.
0007 
0008 if ~isempty(cstream)
0009     new_cstream = cstream(:,:);
0010     
0011     if isempty(old_roi_list)
0012         if ~iscell(new_roi_list) && (length(new_roi_list) == 1)
0013             assign_mask = cstream(:,2) > 0;
0014             new_cstream(assign_mask,2) = new_roi_list;
0015         else
0016             error(['Invalid_parameter: when old_roi_list is empty, ' ...
0017                 'the new_roi_list must not be one number']);
0018         end
0019     else
0020         for i = 1:length(old_roi_list)
0021             old_rois = old_roi_list{i};
0022             new_roi = new_roi_list{i};
0023 
0024             if length(new_roi) > 1
0025                 error('New roi can only be length 1');
0026             end
0027 
0028             assign_mask = ismember(cstream(:,2), old_rois);
0029             new_cstream(assign_mask,2) = new_roi;
0030         end
0031     end
0032 else
0033     new_cstream = cstream;
0034 end

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005