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)
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
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
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 );
0 commit comments