|
| 1 | +% nix.RangeDimension class provides access to the RangeDimension properties. |
| 2 | +% |
| 3 | +% The RangeDimension covers cases when indexes of a dimension are mapped to other values |
| 4 | +% in a non-regular fashion. A use-case for this would be for example irregularly sampled |
| 5 | +% time-series or certain kinds of histograms. To achieve the mapping of the indexes an |
| 6 | +% array of mapping values must be provided. Those values are stored in the dimensions |
| 7 | +% ticks property. In analogy to the SampledDimension a unit and a label can be defined. |
| 8 | +% |
| 9 | +% An AliasRangeDimension is a special case of a RangeDimension that uses the data |
| 10 | +% stored in the invoking DataArray as ticks. This works only(!) if the DataArray |
| 11 | +% is 1D and the stored data is numeric. |
| 12 | +% |
| 13 | +% nix.RangeDimension dynamic properties |
| 14 | +% dimensionType (char): read-only, returns type of the dimension as string. |
| 15 | +% label (char): read-write, gets and sets the label of the dimension. |
| 16 | +% unit (char): read-write, gets and sets the unit of the dimension. |
| 17 | +% Only SI units are supported. |
| 18 | +% ticks ([double]): read-write, gets and sets the ticks of the dimension. |
| 19 | +% The ticks map the index of the data at the respective |
| 20 | +% dimension to other values. This can be used to store data |
| 21 | +% that is sampled at irregular intervals. |
| 22 | +% Note: Ticks must be ordered in ascending order. |
| 23 | +% isAlias (logical): read-only, returns True if the current Dimension is an |
| 24 | +% AliasRangeDimension, False otherwise. |
| 25 | +% |
| 26 | +% Examples: dt = currDataArray.dimensions{1}.dimensionType; |
| 27 | +% |
| 28 | +% getLabel = currDimension.label; |
| 29 | +% currDimension.dimensions{2}.label = 'Time'; |
| 30 | +% |
| 31 | +% getUnit = currDimension.unit; |
| 32 | +% currDimension.unit = 'ms'; |
| 33 | +% |
| 34 | +% getTicks = currDimension.ticks; |
| 35 | +% currDimension.ticks = [2 12 36 292]; |
| 36 | +% |
| 37 | +% See also nix.DataArray. |
| 38 | +% |
| 39 | +% |
1 | 40 | % Copyright (c) 2016, German Neuroinformatics Node (G-Node)
|
2 | 41 | %
|
3 | 42 | % All rights reserved.
|
|
7 | 46 | % LICENSE file in the root of the Project.
|
8 | 47 |
|
9 | 48 | classdef RangeDimension < nix.Entity
|
10 |
| - % RangeDimension nix RangeDimension object |
11 | 49 |
|
12 | 50 | properties (Hidden)
|
13 |
| - % namespace reference for nix-mx functions |
14 |
| - alias = 'RangeDimension' |
| 51 | + alias = 'RangeDimension' % nix-mx namespace to access RangeDimension specific nix backend functions. |
15 | 52 | end
|
16 | 53 |
|
17 | 54 | methods
|
|
27 | 64 | end
|
28 | 65 |
|
29 | 66 | function r = tickAt(obj, index)
|
| 67 | + % Returns the entry of the RangeDimension at a given index. |
| 68 | + % |
| 69 | + % index (double): The index of interest. |
| 70 | + % |
| 71 | + % Returns: (double) The tick value at the given index or an |
| 72 | + % error if the index is out of range of the |
| 73 | + % dimensions tick array. |
| 74 | + % |
| 75 | + % Example: getTickValue = currDimension.tickAt(101); |
| 76 | + |
30 | 77 | index = nix.Utils.handleIndex(index);
|
31 | 78 | fname = strcat(obj.alias, '::tickAt');
|
32 | 79 | r = nix_mx(fname, obj.nixhandle, index);
|
33 | 80 | end
|
34 | 81 |
|
35 | 82 | function r = indexOf(obj, position)
|
| 83 | + % Returns the index of the requested position or tick value. |
| 84 | + % |
| 85 | + % If the provided position is not a value in the tick array, the |
| 86 | + % method will return the index of the next tick larger than |
| 87 | + % the provided value. |
| 88 | + % |
| 89 | + % position (double): Tick value of the requested index. |
| 90 | + % |
| 91 | + % Returns: (double) The index of the provided position. |
| 92 | + % |
| 93 | + % Example: getIndexOfTick = currDimension.indexOf(12); |
| 94 | + |
36 | 95 | fname = strcat(obj.alias, '::indexOf');
|
37 |
| - r = nix_mx(fname, obj.nixhandle, position); |
| 96 | + idx = nix_mx(fname, obj.nixhandle, position); |
| 97 | + r = double(idx + 1); % convert index from c++ to Matlab style. |
38 | 98 | end
|
39 | 99 |
|
40 | 100 | function r = axis(obj, count, startIndex)
|
| 101 | + % Returns an array of values for axis labeling. |
| 102 | + % |
| 103 | + % count (double): Number of tick values to be returned. |
| 104 | + % startIndex (double): Starting index for the returned tick values. |
| 105 | + % |
| 106 | + % Returns: ([double]) Axis labeling values array. |
| 107 | + % |
| 108 | + % Example: currDimension.ticks = [4 8 15 16 23 42]; |
| 109 | + % getAxis = currDimension.axis(1, 5); %-- returns [23] |
| 110 | + % getAxis = currDimension.axis(3, 2); %-- returns [8 15 16] |
| 111 | + |
41 | 112 | if (nargin < 3)
|
42 | 113 | startIndex = 1;
|
43 | 114 | end
|
|
0 commit comments