From b42d6d1a19cfac5f211e792a001fc8a9498bb641 Mon Sep 17 00:00:00 2001 From: Kenya Otsuka Date: Wed, 24 Jun 2026 15:57:50 +0000 Subject: [PATCH 1/3] chore: remove unused private methods --- bdpy/dataform/features.py | 3 --- bdpy/mri/fmriprep.py | 46 --------------------------------------- 2 files changed, 49 deletions(-) diff --git a/bdpy/dataform/features.py b/bdpy/dataform/features.py index f378538..1a181f5 100644 --- a/bdpy/dataform/features.py +++ b/bdpy/dataform/features.py @@ -466,9 +466,6 @@ def __parse_dir(self, path: str, keys: Optional[List[str]] = None) -> 'FileDatab return db - def __init_db(self, keys): - raise NotImplementedError - class FileDatabase(object): def __init__(self, keys: List[str]): diff --git a/bdpy/mri/fmriprep.py b/bdpy/mri/fmriprep.py index 7e786d0..4128d49 100644 --- a/bdpy/mri/fmriprep.py +++ b/bdpy/mri/fmriprep.py @@ -813,52 +813,6 @@ def __create_bdata_fmriprep_subject(subject_data, data_mode, data_path='./', lab return bdata -def __get_xyz(img): - if len(img.shape) == 4: - # 4D-image - i_len, j_len, k_len, t = img.shape - affine = np.delete(np.delete(img.coordmap.affine, 3, axis=0), 3, axis=1) - else: - # 3D-image - i_len, j_len, k_len = img.shape - affine = img.coordmap.affine - ijk = np.array(list(itertools.product(range(i_len), - range(j_len), - range(k_len), - [1]))).T - return np.dot(affine, ijk)[:-1] - - -def __load_mri(fpath): - """Load a MRI image. - - - Returns data as 2D array (sample x voxel) - - Returns voxle xyz coordinates (3 x voxel) - - Returns voxel ijk indexes (3 x voxel) - - Data, xyz, and ijk are flattened by Fortran-like index order - """ - img = nibabel.load(fpath) - - data = img.get_fdata() - if data.ndim == 4: - data = data.reshape(-1, data.shape[-1], order='F').T - i_len, j_len, k_len, t = img.shape - affine = np.delete(np.delete(img.affine, 3, axis=0), 3, axis=1) - elif data.ndim == 3: - data = data.flatten(order='F') - i_len, j_len, k_len = img.shape - affine = img.affine - else: - raise ValueError('Invalid shape.') - - ijk = np.array(np.unravel_index(np.arange(i_len * j_len * k_len), - (i_len, j_len, k_len), order='F')) - ijk_b = np.vstack([ijk, np.ones((1, i_len * j_len * k_len))]) - xyz_b = np.dot(affine, ijk_b) - xyz = xyz_b[:-1] - - return data, xyz, ijk - if __name__ == '__main__': pass From 4f182a83de3e53a0efd81133a364fc665d2b44fa Mon Sep 17 00:00:00 2001 From: Kenya Otsuka Date: Thu, 25 Jun 2026 04:15:26 +0000 Subject: [PATCH 2/3] chore: remove unused private functions --- bdpy/dl/torch/dataset.py | 25 ------------------------- bdpy/recon/torch/task/inversion.py | 6 ------ 2 files changed, 31 deletions(-) diff --git a/bdpy/dl/torch/dataset.py b/bdpy/dl/torch/dataset.py index 6f71f83..87d0c02 100644 --- a/bdpy/dl/torch/dataset.py +++ b/bdpy/dl/torch/dataset.py @@ -12,31 +12,6 @@ _FeatureTypeNP = Dict[str, np.ndarray] -def _removesuffix(s: str, suffix: str) -> str: - """Remove suffix from string. - - Note - ---- - This function is available from Python 3.9 as `str.removesuffix`. We can - remove this function when we drop support for Python 3.8. - - Parameters - ---------- - s : str - String. - suffix : str - Suffix to remove. - - Returns - ------- - str - String without suffix. - """ - if suffix and s.endswith(suffix): - return s[: -len(suffix)] - return s[:] - - class FeaturesDataset(Dataset): """Dataset of features. diff --git a/bdpy/recon/torch/task/inversion.py b/bdpy/recon/torch/task/inversion.py index 25eef43..030be8b 100644 --- a/bdpy/recon/torch/task/inversion.py +++ b/bdpy/recon/torch/task/inversion.py @@ -14,12 +14,6 @@ _FeatureType = Dict[str, torch.Tensor] -def _apply_to_features( - fn: Callable[[torch.Tensor], torch.Tensor], features: _FeatureType -) -> _FeatureType: - return {k: fn(v) for k, v in features.items()} - - class FeatureInversionCallback(BaseCallback): """Callback for feature inversion task. From cca5ed1f87bef68be3518d5c0c3360be48f859d7 Mon Sep 17 00:00:00 2001 From: Kenya Otsuka Date: Tue, 21 Jul 2026 10:07:09 +0000 Subject: [PATCH 3/3] chore: remove unused Callable import from inversion.py --- bdpy/recon/torch/task/inversion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdpy/recon/torch/task/inversion.py b/bdpy/recon/torch/task/inversion.py index 030be8b..2325930 100644 --- a/bdpy/recon/torch/task/inversion.py +++ b/bdpy/recon/torch/task/inversion.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Dict, Iterable +from typing import TYPE_CHECKING, Dict, Iterable from bdpy.task import BaseTask from bdpy.task.callback import BaseCallback, unused