Skip to contents

Generic function for writing neuroimaging datasets to HDF5 format

Write a single NeuroVec object with clustering to HDF5

Write multiple NeuroVec objects with clustering to HDF5

Export an existing H5ParcellatedMultiScan object to a new HDF5 file

Export an existing H5NeuroVec object to a new HDF5 file

Export an existing H5NeuroVol object to a new HDF5 file

Write a LatentNeuroVec object to HDF5

Usage

write_dataset(x, ...)

# S4 method for class 'NeuroVec'
write_dataset(
  x,
  file,
  clusters,
  mask = NULL,
  summary = FALSE,
  summary_fun = mean,
  scan_name = "scan_001",
  compression = 4,
  ...
)

# S4 method for class 'list'
write_dataset(
  x,
  file,
  clusters,
  mask = NULL,
  summary = FALSE,
  summary_fun = mean,
  scan_names = NULL,
  compression = 4,
  ...
)

# S4 method for class 'H5ParcellatedMultiScan'
write_dataset(x, file, overwrite = FALSE, ...)

# S4 method for class 'H5NeuroVec'
write_dataset(x, file, overwrite = FALSE, ...)

# S4 method for class 'H5NeuroVol'
write_dataset(x, file, overwrite = FALSE, ...)

# S4 method for class 'LatentNeuroVec'
write_dataset(x, file, compression = 6, ...)

Arguments

x

A LatentNeuroVec object

...

Additional arguments passed to as_h5

file

Output HDF5 file path

clusters

A ClusteredNeuroVol object defining spatial clusters

mask

Optional LogicalNeuroVol mask (extracted from first element if not provided)

summary

Logical, whether to summarize data by clusters (default: FALSE)

summary_fun

Function to use for summarization (default: mean)

scan_name

Name for the scan (default: "scan_001")

compression

Compression level 0-9 (default: 6)

scan_names

Character vector of scan names (auto-generated if not provided)

overwrite

Logical, whether to overwrite existing file (default: FALSE)

Value

Invisible NULL or file path, depending on the method

Invisible NULL

Invisible NULL

Invisible file path

Invisible file path

Invisible file path

Invisible NULL

Examples

if (FALSE) { # \dontrun{
# Write full voxel-level data
write_dataset(nvec, file = "output.h5", clusters = cvol)

# Write summarized data (mean per cluster)
write_dataset(nvec, file = "output_summary.h5", clusters = cvol, summary = TRUE)

# Use median for summarization
write_dataset(nvec, file = "output_median.h5", clusters = cvol, 
              summary = TRUE, summary_fun = median)
} # }

if (FALSE) { # \dontrun{
# Write multiple scans
scans <- list(nvec1, nvec2, nvec3)
write_dataset(scans, file = "multi_scan.h5", clusters = cvol)

# With custom names and summary
write_dataset(scans, file = "multi_summary.h5", clusters = cvol,
              summary = TRUE, scan_names = c("rest", "task1", "task2"))
} # }

if (FALSE) { # \dontrun{
# Export existing H5 object to new file
h5_obj <- H5ParcellatedMultiScan("existing.h5")
write_dataset(h5_obj, file = "copy.h5")
} # }

if (FALSE) { # \dontrun{
# Write latent representation
write_dataset(latent_nvec, file = "latent.h5")
} # }