Skip to content

Commit 365e215

Browse files
committed
Bugfixes
* Add `nigeLab.libs.DashBoard/empty()` static method, as well as `nigeLab.Sort/empty()` static method. * Fix syntax on `repmat` calls due to warning about future Matlab release incompatibilities. * Fix assignment in property set calls from empty double assignment to .empty() versions of `DashBoard` and `Sort` for the corresponding properties of `nigeLab.nigelObj`. * Resolve issue where `_Obj.mat` was being used to set `.FolderIdentifier` property incorrectly + This was resulting in an empty `.mat` file at the `Block` level, which had the same contents as the `.nigelFile` that should be there. Bugfix
1 parent e2fe051 commit 365e215

5 files changed

Lines changed: 100 additions & 32 deletions

File tree

+nigeLab/+libs/@DashBoard/DashBoard.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@
104104

105105
% Check input
106106
if nargin < 1
107-
obj = nigeLab.libs.DashBoard([0,0]); % Empty DashBoard
108-
close(gcf); % If a figure is opened
107+
obj = nigeLab.libs.DashBoard.empty(); % Empty DashBoard
109108
return; % Should always be called from tankObj anyways
110109
elseif isnumeric(tankObj)
111110
dims = tankObj;
111+
if numel(dims) == 1
112+
dims = [dims,0];
113+
end
112114
obj = repmat(obj,dims);
115+
close(gcf); % If a figure is opened
113116
return;
114117
end
115118

@@ -218,7 +221,7 @@ function delete(obj)
218221
% Finally, notify the TANK that GUI is closed (if it exists)
219222
if ~isempty(obj.Tank)
220223
if isvalid(obj.Tank)
221-
obj.Tank.GUI = [];
224+
set(obj.Tank,'GUI',nigeLab.libs.DashBoard.empty);
222225
end
223226
end
224227
end
@@ -2162,6 +2165,14 @@ function addToNode(nodeObj,name)
21622165

21632166
% STATIC,PUBLIC
21642167
methods (Static,Access=public)
2168+
function obj = empty()
2169+
%EMPTY Returns empty object
2170+
%
2171+
% obj = nigeLab.libs.DashBoard.empty();
2172+
2173+
obj = nigeLab.libs.DashBoard([0 0]);
2174+
end
2175+
21652176
% Translates "SelectedItems" (nodes UserData) to "selection index"
21662177
function sel = selectedItems2Index(items)
21672178
% SELECTEDITEMS2INDEX Returns the "indexing" for SelectedItems

+nigeLab/+libs/@splitMultiAnimalsUI/splitMultiAnimalsUI.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
end
1111

1212
properties (Access = private,SetObservable,AbortSet)
13-
animalObj nigeLab.Animal
13+
animalObj % nigeLab.Animal
1414
end
1515

1616
properties (Access = private)
17-
blockObj nigeLab.Block
17+
blockObj % nigeLab.Block
1818
DashObj nigeLab.libs.DashBoard
1919
AcceptBtn matlab.ui.control.UIControl % pushbutton
2020
ApplyToAllBtn matlab.ui.control.UIControl % pushbutton

+nigeLab/@Block/scoreVideo.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
if any(~blockObj.Status.(scoringFieldName))
2020
error('Not all %s files have been created yet.',scoringFieldName);
2121
end
22-
23-
2422
%MAKE UI WINDOW AND DISPLAY CONTAINER
2523
fig=figure('Name','Behavior Scoring',...
2624
'NumberTitle','off',...

+nigeLab/@Sort/Sort.m

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
if nargin > 0
7373
if isnumeric(nigelObj) % Initialize
7474
dims = nigelObj;
75+
if numel(dims) == 1
76+
dims = [dims,0];
77+
end
7578
sortObj = repmat(sortObj,dims);
79+
close(gcf);
7680
return;
7781
end
7882

@@ -102,8 +106,7 @@
102106
% 'sortObj array not created successfully.');
103107
% end
104108
else % Therefore, if it is given without inputs, it is for init
105-
sortObj = nigeLab.Sort([0,0]); % Empty
106-
close(gcf);
109+
sortObj = nigeLab.Sort.empty(); % Empty
107110
return;
108111
end
109112

@@ -135,7 +138,7 @@ function delete(sortObj)
135138

136139
% Remove association from input
137140
if ~isempty(sortObj.Input)
138-
set(sortObj.Input,'SortGUI',[]);
141+
set(sortObj.Input,'SortGUI',nigeLab.Sort.empty());
139142
end
140143
end
141144

@@ -221,5 +224,16 @@ function delete(sortObj)
221224

222225
channelName = parseChannelName(sortObj); % Get all channel names
223226
end
227+
228+
% STATIC, PUBLIC
229+
methods (Static,Access=public)
230+
function obj = empty()
231+
%EMPTY Returns empty `nigeLab.Sort` object handle
232+
%
233+
% obj = nigeLab.Sort.empty();
234+
235+
obj = nigeLab.Sort([0 0]);
236+
end
237+
end
224238
% % % % % % % % % % END METHODS% % %
225239
end

+nigeLab/@nigelObj/nigelObj.m

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
properties (GetAccess=public,SetAccess=protected)
5757
Fields cell = nigeLab.nigelObj.Default('Fields') % Specific things to record
5858
FieldType cell = nigeLab.nigelObj.Default('FieldType') % "Types" corresponding to Fields elements
59-
FolderIdentifier char % '.nigelBlock', '.nigelAnimal', or '.nigelTank'
6059
IDInfo (1,1) struct % Struct parsed from ID file
6160
HasParsFile (1,1) logical=false % Flag --> True if _Pars.mat exists
6261
HasParsInit (1,1) struct % Flag struct --> .param is True if obj.updateParams('param') has been run
@@ -73,17 +72,16 @@
7372

7473
% DEPENDENT,PUBLIC
7574
properties (Dependent,Access=public)
76-
File char % Full file of _Block.mat, _Animal.mat, or _Tank.mat file
77-
GUI nigeLab.libs.DashBoard % Handle to nigeLab.libs.DashBoard GUI (nigelObj.nigelDash method)
78-
Input char % Path to input file or folder
79-
Name char % Name of the obj (char array)
80-
OnRemote (1,1)logical % Is this object running a job on remote worker?
81-
Output char % Path to output folder (same as .Paths.SaveLoc)
82-
Pars (1,1)struct % Parameters struct
83-
Paths (1,1)struct % Detailed paths specifications
84-
ShortFile char % Shortened filename
85-
SortGUI nigeLab.Sort % Handle to nigeLab.Sort GUI (nigelObj.Sort method)
86-
Type char %'Block', 'Animal' or 'Tank'
75+
File char % Full file of _Block.mat, _Animal.mat, or _Tank.mat file
76+
FolderIdentifier char % '.nigelBlock', '.nigelAnimal', or '.nigelTank'
77+
Input char % Path to input file or folder
78+
Name char % Name of the obj (char array)
79+
OnRemote (1,1) logical % Is this object running a job on remote worker?
80+
Output char % Path to output folder (same as .Paths.SaveLoc)
81+
Pars (1,1) struct % Parameters struct
82+
Paths (1,1) struct % Detailed paths specifications
83+
ShortFile char % Shortened filename
84+
Type char %'Block', 'Animal' or 'Tank'
8785
end
8886

8987
% DEPENDENT,PUBLIC/PROTECTED
@@ -115,6 +113,12 @@
115113
OutPrompt char % To print for output path prompts
116114
end
117115

116+
% DEPENDENT,TRANSIENT,PUBLIC (GUI)
117+
properties (Dependent,Transient,Access=public)
118+
GUI nigeLab.libs.DashBoard % Handle to nigeLab.libs.DashBoard GUI (nigelObj.nigelDash method)
119+
SortGUI nigeLab.Sort % Handle to nigeLab.Sort GUI (nigelObj.Sort method)
120+
end
121+
118122
% DEPENDENT,TRANSIENT,SETOBSERVABLE,PUBLIC (Children Objects)
119123
properties (Dependent,Transient,SetObservable,Access=public)
120124
Children % Array of "child" objects
@@ -358,10 +362,6 @@
358362
end
359363
end
360364

361-
% Set these after parsing <'Name',value> so they cannot be
362-
% overwritten manually by accident, or set to different values.
363-
obj.FolderIdentifier = sprintf('.nigel%s',obj.Type);
364-
365365
% Check for input passed via subclass constructor
366366
if isstruct(inPath) % Then this came from loadobj
367367
obj_ = inPath;
@@ -695,6 +695,21 @@ function delete(obj)
695695
end
696696
end
697697

698+
% [DEPENDENT] Get method for .FolderIdentifier (.nigelFile)
699+
function value = get.FolderIdentifier(obj)
700+
%GET.FOLDERIDENTIFIER Returns .nigel[Type] char array
701+
%
702+
% value = get(obj,'FolderIdentifier');
703+
% --> value is either '.nigelBlock', '.nigelAnimal', or
704+
% '.nigelTank'
705+
706+
if isempty(obj.Type)
707+
value = '.nigelFile';
708+
return;
709+
end
710+
value = sprintf('.nigel%s',obj.Type);
711+
end
712+
698713
% [DEPENDENT] Get method for .FileExt (recording file type)
699714
function value = get.FileExt(obj)
700715
%GET.FILEEXT Returns char array of file extension
@@ -1599,7 +1614,37 @@ function getdisp(obj)
15991614
if ~ischar(value)
16001615
return;
16011616
end
1602-
[obj.Output,~,obj.FolderIdentifier]=fileparts(value);
1617+
[path,f,e]=fileparts(value);
1618+
fparts = strsplit(f,'_');
1619+
1620+
if ismember(fparts{end},{'Block','Animal','Tank'})
1621+
obj.Type = fparts{end};
1622+
obj.Output = path;
1623+
else
1624+
p = nigeLab.utils.shortenedPath(path);
1625+
nigeLab.utils.cprintf('Errors*',...
1626+
'[SET.FILE]: Bad File name (%s/%s)\n',p,[f e]);
1627+
return;
1628+
end
1629+
1630+
end
1631+
1632+
% [DEPENDENT] Set method for .FolderIdentifier (.nigelFile)
1633+
function set.FolderIdentifier(obj,value)
1634+
%SET.FOLDERIDENTIFIER Sets .nigelFile char array
1635+
%
1636+
% set(obj,'FolderIdentifier','.nigelTank');
1637+
% --> Set folder identifier for 'Tank' type nigelObj
1638+
1639+
if isempty(value)
1640+
return;
1641+
elseif ~ischar(value)
1642+
return;
1643+
end
1644+
value = strrep(value,'.nigel','');
1645+
if ismember(value,{'Block','Animal','Tank'})
1646+
set(obj,'Type',value);
1647+
end
16031648
end
16041649

16051650
% [DEPENDENT] Set method for .FileExt (recording binary)
@@ -1629,14 +1674,14 @@ function getdisp(obj)
16291674

16301675
if isempty(value)
16311676
if ~isempty(obj.GUIContainer)
1632-
obj.GUIContainer(:) = []; % Remove handle association
1677+
obj.GUIContainer = nigeLab.libs.DashBoard.empty();
16331678
end
16341679
obj.IsDashOpen = false; % Set flag to false
16351680
else
16361681
if obj.IsDashOpen
16371682
obj.IsDashOpen = isvalid(value);
16381683
if ~obj.IsDashOpen
1639-
value = [];
1684+
value = nigeLab.libs.DashBoard.empty();
16401685
end
16411686
% Store association to handle object
16421687
obj.GUIContainer = value;
@@ -2142,7 +2187,7 @@ function getdisp(obj)
21422187

21432188
for i = 1:numel(obj)
21442189
if isempty(value)
2145-
obj(i).SortGUIContainer(:) = []; % Remove handle association
2190+
obj(i).SortGUIContainer = nigeLab.Sort.empty(); % Remove handle association
21462191
if obj(i).IsDashOpen % Make sure Dash is un-hidden
21472192
visible = obj(i).GUI.Visible;
21482193
if strcmpi(visible,'off')
@@ -2188,7 +2233,7 @@ function getdisp(obj)
21882233

21892234
if ~ischar(value)
21902235
error(['nigeLab:' mfilename ':BadClass'],...
2191-
'nigelObj.Type must be char');
2236+
'[SET.TYPE]: nigelObj.Type must be char');
21922237
end
21932238

21942239
if ~ismember(value,{'Block','Animal','Tank'})
@@ -2197,7 +2242,7 @@ function getdisp(obj)
21972242
value = strrep(class(obj),'nigeLab.','');
21982243
if ~ismember(value,{'Block','Animal','Tank','nigelObj'})
21992244
error(['nigeLab:' mfilename ':BadType'],...
2200-
['Unexpected Type: %s\n' ...
2245+
['[SET.TYPE]: Unexpected Type: %s\n' ...
22012246
'\t-->\tMust be: ''Block,'' ''Animal,'' or ''Tank'''],...
22022247
value);
22032248
end

0 commit comments

Comments
 (0)