Skip to content

Commit 42997bf

Browse files
committed
MAINT: Purge remaining pkg_resource uses
1 parent 7cbb35a commit 42997bf

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

nibabies/workflows/anatomical/brain_extraction.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""Baby brain extraction from T2w images."""
44
from nipype.interfaces import utility as niu
55
from nipype.pipeline import engine as pe
6-
from pkg_resources import resource_filename as pkgr_fn
76

87

98
def init_infant_brain_extraction_wf(
@@ -79,16 +78,15 @@ def init_infant_brain_extraction_wf(
7978
from nipype.interfaces.ants import ImageMath, N4BiasFieldCorrection
8079
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
8180
from niworkflows.interfaces.fixes import FixHeaderRegistration as Registration
82-
83-
# niworkflows
8481
from niworkflows.interfaces.nibabel import (
8582
ApplyMask,
8683
Binarize,
8784
BinaryDilation,
8885
IntensityClip,
8986
)
9087

91-
from ...utils.misc import cohort_by_months
88+
from nibabies.data import load as load_data
89+
from nibabies.utils.misc import cohort_by_months
9290

9391
# handle template specifics
9492
template_specs = template_specs or {}
@@ -138,9 +136,7 @@ def init_infant_brain_extraction_wf(
138136
# Set up initial spatial normalization
139137
ants_params = "testing" if sloppy else "precise"
140138
norm = pe.Node(
141-
Registration(
142-
from_file=pkgr_fn("nibabies.data", f"antsBrainExtraction_{ants_params}.json")
143-
),
139+
Registration(from_file=load_data(f"antsBrainExtraction_{ants_params}.json")),
144140
name="norm",
145141
n_procs=omp_nthreads,
146142
mem_gb=mem_gb,

nibabies/workflows/anatomical/segmentation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
from nipype.interfaces import utility as niu
55
from nipype.interfaces.ants.segmentation import JointFusion
66
from nipype.pipeline import engine as pe
7+
from niworkflows.data import load as load_nwf
78
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
89
from niworkflows.interfaces.fixes import FixHeaderRegistration as Registration
9-
from niworkflows.interfaces.nibabel import MapLabels
10-
from pkg_resources import resource_filename as pkgr_fn
1110
from smriprep.utils.misc import apply_lut as _apply_bids_lut
1211
from smriprep.workflows.anatomical import (
1312
_aseg_to_three,
1413
_probseg_fast2bids,
1514
_split_segments,
1615
)
1716

18-
from ...config import DEFAULT_MEMORY_MIN_GB
17+
from nibabies.config import DEFAULT_MEMORY_MIN_GB
1918

2019

2120
def init_anat_segmentations_wf(
@@ -104,9 +103,7 @@ def init_anat_segmentations_wf(
104103
ants_params = "testing" if sloppy else "precise"
105104
# Register to each subject space
106105
norm = pe.MapNode(
107-
Registration(
108-
from_file=pkgr_fn("niworkflows.data", f"antsBrainExtraction_{ants_params}.json")
109-
),
106+
Registration(from_file=load_nwf(f"antsBrainExtraction_{ants_params}.json")),
110107
name="norm",
111108
iterfield=["moving_image"],
112109
n_procs=omp_nthreads,

nibabies/workflows/bold/alignment.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from nipype.interfaces import utility as niu
77
from nipype.pipeline import engine as pe
88
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
9-
from pkg_resources import resource_filename
109

11-
from ...interfaces.workbench import VolumeLabelImport
10+
from nibabies.data import load as load_data
11+
from nibabies.interfaces.workbench import VolumeLabelImport
1212

1313

1414
def init_subcortical_rois_wf(*, name="subcortical_rois_wf"):
@@ -70,17 +70,15 @@ def init_subcortical_rois_wf(*, name="subcortical_rois_wf"):
7070
# )
7171

7272
map_labels = pe.Node(
73-
MapLabels(
74-
mappings_file=resource_filename("nibabies", "data/FreeSurferLabelRemappings.json")
75-
),
73+
MapLabels(mappings_file=load_data("FreeSurferLabelRemappings.json")),
7674
name='map_labels',
7775
)
7876

79-
subcortical_labels = resource_filename(
80-
"nibabies", "data/FreeSurferSubcorticalLabelTableLut.txt"
81-
)
8277
refine_bold_rois = pe.Node(
83-
VolumeLabelImport(label_list_file=subcortical_labels, discard_others=True),
78+
VolumeLabelImport(
79+
label_list_file=load_data("FreeSurferSubcorticalLabelTableLut.txt"),
80+
discard_others=True,
81+
),
8482
name="refine_bold_rois",
8583
)
8684

nibabies/workflows/bold/registration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import logging
1414
import os
1515

16-
import pkg_resources as pkgr
1716
from nipype.interfaces import c3, fsl
1817
from nipype.interfaces import utility as niu
1918
from nipype.pipeline import engine as pe
2019

21-
from ...config import DEFAULT_MEMORY_MIN_GB
20+
from nibabies.config import DEFAULT_MEMORY_MIN_GB
21+
from nibabies.data import load as load_data
2222

2323
LOGGER = logging.getLogger("nipype.workflow")
2424

@@ -793,7 +793,7 @@ def init_fsl_bbr_wf(use_bbr, bold2t1w_dof, bold2t1w_init, sloppy=False, name="fs
793793
else:
794794
# Should mostly be hit while building docs
795795
LOGGER.warning("FSLDIR unset - using packaged BBR schedule")
796-
flt_bbr.inputs.schedule = pkgr.resource_filename("fmriprep", "data/flirtsch/bbr.sch")
796+
flt_bbr.inputs.schedule = load_data("flirtsch/bbr.sch")
797797

798798
# fmt: off
799799
workflow.connect([

0 commit comments

Comments
 (0)