Home > class > BCObject.m

BCObject

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 classdef BCObject < hgsetget
0002     properties
0003         dataset       % dataset number
0004         frame         % frame number
0005         id            % cell id unique in each frame
0006         col           % col or x position
0007         row           % row or y position
0008         area          % cell area in pixels
0009         shape         % orientation, major axis, minor axis
0010         type          % type of cell
0011         status        % behaviors
0012         
0013     end %properties
0014     
0015     methods
0016         %% Constructor
0017         function cell = BCObject (dataset, frame, id, col, row, area, shape)
0018         %BCOjbect constructor supports 4 types of different input arguments
0019         %   1) a structure with following numeric fields 'dataset', 'frame',
0020         %   'id','col','row'.
0021         %   2) an array which has length of 5
0022         %   3) individual argument of 5
0023         %   4) individual argument of 5 + additional 2 (area and shape)
0024         
0025        
0026         if nargin == 1
0027             % Handle structure
0028             if isstruct(dataset)
0029                 cell = BCObject(dataset.dataset,...
0030                                 dataset.frame,...
0031                                 dataset.id,...
0032                                 dataset.col,...
0033                                 dataset.row);
0034             end
0035             % Handle array
0036             if length(dataset) == 5
0037                 cell = BCObject(dataset(1),...
0038                                 dataset(2),...
0039                                 dataset(3),...
0040                                 dataset(4),...
0041                                 dataset(5));
0042             end
0043         elseif nargin >= 5
0044             % Make sure all input argument is number
0045             if ~isnumeric(dataset)
0046                 error('BCObject: Dataset should be an integer.');
0047             end
0048             if ~isnumeric(frame)
0049                 error('BCObject: Frame should be an integer.');
0050             end
0051             if ~isnumeric(id)
0052                 error('BCObject: Id should be an integer.');
0053             end
0054             if ~isnumeric(col)
0055                 error('BCObject: Col should be an integer.');
0056             end
0057             if ~isnumeric(row)
0058                 error('BCObject: Row should be an integer.');
0059             end
0060             % Handle 5 input arguments
0061             cell.dataset = dataset;
0062             cell.frame   = frame;
0063             cell.id      = id;
0064             cell.col     = col;
0065             cell.row     = row;
0066             % Handle 7 input arguments
0067             if nargin == 7                
0068                 cell.area    = area;
0069                 cell.shape   = shape;
0070             end
0071         else
0072             error('BCObject: Incorrect number of input arguments.');
0073         end %if
0074         
0075         end %constructor
0076                 
0077         %% Convert cell object to a row vector
0078         function array = toArray(cell)
0079             array = [cell.dataset, cell.frame, cell.id, cell.col, cell.row];
0080         end
0081         
0082         %% Convert cell object to a struct
0083         function str = toStruct(cell)
0084             str = struct('dataset', cell.dataset,...
0085                          'frame'  , cell.frame,...
0086                          'id'     , cell.id,...
0087                          'col'    , cell.col,...
0088                          'row'    , cell.row);            
0089         end
0090 
0091         %% Convert cell object to a string (to display)
0092         function str = toString(cell)
0093             str = ['Cell #', num2str(cell.id),...
0094                    ' (', num2str(cell.col),...
0095                    ', ', num2str(cell.row),...
0096                    ') in frame ', num2str(cell.frame),...
0097                    ' of dataset ', num2str(cell.dataset)];
0098                          
0099                          
0100         end
0101        
0102         %% Destroyer
0103         function die(cell)
0104             delete(cell);
0105         end
0106         
0107     end %methods
0108 end %classdef

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005