Skip to content

Commit 11b50f6

Browse files
committed
Demo Should Work
* Address minor typos. * Update default `User` to `'demo'` * Fix problem where `.rhs` or `.rhd` files were staying open during `nigeLab.Block/initChannels()` * Changed so `User` it tries to automatically parse username from local machine (depends on OS). * Added "Verbose" checks in many places to reduce potential command window output. * Fixed order of checks for `isempty` in DiskData subsasgn and subsref so that it works properly. * Fixed more typos, capitalization errors, or erroneous method calls/syntax errors. * Modified the `demo_nigeLab` script somewhat. * Fix bug with this subsref case: block = obj.Tank{:,:}; * Change `NumChannels`, `NumProbes`, and `ChannelID` from methods to Dependent Properties of `Block` so that they return the expected number of outputs. * Bugfixes for `nigeLab.libs.DashBoard` due to changes in subsref (primarily due to cases where `SelectedItems` was a 2-column array that was used to index tankObj{SelectedItems}, which behaves differently now).
1 parent ff1e1d3 commit 11b50f6

44 files changed

Lines changed: 1792 additions & 1194 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

+nigeLab/+defaults/Experiment.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222
pars.StandardPortNames = {'A','B','C','D'};
2323
pars.DefaultAcquisitionSystem = 'RHD'; % Important if things go wrong
2424
pars.SupportedFormats = {'.rhs','.rhd','tdt'};
25-
pars.User = 'MM'; % Default user
25+
pars.User = ''; % Default user is now parsed from local machine
2626

2727
%% Parse output
2828
if nargin < 1
2929
varargout = {pars};
30+
if strcmpi(pars.User,'demo')
31+
nigeLab.utils.cprintf('Errors*','\n\t[+defaults/Experiment.m]: ');
32+
nigeLab.utils.cprintf('[0.5 0.5 0.5]',...
33+
'Running using `''demo''` "User"\n');
34+
end
3035
else
3136
varargout = cell(1,nargin);
3237
f = fieldnames(pars);

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ function Show(obj)
471471
Index = obj.SelectionIndex(:,[2,3]);
472472
end
473473

474-
nigelObj = tankObj{Index};
474+
nigelObj = tankObj{Index(:,1),Index(:,2)};
475475

476476
end
477477

@@ -514,7 +514,7 @@ function Show(obj)
514514
case 2 % block
515515
animalIdx = unique(SelectedItems(:,1));
516516
animal = obj.Tank{animalIdx};
517-
block = obj.Tank{SelectedItems};
517+
block = obj.Tank{SelectedItems(:,1),SelectedItems(:,2)};
518518
end
519519
case 'index'
520520
SelectedItems = cat(1,obj.Tree.SelectedNodes.UserData);
@@ -1309,7 +1309,10 @@ function reloadTank(obj)
13091309
UserData = cellfun(@(x) x-1,{obj.Tree.Root.Children(indx:end).UserData},'UniformOutput',false);
13101310
[obj.Tree.Root.Children(indx:end).UserData]=deal(UserData{:});
13111311
else
1312-
nigeLab.utils.cprintf('SystemCommands','There is mimatch between the tank loaded in the dashboard and the one in memory.\n Try to reload it!');
1312+
nigeLab.utils.cprintf('SystemCommands*',...
1313+
['There is mimatch between the Tank loaded ' ...
1314+
'in nigelDash and the one in memory.\n ' ...
1315+
'Try to reload it!'],obj.Tank.Verbose);
13131316
end
13141317

13151318
case 'nigeLab.Block'
@@ -1322,7 +1325,10 @@ function reloadTank(obj)
13221325
UserData = cellfun(@(x) x-[0 1],{obj.Tree.Root.Children(indx(1)).Children(indx(2):end).UserData},'UniformOutput',false);
13231326
[obj.Tree.Root.Children(indx(1)).Children(indx(2):end).UserData]=deal(UserData{:});
13241327
else
1325-
nigeLab.utils.cprintf('SystemCommands','There is mimatch between the tank loaded in the dashboard and the one in memory.\n Try to reload it!');
1328+
nigeLab.utils.cprintf('SystemCommands*',...
1329+
['There is mimatch between the Tank loaded ' ...
1330+
'in nigelDash and the one in memory.\n ' ...
1331+
'Try to reload it!'],obj.Tank.Verbose);
13261332
end
13271333
end
13281334

@@ -1417,7 +1423,7 @@ function setBlockTable(obj,SelectedItems)
14171423
if nargin < 2
14181424
B = obj.getSelectedItems('obj');
14191425
else
1420-
B = obj.Tank{SelectedItems};
1426+
B = obj.Tank{SelectedItems(:,1),SelectedItems(:,2)};
14211427
end
14221428
tt = list(B);
14231429
if isempty(tt)
@@ -1562,6 +1568,9 @@ function treeSelectionFcn(obj,Tree,nodeEvent)
15621568
SelectedItems = cat(1,Tree.SelectedNodes.UserData);
15631569
blockObj = blockObj([blockObj.IsMasked]);
15641570
obj.SelectionIndex = obj.selectedItems2Index(SelectedItems);
1571+
else
1572+
vec = 1:blockObj.NumChannels;
1573+
obj.Mask = ismember(vec,blockObj.Mask);
15651574
end
15661575
evt = nigeLab.evt.treeSelectionChanged(...
15671576
obj.Tank,obj.SelectionIndex,'Block');

+nigeLab/+libs/@DiskData/DiskData.m

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
const_dim_ext double % (numeric) Extent of dimension to remain constant
7474
const_dim_idx double % (numeric) Index of dimension to remain constant
7575
dims_h5 double % (numeric) Dimensions (.size_ for h5)
76+
inf_dim_idx double % (numeric) Dimension that gets `inf` value for "maxsize"
7677
maxdims_h5 double % (numeric) Max. dims (depend on .type_)
7778
rank_h5 (1,1)double = 1 % (scalar double) H5 rank of memory space
7879
var_dim_idx double % (numeric) "Variable" dimension index (the one that extends)
@@ -91,7 +92,7 @@
9192
access_ (1,1) char = 'r' % Access type (default: 'r')
9293
writable_ logical % Whether file is writable
9394
overwrite_ (1,1) logical = false % By default, constructor does not overwrite if data is already present
94-
verbose_ (1,1) logical = true % Set false to suppress `getAttr` and `setAttr` print commands (maybe)
95+
verbose_ (1,1) logical = false % Set false to suppress `getAttr` and `setAttr` print commands (maybe)
9596
end
9697
% % % % % % % % % % END PROPERTIES %
9798

@@ -258,12 +259,18 @@
258259
nigeLab.libs.DiskData.throwImproperAssignmentError('class',...
259260
obj.class_,class(data));
260261
out = [];
262+
if nargout < 1
263+
clear out;
264+
end
261265
return;
262266
end
263267

264268
% If data (to append) is empty, don't do anything
265269
if isempty(data)
266270
out = [];
271+
if nargout < 1
272+
clear out;
273+
end
267274
return;
268275
end
269276

@@ -303,6 +310,9 @@
303310
if nargout > 0
304311
out = h5read(obj.diskfile_,varname_,...
305312
ones(1,obj.rank_h5),[inf,inf],ones(1,obj.rank_h5));
313+
else
314+
out = [];
315+
clear out; % Suppress output
306316
end
307317
end
308318

@@ -705,15 +715,17 @@ function lockData(obj,verbose)
705715
end
706716

707717
if exist(obj.diskfile_,'file')==0
708-
[p,f,e] = fileparts(obj.diskfile_);
709-
p = nigeLab.utils.shortenedPath(p);
710-
f = nigeLab.utils.shortenedName([f e]);
711-
nigeLab.sounds.play('pop',0.35);
712-
dbstack();
713-
nigeLab.utils.cprintf('Errors*','\t\t\t->\t[DISKDATA/LOCKDATA]: ');
714-
nigeLab.utils.cprintf('[0.55 0.55 0.55]',' Missing diskfile_ (');
715-
nigeLab.utils.cprintf('Keywords*','%s%s',p,f);
716-
nigeLab.utils.cprintf('[0.55 0.55 0.55]',')\n');
718+
if verbose
719+
[p,f,e] = fileparts(obj.diskfile_);
720+
p = nigeLab.utils.shortenedPath(p);
721+
f = nigeLab.utils.shortenedName([f e]);
722+
nigeLab.sounds.play('pop',0.35);
723+
dbstack();
724+
nigeLab.utils.cprintf('Errors*','\t\t\t->\t[DISKDATA/LOCKDATA]: ');
725+
nigeLab.utils.cprintf('[0.55 0.55 0.55]',' Missing diskfile_ (');
726+
nigeLab.utils.cprintf('Keywords*','%s%s',p,f);
727+
nigeLab.utils.cprintf('[0.55 0.55 0.55]',')\n');
728+
end
717729
return;
718730
end
719731

@@ -797,7 +809,7 @@ function unlockData(obj,verbose)
797809

798810
if exist(obj.diskfile_,'file')~=0
799811
fileattrib(obj.diskfile_,'+w');
800-
else
812+
elseif verbose
801813
[p,f,e] = fileparts(obj.diskfile_);
802814
p = nigeLab.utils.shortenedPath(p);
803815
f = nigeLab.utils.shortenedName([f e]);
@@ -807,7 +819,9 @@ function unlockData(obj,verbose)
807819
nigeLab.utils.cprintf('[0.55 0.55 0.55]',' Missing diskfile_ (');
808820
nigeLab.utils.cprintf('Keywords*','%s%s',p,f);
809821
nigeLab.utils.cprintf('[0.55 0.55 0.55]',')\n');
810-
return;
822+
return;
823+
else
824+
return;
811825
end
812826

813827
obj.writable_ = true;
@@ -1120,6 +1134,27 @@ function unlockData(obj,verbose)
11201134
value = fliplr(obj.size_);
11211135
end
11221136

1137+
% [DEPENDENT] Returns .inf_dim_idx property
1138+
function value = get.inf_dim_idx(obj)
1139+
%GET.INF_DIM_IDX Returns .inf_dim_idx property
1140+
%
1141+
% value = get(obj,'inf_dim_idx');
1142+
% --> Returns index of "inf" dimension. Depends on obj.type_
1143+
1144+
value = [];
1145+
if isempty(obj.type_)
1146+
return;
1147+
end
1148+
switch obj.type_
1149+
case 'MatFile'
1150+
value = []; % Size remains fixed
1151+
case 'Hybrid'
1152+
value = 2; % Append along columns
1153+
case 'Event'
1154+
value = 1; % Append along rows
1155+
end
1156+
end
1157+
11231158
% [DEPENDENT] Returns .maxdims_h5 property
11241159
function value = get.maxdims_h5(obj)
11251160
%GET.MAXDIMS_H5 Returns .maxdims_h5 property (from .size_,.type_)
@@ -1135,7 +1170,7 @@ function unlockData(obj,verbose)
11351170
end
11361171
% Value depends on obj.type_
11371172
value = obj.size_;
1138-
value(obj.var_dim_idx) = inf;
1173+
value(obj.inf_dim_idx) = inf;
11391174
end
11401175

11411176
% [DEPENDENT] Returns .rank_h5 property
@@ -1475,7 +1510,7 @@ function unlockData(obj,verbose)
14751510
end
14761511

14771512
% [DEPENDENT] Assigns .File property (does nothing)
1478-
function set.File(~,~)
1513+
function set.File(obj,~)
14791514
%SET.FILE (does nothing)
14801515
if obj.verbose_
14811516
nigeLab.sounds.play('pop',2.7);
@@ -1575,7 +1610,7 @@ function unlockData(obj,verbose)
15751610
end
15761611

15771612
% [DEPENDENT] Assigns .chunks_h5 property (does nothing)
1578-
function set.chunks_h5(~,~)
1613+
function set.chunks_h5(obj,~)
15791614
%SET.CHUNKS_H5 (does nothing)
15801615
if obj.verbose_
15811616
nigeLab.sounds.play('pop',2.7);
@@ -1588,7 +1623,7 @@ function unlockData(obj,verbose)
15881623
end
15891624

15901625
% [DEPENDENT] Assigns .class_h5 property (does nothing)
1591-
function set.class_h5(~,~)
1626+
function set.class_h5(obj,~)
15921627
%SET.CLASS_H5 (does nothing)
15931628
if obj.verbose_
15941629
nigeLab.sounds.play('pop',2.7);
@@ -1601,7 +1636,7 @@ function unlockData(obj,verbose)
16011636
end
16021637

16031638
% [DEPENDENT] Assigns .const_dim_ext property (does nothing)
1604-
function set.const_dim_ext(~,~)
1639+
function set.const_dim_ext(obj,~)
16051640
%SET.CONST_DIM_EXT (does nothing)
16061641
if obj.verbose_
16071642
nigeLab.sounds.play('pop',2.7);
@@ -1614,7 +1649,7 @@ function unlockData(obj,verbose)
16141649
end
16151650

16161651
% [DEPENDENT] Assigns .const_dim_idx property (does nothing)
1617-
function set.const_dim_idx(~,~)
1652+
function set.const_dim_idx(obj,~)
16181653
%SET.CONST_DIM_IDX (does nothing)
16191654
if obj.verbose_
16201655
nigeLab.sounds.play('pop',2.7);
@@ -1636,7 +1671,7 @@ function unlockData(obj,verbose)
16361671
end
16371672

16381673
% [DEPENDENT] Assigns .dims_h5 property (does nothing)
1639-
function set.dims_h5(~,~)
1674+
function set.dims_h5(obj,~)
16401675
%SET.DIMS_H5 (does nothing)
16411676
if obj.verbose_
16421677
nigeLab.sounds.play('pop',2.7);
@@ -1648,8 +1683,21 @@ function unlockData(obj,verbose)
16481683
end
16491684
end
16501685

1686+
% [DEPENDENT] Assigns .inf_dim_idx property (does nothing)
1687+
function set.inf_dim_idx(obj,~)
1688+
%SET.INF_DIM_IDX (does nothing)
1689+
if obj.verbose_
1690+
nigeLab.sounds.play('pop',2.7);
1691+
dbstack();
1692+
nigeLab.utils.cprintf('Errors*','[DISKDATA]: ');
1693+
nigeLab.utils.cprintf('Errors',...
1694+
'Failed attempt to set DEPENDENT property:inf_dim_idx\n');
1695+
fprintf(1,'\n');
1696+
end
1697+
end
1698+
16511699
% [DEPENDENT] Assigns .maxdims_h5 property (does nothing)
1652-
function set.maxdims_h5(~,~)
1700+
function set.maxdims_h5(obj,~)
16531701
%SET.MAXDIMS_H5 (does nothing)
16541702
if obj.verbose_
16551703
nigeLab.sounds.play('pop',2.7);
@@ -1706,7 +1754,7 @@ function unlockData(obj,verbose)
17061754
end
17071755

17081756
% [DEPENDENT] Assigns .rank_h5 property (does nothing)
1709-
function set.rank_h5(~,~)
1757+
function set.rank_h5(obj,~)
17101758
%SET.RANK_H5 (does nothing)
17111759
if obj.verbose_
17121760
nigeLab.sounds.play('pop',2.7);
@@ -1730,7 +1778,7 @@ function unlockData(obj,verbose)
17301778
end
17311779

17321780
% [DEPENDENT] Assigns .var_dim_idx property (does nothing)
1733-
function set.var_dim_idx(~,~)
1781+
function set.var_dim_idx(obj,~)
17341782
%SET.VAR_DIM_IDX (does nothing)
17351783
if obj.verbose_
17361784
nigeLab.sounds.play('pop',2.7);
@@ -1836,6 +1884,12 @@ function addFileNameAttributes(obj,fName)
18361884
curSz = sz;
18371885
end
18381886
end
1887+
elseif numel(info.Datasets) < 1
1888+
fsize = 0;
1889+
dname = '';
1890+
dclass = 'unknown';
1891+
sz = [0 0];
1892+
return;
18391893
else
18401894
idx = 1;
18411895
end
@@ -1978,12 +2032,12 @@ function initHybridFile(obj,fName)
19782032
% Now, create h5 dataset with (correct) desired property list
19792033
if strcmp(obj.type_,'MatFile') % MatFile ~ not extendable
19802034
h5create(fName, varname_, obj.maxdims_h5,...
1981-
'DataType',obj.class_,'FillValue',0);
2035+
'DataType',obj.class_,'FillValue',zeros(1,1,obj.class_));
19822036

19832037
else % Event, Hybrid
19842038
h5create(fName, varname_, obj.maxdims_h5,...
19852039
'ChunkSize',obj.chunks_h5,'DataType',obj.class_,...
1986-
'Deflate',obj.compress_,'FillValue',0);
2040+
'Deflate',obj.compress_,'FillValue',zeros(1,1,obj.class_));
19872041
end
19882042
% Denote that the file is empty (initialized only)
19892043
obj.Empty = ones(1,1,'int8');
@@ -2028,8 +2082,10 @@ function initHybridFile(obj,fName)
20282082
% By default: obj.name_ = 'data'
20292083
data = ones(1,1,obj.class_); %#ok<PROPLC>
20302084
save(fName,'data','-v7.3');
2031-
% Switch to `Hybrid`, since this MUST be expanded
2032-
obj.type_ = 'Hybrid';
2085+
if strcmp(obj.type_,'MatFile')
2086+
% Switch to `Hybrid`, since this MUST be expanded
2087+
obj.type_ = 'Hybrid';
2088+
end
20332089
end
20342090

20352091
obj.diskfile_ = fName;
@@ -2063,13 +2119,11 @@ function saveFile(obj,fName,data,type)
20632119
if nargin < 4
20642120
type = obj.type_;
20652121
end
2066-
20672122
if isempty(data)
20682123
error(['nigeLab:' mfilename ':BadInit'],...
20692124
['[DISKDATA]: Cannot write EMPTY array to file. '...
20702125
'\t->\t(Check constructor)\n']);
2071-
end
2072-
2126+
end
20732127
if exist(fName,'file')~=0
20742128
if obj.overwrite_
20752129
delete(fName);

+nigeLab/+libs/@DiskData/subsasgn.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,22 @@
1616
%
1717
% This should effectively work as a `save` method for DiskData class
1818

19+
if strcmp(S(1).type,'.') % Check for '.'-indexed property assignment
20+
mc = ?nigeLab.libs.DiskData;
21+
diskProps = {mc.PropertyList.Name};
22+
includedPropNames = setdiff(diskProps,...
23+
{'type','value','tag','ts','snippet','data'});
24+
if any(strcmp(includedPropNames,S(1).subs))
25+
obj = builtin('subsasgn',obj,S,data);
26+
return;
27+
end
28+
end
29+
1930
% Do validation that the DiskData object can be assigned to
20-
if isempty(obj)
31+
if strcmp(obj.type_,'MatFile') && (length(obj)==0) %#ok<ISMT>
32+
nigeLab.libs.DiskData.throwImproperAssignmentError('empty');
33+
return;
34+
elseif builtin('isempty',obj)
2135
nigeLab.libs.DiskData.throwImproperAssignmentError('empty');
2236
return;
2337
elseif ~isvalid(obj)

0 commit comments

Comments
 (0)