Skip to content

Commit 4ccc222

Browse files
authored
Fixes private nilearn function call
Replace private nilearn._utils import with public API - Use nilearn.image.check_niimg instead of nilearn._utils.check_niimg - Replace deprecated pkg_resources with importlib.resources Fixes compatibility with nilearn >= 0.12.1 Closes #156
1 parent 9ddd37d commit 4ccc222

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

atlasreader/atlasreader.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import os
66
import os.path as op
77
import warnings
8+
from importlib.resources import files
89

910
import nibabel as nb
1011
import numpy as np
1112
import pandas as pd
1213
from nilearn import image, plotting
13-
from nilearn._utils import check_niimg
14+
from nilearn.image import check_niimg
1415
from nilearn.regions import connected_regions
15-
from pkg_resources import resource_filename
1616
from scipy.ndimage import center_of_mass, label
1717
from scipy.spatial.distance import cdist
1818
from skimage.feature import peak_local_max
@@ -63,8 +63,7 @@ def get_atlas(atlastype, cache=True):
6363
atlastype = atlastype.lower()
6464

6565
# get the path to atlas + label files shipped with package
66-
# resource_filename ensures that we're getting the correct path
67-
data_dir = resource_filename("atlasreader", "data/atlases")
66+
data_dir = str(files("atlasreader").joinpath("data/atlases"))
6867
atlas_path = op.join(data_dir, f"atlas_{atlastype}.nii.gz")
6968
label_path = op.join(data_dir, f"labels_{atlastype}.csv")
7069

@@ -901,7 +900,7 @@ def create_output(
901900

902901
# get template image for plotting cluster maps
903902
bgimg = nb.load(
904-
resource_filename("atlasreader", "data/templates/MNI152_T1_1mm_brain.nii.gz")
903+
str(files("atlasreader").joinpath("data/templates/MNI152_T1_1mm_brain.nii.gz"))
905904
)
906905

907906
# plot clusters

0 commit comments

Comments
 (0)