Skip to content

Commit

Permalink
Refactor verbosity handling in SparseUOT and SparseTemplateAlignment;…
Browse files Browse the repository at this point in the history
… ensure consistent verbose flag usage
  • Loading branch information
pbarbarant committed Feb 3, 2025
1 parent 142bc3c commit 971d886
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fmralign/sparse_pairwise_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def fit(self, X, Y):
self.fit_ = SparseUOT(
sparsity_mask=sparsity_mask,
device=self.device,
verbose=self.verbose,
verbose=True if self.verbose > 0 else False,
**self.kwargs,
).fit(X, Y)
else:
Expand Down
9 changes: 5 additions & 4 deletions fmralign/sparse_template_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def _fit_sparse_template(
alignment_method="sparse_uot",
n_iter=2,
scale_template=False,
verbose=False,
**kwargs,
):
n_subjects = len(subjects_data)
if alignment_method != "sparse_uot":
raise ValueError(f"Unknown alignment method: {alignment_method}")
subjects_estimators = [
SparseUOT(sparsity_mask, **kwargs) for _ in range(n_subjects)
SparseUOT(sparsity_mask, verbose=verbose, **kwargs)
for _ in range(n_subjects)
]
for _ in range(n_iter):
template = _rescaled_euclidean_mean_torch(
Expand Down Expand Up @@ -249,16 +251,15 @@ def fit(self, imgs):
)
for img in imgs
]
sparsity_mask = _sparse_cluster_matrix(self.labels_).to(
self.device
)
sparsity_mask = _sparse_cluster_matrix(self.labels_).to(self.device)
template_data, self.fit_ = _fit_sparse_template(
subjects_data=subjects_data,
sparsity_mask=sparsity_mask,
n_iter=self.n_iter,
scale_template=self.scale_template,
alignment_method=self.alignment_method,
device=self.device,
verbose=True if self.verbose > 0 else False,
**self.kwargs,
)

Expand Down

0 comments on commit 971d886

Please sign in to comment.