This class represents a sample of connectomes, with various properties and methods to handle their tangent and vectorized images.
Active bindings
connectomesConnectomes data
tangent_imagesTangent images data
vector_imagesVector images data
sample_sizeSample size
matrix_sizeMatrix size
mfd_dimManifold dimension
is_centeredCentering status
frechet_meanFrechet mean
riem_metricRiemannian Metric used
variationVariation of the sample
sample_covSample covariance
ref_pointReference point for tangent or vectorized images
distancesDistances to the Frechet mean
batch_sizeBatch size for compute_fmean
Methods
Method new()
Initialize a CSample object
Usage
CSample$new(
conns = NULL,
tan_imgs = NULL,
vec_imgs = NULL,
centered = NULL,
ref_pt = NULL,
metric_obj,
batch_size = NULL,
backend = NULL
)Arguments
connsA list of connectomes (default is NULL).
tan_imgsA list of tangent images (default is NULL).
vec_imgsA matrix whose rows are vectorized images (default is NULL).
centeredBoolean indicating whether tangent or vectorized images are centered (default is NULL).
ref_ptA connectome (default is identity)
metric_objObject of class
rmetricrepresenting the Riemannian metric used.batch_sizeThe batch size for compute_fmean (default is 32).
backendA DataBackend object (ListBackend or ParquetBackend). If NULL and conns is provided, a ListBackend will be created automatically.
Method load_connectomes_batched()
Load connectomes in parallel batches from ParquetBackend. This method is particularly useful for large Parquet-backed datasets where loading all matrices at once would be memory-prohibitive.
Arguments
indicesOptional vector of indices to load. If NULL (default), loads all matrices.
batch_sizeNumber of matrices to load per batch (default: 50). Larger batches use more memory but may be faster.
progressLogical indicating whether to show progress (default: FALSE).
Method compute_tangents()
This function computes the tangent images from the connectomes.
Usage
CSample$compute_tangents(ref_pt = default_ref_pt(private$p), progress = FALSE)Method compute_fmean()
This function computes the Frechet mean of the sample.
Usage
CSample$compute_fmean(
tol = 0.001,
max_iter = 100,
lr = 0.2,
batch_size = NULL,
progress = FALSE
)Arguments
tolTolerance for the convergence of the mean (default is 0.05).
max_iterMaximum number of iterations for the computation (default is 20).
lrLearning rate for the optimization algorithm (default is 0.2).
batch_sizeThe batch size (default is the instance's batch_size).
progressLogical indicating whether to show progress (default: FALSE).
Method change_ref_pt()
This function changes the reference point for the tangent images.
Method center()
Center the sample
Method compute_variation()
Compute Variation
Details
This function computes the variation of the sample. It first checks if the vector images are null, and if so, it computes the vectors, computing first the tangent images if necessary. If the sample is not centered, it centers the sample and recomputes the vectors. Finally, it calculates the variation as the mean of the sum of squares of the vector images. Error if vec_imgs is not specified.
Method compute_dists()
Compute distances
Details
This function computes the distances of the elements of the sample to the Frechet mean. It first checks if the vector images are null, and if so, it computes the vectors, computing first the tangent images if necessary. If the sample is not centered, it centers the sample and recomputes the vectors. Finally, it calculates the distances as the Euclidean norms of the vector images. Error if vec_imgs is not specified.
Method compute_sample_cov()
Compute Sample Covariance
Examples
## ------------------------------------------------
## Method `CSample$load_connectomes_batched`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# Create CSample with ParquetBackend
backend <- create_parquet_backend("my_data")
sample <- CSample$new(backend = backend, metric_obj = airm)
# Load first 100 matrices in batches of 20
conns <- sample$load_connectomes_batched(indices = 1:100, batch_size = 20)
} # }