htfa.fit¶
- htfa.fit(data, K=50, coords=None, mask=None, stack=False, channels='gray', spacing=None, groups=None, subject_ids=None, **model_kwargs)[source]¶
Load
dataand fit TFA (one subject) or HTFA (several).- Parameters:
- data, coords, mask, stack, channels, spacing
As in
htfa.io.load.- Kint
Number of factors.
- groups, subject_idsoptional
Nested groups of subjects and subject identifiers, passed to
htfa.HTFA.fit(several subjects only);groupsneedstemplate_update='fixed'or'empirical'. Withgroups=None, nested folders supply group paths automatically and the template update defaults to'fixed'. Explicit groups override folder metadata;groups=Falsedisables inference. A single subject still fits TFA. AGroupTree.from_pathstree supports unequal hierarchy depths.- **model_kwargs
Passed to
htfa.TFAorhtfa.HTFA; an unknown key raisesTypeError. One subject fits a TFA and several fit an HTFA, so HTFA-only kwargs (e.g.max_global_iter) fail for a single subject. Both takekernelandn_components(factor shapes and mixtures).
- Returns:
- HTFAResults
Examples
>>> import numpy as np >>> from htfa import fit >>> img = np.random.default_rng(0).random((6, 6, 6, 8)) + 1 >>> res = fit(img, K=2, standardize=False, init="power", max_iter=5) >>> res.connectivity().shape (2, 2)