|
1 | | -# Construct a ModelArray object |
| 1 | +# ModelArray class |
2 | 2 |
|
3 | | -Load element-wise data from an .h5 file as a \`ModelArray\` object. |
| 3 | +A ModelArray wraps one or more element-wise scalar matrices (e.g., FD, |
| 4 | +FC, log_FC for fixel data) read lazily via DelayedArray, along with any |
| 5 | +previously saved analysis results. The object holds references to the |
| 6 | +underlying HDF5 file and reads data on demand, making it suitable for |
| 7 | +large-scale neuroimaging datasets. |
| 8 | + |
| 9 | +Reads scalar matrices and (optionally) saved analysis results from an |
| 10 | +HDF5 file and returns a ModelArray object. |
4 | 11 |
|
5 | 12 | ## Usage |
6 | 13 |
|
7 | 14 | ``` r |
| 15 | +ModelArray(filepath, scalar_types = c("FD"), analysis_names = character(0)) |
| 16 | + |
8 | 17 | ModelArray(filepath, scalar_types = c("FD"), analysis_names = character(0)) |
9 | 18 | ``` |
10 | 19 |
|
11 | 20 | ## Arguments |
12 | 21 |
|
13 | 22 | - filepath: |
14 | 23 |
|
15 | | - Path to an .h5 file |
| 24 | + Character. Path to an existing HDF5 (`.h5`) file containing |
| 25 | + element-wise scalar data. |
16 | 26 |
|
17 | 27 | - scalar_types: |
18 | 28 |
|
19 | | - Expected scalars |
| 29 | + Character vector. Names of scalar groups to read from `/scalars/` in |
| 30 | + the HDF5 file. Default is `c("FD")`. Must match group names in the |
| 31 | + file; verify with `rhdf5::h5ls(filepath)`. |
20 | 32 |
|
21 | 33 | - analysis_names: |
22 | 34 |
|
23 | | - The subfolder names for results in the .h5 file. If empty (default), |
24 | | - results are not read. |
| 35 | + Character vector. Subfolder names under `/results/` to load. Default |
| 36 | + is `character(0)` (no results loaded). |
25 | 37 |
|
26 | 38 | ## Value |
27 | 39 |
|
28 | | -A \`ModelArray\` object |
| 40 | +A ModelArray object. |
| 41 | + |
| 42 | +## Details |
| 43 | + |
| 44 | +ModelArray is an S4 class that represents element-wise scalar data and |
| 45 | +associated statistical results backed by an HDF5 file on disk. |
| 46 | + |
| 47 | +Each scalar in the HDF5 file is stored at `/scalars/<name>/values` as a |
| 48 | +matrix of elements (rows) by source files (columns). Source filenames |
| 49 | +are read from HDF5 attributes or companion datasets. Analysis results, |
| 50 | +if present, live under `/results/<analysis_name>/results_matrix`. |
| 51 | + |
| 52 | +ModelArray objects are typically created with the `ModelArray` |
| 53 | +constructor function. Element-wise models are fit with |
| 54 | +[`ModelArray.lm`](https://pennlinc.github.io/ModelArray/reference/ModelArray.lm.md), |
| 55 | +[`ModelArray.gam`](https://pennlinc.github.io/ModelArray/reference/ModelArray.gam.md), |
| 56 | +or |
| 57 | +[`ModelArray.wrap`](https://pennlinc.github.io/ModelArray/reference/ModelArray.wrap.md). |
| 58 | + |
| 59 | +The constructor reads each scalar listed in `scalar_types` from |
| 60 | +`/scalars/<scalar_type>/values` in the HDF5 file, wrapping them as |
| 61 | +DelayedArray objects for lazy access. Source filenames are extracted |
| 62 | +from HDF5 attributes or companion datasets. |
| 63 | + |
| 64 | +If `analysis_names` is non-empty, saved results are read from |
| 65 | +`/results/<name>/results_matrix` along with column name metadata. |
| 66 | + |
| 67 | +**Debugging tip:** If you encounter |
| 68 | +`"Error in h(simpleError(msg, call)) : error in evaluating the argument 'seed'..."`, |
| 69 | +check that `scalar_types` matches the groups present in the file. |
| 70 | +Inspect with `rhdf5::h5ls(filepath)`. |
| 71 | + |
| 72 | +## Slots |
| 73 | + |
| 74 | +- `sources`: |
| 75 | + |
| 76 | + A named list of character vectors. Each element corresponds to a |
| 77 | + scalar and contains the source filenames (one per input file/subject). |
| 78 | + |
| 79 | +- `scalars`: |
| 80 | + |
| 81 | + A named list of DelayedArray matrices. Each matrix has elements as |
| 82 | + rows and source files as columns. |
| 83 | + |
| 84 | +- `results`: |
| 85 | + |
| 86 | + A named list of analysis results. Each element is itself a list |
| 87 | + containing at minimum `results_matrix` (a DelayedArray). |
| 88 | + |
| 89 | +- `path`: |
| 90 | + |
| 91 | + Character. Path(s) to the HDF5 file(s) on disk. |
| 92 | + |
| 93 | +## See also |
| 94 | + |
| 95 | +`ModelArray` for the constructor, |
| 96 | +[`ModelArray.lm`](https://pennlinc.github.io/ModelArray/reference/ModelArray.lm.md), |
| 97 | +[`ModelArray.gam`](https://pennlinc.github.io/ModelArray/reference/ModelArray.gam.md), |
| 98 | +[`ModelArray.wrap`](https://pennlinc.github.io/ModelArray/reference/ModelArray.wrap.md) |
| 99 | +for analysis, |
| 100 | +[`scalars`](https://pennlinc.github.io/ModelArray/reference/scalars.md), |
| 101 | +[`sources`](https://pennlinc.github.io/ModelArray/reference/sources.md), |
| 102 | +[`results`](https://pennlinc.github.io/ModelArray/reference/results.md) |
| 103 | +for accessors. |
| 104 | + |
| 105 | +ModelArray for the class definition, |
| 106 | +[`h5summary`](https://pennlinc.github.io/ModelArray/reference/h5summary.md) |
| 107 | +for inspecting an HDF5 file without loading, |
| 108 | +[`scalars`](https://pennlinc.github.io/ModelArray/reference/scalars.md), |
| 109 | +[`sources`](https://pennlinc.github.io/ModelArray/reference/sources.md) |
| 110 | +for accessing loaded data. |
| 111 | + |
| 112 | +## Examples |
| 113 | + |
| 114 | +``` r |
| 115 | +if (FALSE) { # \dontrun{ |
| 116 | +ma <- ModelArray("path/to/data.h5", scalar_types = c("FD", "FC")) |
| 117 | +ma |
| 118 | +scalars(ma) |
| 119 | +} # } |
| 120 | +``` |
0 commit comments