Skip to content

Commit fe8ef5d

Browse files
authored
Merge pull request #746 from effigies/fix/resources
[RTM] Resource annotation
2 parents a5538a4 + d15119c commit fe8ef5d

File tree

7 files changed

+44
-57
lines changed

7 files changed

+44
-57
lines changed

fmriprep/interfaces/fmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FieldEnhanceInputSpec(BaseInterfaceInputSpec):
2727
bspline_smooth = traits.Bool(True, usedefault=True, desc='run 3D bspline smoother')
2828
mask_erode = traits.Int(1, usedefault=True, desc='mask erosion iterations')
2929
despike_threshold = traits.Float(0.2, usedefault=True, desc='mask erosion iterations')
30-
njobs = traits.Int(1, usedefault=True, nohash=True, desc='number of jobs')
30+
num_threads = traits.Int(1, usedefault=True, nohash=True, desc='number of jobs')
3131

3232

3333
class FieldEnhanceOutputSpec(TraitedSpec):
@@ -86,7 +86,7 @@ def _run_interface(self, runtime):
8686

8787
# Fit BSplines (coarse)
8888
bspobj = fbsp.BSplineFieldmap(datanii, weights=mask,
89-
njobs=self.inputs.njobs)
89+
njobs=self.inputs.num_threads)
9090
bspobj.fit()
9191
smoothed1 = bspobj.get_smoothed()
9292

@@ -112,7 +112,7 @@ def _run_interface(self, runtime):
112112
datanii.affine, datanii.header)
113113

114114
bspobj2 = fbsp.BSplineFieldmap(diffmapnii, knots_zooms=[24., 24., 4.],
115-
njobs=self.inputs.njobs)
115+
njobs=self.inputs.num_threads)
116116
bspobj2.fit()
117117
smoothed2 = bspobj2.get_smoothed().get_data()
118118

fmriprep/workflows/anatomical.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ def init_anat_preproc_wf(skull_strip_template, output_spaces, template, debug,
216216
RobustMNINormalizationRPT(
217217
float=True,
218218
generate_report=True,
219-
num_threads=omp_nthreads,
220219
flavor='testing' if debug else 'precise',
221220
),
222221
name='t1_2_mni',
@@ -427,10 +426,9 @@ def init_skullstrip_ants_wf(skull_strip_template, debug, omp_nthreads, name='sku
427426
outputnode = pe.Node(niu.IdentityInterface(
428427
fields=['bias_corrected', 'out_file', 'out_mask', 'out_report']), name='outputnode')
429428

430-
t1_skull_strip = pe.Node(BrainExtractionRPT(
431-
dimension=3, use_floatingpoint_precision=1,
432-
debug=debug, generate_report=True,
433-
num_threads=omp_nthreads, keep_temporary_files=1),
429+
t1_skull_strip = pe.Node(
430+
BrainExtractionRPT(dimension=3, use_floatingpoint_precision=1, debug=debug,
431+
generate_report=True, keep_temporary_files=1),
434432
name='t1_skull_strip', n_procs=omp_nthreads)
435433

436434
t1_skull_strip.inputs.brain_template = brain_template
@@ -537,12 +535,8 @@ def init_surface_recon_wf(omp_nthreads, hires, name='surface_recon_wf'):
537535
run_without_submitting=True)
538536

539537
autorecon1 = pe.Node(
540-
fs.ReconAll(
541-
directive='autorecon1',
542-
flags='-noskullstrip',
543-
openmp=omp_nthreads),
544-
name='autorecon1',
545-
n_procs=omp_nthreads)
538+
fs.ReconAll(directive='autorecon1', flags='-noskullstrip', openmp=omp_nthreads),
539+
name='autorecon1', n_procs=omp_nthreads, mem_gb=32)
546540
autorecon1.interface._can_resume = False
547541

548542
skull_strip_extern = pe.Node(FSInjectBrainExtracted(), name='skull_strip_extern',
@@ -679,20 +673,20 @@ def init_autorecon_resume_wf(omp_nthreads, name='autorecon_resume_wf'):
679673
'-nohyporelabel', '-noaparc2aseg', '-noapas2aseg',
680674
'-nosegstats', '-nowmparc', '-nobalabels'],
681675
openmp=omp_nthreads),
682-
iterfield='hemi', n_procs=omp_nthreads,
676+
iterfield='hemi', n_procs=omp_nthreads, mem_gb=32,
683677
name='autorecon_surfs')
684678
autorecon_surfs.inputs.hemi = ['lh', 'rh']
685679

686680
autorecon3 = pe.MapNode(
687681
fs.ReconAll(directive='autorecon3', openmp=omp_nthreads),
688-
iterfield='hemi', n_procs=omp_nthreads,
682+
iterfield='hemi', n_procs=omp_nthreads, mem_gb=32,
689683
name='autorecon3')
690684
autorecon3.inputs.hemi = ['lh', 'rh']
691685

692686
# Only generate the report once; should be nothing to do
693687
recon_report = pe.Node(
694688
ReconAllRPT(directive='autorecon3', generate_report=True),
695-
name='recon_report')
689+
name='recon_report', mem_gb=8)
696690

697691
def _dedup(in_list):
698692
vals = set(in_list)

fmriprep/workflows/bold.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def init_bold_hmc_wf(bold_file_size_gb, omp_nthreads, name='bold_hmc_wf'):
811811
mcflirt = pe.Node(fsl.MCFLIRT(save_mats=True, save_plots=True),
812812
name='mcflirt', mem_gb=bold_file_size_gb * 3)
813813

814-
fsl2itk = pe.Node(MCFLIRT2ITK(num_threads=omp_nthreads), name='fsl2itk',
814+
fsl2itk = pe.Node(MCFLIRT2ITK(), name='fsl2itk',
815815
mem_gb=0.05, n_procs=omp_nthreads)
816816

817817
normalize_motion = pe.Node(NormalizeMotionParams(format='FSL'),
@@ -1002,10 +1002,9 @@ def init_bold_reg_wf(freesurfer, use_bbr, bold2t1w_dof, bold_file_size_gb, omp_n
10021002
(inputnode, merge_xforms, [('fieldwarp', 'in2')])
10031003
])
10041004

1005-
bold_to_t1w_transform = pe.Node(MultiApplyTransforms(
1006-
interpolation="LanczosWindowedSinc", float=True, copy_dtype=True,
1007-
num_threads=omp_nthreads),
1008-
name='bold_to_t1w_transform', mem_gb=0.1, n_procs=omp_nthreads)
1005+
bold_to_t1w_transform = pe.Node(
1006+
MultiApplyTransforms(interpolation="LanczosWindowedSinc", float=True, copy_dtype=True),
1007+
name='bold_to_t1w_transform', mem_gb=bold_file_size_gb * 3, n_procs=omp_nthreads)
10091008

10101009
merge = pe.Node(Merge(compress=use_compression), name='merge', mem_gb=bold_file_size_gb * 3)
10111010

@@ -1105,7 +1104,7 @@ def select_target(subject_id, space):
11051104
override_reg_subj=True, out_type='gii'),
11061105
iterfield=['source_file', 'target_subject'],
11071106
iterables=('hemi', ['lh', 'rh']),
1108-
name='sampler')
1107+
name='sampler', mem_gb=3)
11091108

11101109
def medial_wall_to_nan(in_file, subjects_dir, target_subject):
11111110
""" Convert values on medial wall to NaNs
@@ -1261,7 +1260,7 @@ def _aslist(in_value):
12611260
mask_mni_tfm = pe.Node(
12621261
ApplyTransforms(interpolation='NearestNeighbor', float=True),
12631262
name='mask_mni_tfm',
1264-
mem_gb=0.1
1263+
mem_gb=3
12651264
)
12661265

12671266
# Write corrected file in the designated output dir
@@ -1285,9 +1284,10 @@ def _aslist(in_value):
12851284
(inputnode, mask_mni_tfm, [('bold_mask', 'input_image')])
12861285
])
12871286

1288-
bold_to_mni_transform = pe.Node(MultiApplyTransforms(
1289-
interpolation="LanczosWindowedSinc", float=True, num_threads=omp_nthreads,
1290-
copy_dtype=True), name='bold_to_mni_transform', mem_gb=0.1, n_procs=omp_nthreads)
1287+
bold_to_mni_transform = pe.Node(
1288+
MultiApplyTransforms(interpolation="LanczosWindowedSinc", float=True, copy_dtype=True),
1289+
name='bold_to_mni_transform', mem_gb=bold_file_size_gb * 3, n_procs=omp_nthreads)
1290+
12911291
merge = pe.Node(Merge(compress=use_compression), name='merge',
12921292
mem_gb=bold_file_size_gb * 3)
12931293

@@ -1406,9 +1406,9 @@ def init_nonlinear_sdc_wf(bold_file, freesurfer, bold2t1w_dof,
14061406
invert_t1w = pe.Node(InvertT1w(), name='invert_t1w',
14071407
mem_gb=0.3)
14081408

1409-
ref_2_t1 = pe.Node(Registration(from_file=affine_transform, num_threads=omp_nthreads),
1409+
ref_2_t1 = pe.Node(Registration(from_file=affine_transform),
14101410
name='ref_2_t1', n_procs=omp_nthreads)
1411-
t1_2_ref = pe.Node(ApplyTransforms(invert_transform_flags=[True], num_threads=omp_nthreads),
1411+
t1_2_ref = pe.Node(ApplyTransforms(invert_transform_flags=[True]),
14121412
name='t1_2_ref', n_procs=omp_nthreads)
14131413

14141414
# 1) BOLD -> T1; 2) MNI -> T1; 3) ATLAS -> MNI
@@ -1420,8 +1420,7 @@ def init_nonlinear_sdc_wf(bold_file, freesurfer, bold2t1w_dof,
14201420
#
14211421
# ATLAS -> MNI -> T1 -> BOLD
14221422
atlas_2_ref = pe.Node(
1423-
ApplyTransforms(invert_transform_flags=[True, False, False],
1424-
num_threads=omp_nthreads),
1423+
ApplyTransforms(invert_transform_flags=[True, False, False]),
14251424
name='atlas_2_ref', n_procs=omp_nthreads,
14261425
mem_gb=0.3)
14271426
atlas_2_ref.inputs.input_image = atlas_img
@@ -1437,13 +1436,12 @@ def init_nonlinear_sdc_wf(bold_file, freesurfer, bold2t1w_dof,
14371436

14381437
restrict = [[int(bold_pe[0] == 'i'), int(bold_pe[0] == 'j'), 0]] * 2
14391438
syn = pe.Node(
1440-
Registration(from_file=syn_transform, num_threads=omp_nthreads,
1441-
restrict_deformation=restrict),
1439+
Registration(from_file=syn_transform, restrict_deformation=restrict),
14421440
name='syn', n_procs=omp_nthreads)
14431441

14441442
seg_2_ref = pe.Node(
14451443
ApplyTransforms(interpolation='NearestNeighbor', float=True,
1446-
invert_transform_flags=[True], num_threads=omp_nthreads),
1444+
invert_transform_flags=[True]),
14471445
name='seg_2_ref', n_procs=omp_nthreads, mem_gb=0.3)
14481446
sel_wm = pe.Node(niu.Function(function=extract_wm), name='sel_wm',
14491447
mem_gb=DEFAULT_MEMORY_MIN_GB)

fmriprep/workflows/fieldmap/fmap.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ def init_fmap_wf(reportlets_dir, omp_nthreads, fmap_bspline, name='fmap_wf'):
5555
name='fmapmrg')
5656

5757
# de-gradient the fields ("bias/illumination artifact")
58-
n4_correct = pe.Node(ants.N4BiasFieldCorrection(
59-
dimension=3, copy_header=True, num_threads=omp_nthreads),
60-
n_procs=omp_nthreads, name='n4_correct')
58+
n4_correct = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True),
59+
name='n4_correct', n_procs=omp_nthreads)
6160
bet = pe.Node(BETRPT(generate_report=True, frac=0.6, mask=True),
6261
name='bet')
6362
ds_fmap_mask = pe.Node(DerivativesDataSink(
@@ -77,9 +76,8 @@ def init_fmap_wf(reportlets_dir, omp_nthreads, fmap_bspline, name='fmap_wf'):
7776

7877
if fmap_bspline:
7978
# despike_threshold=1.0, mask_erode=1),
80-
fmapenh = pe.Node(FieldEnhance(
81-
unwrap=False, despike=False, njobs=omp_nthreads),
82-
name='fmapenh', mem_gb=4, n_procs=omp_nthreads)
79+
fmapenh = pe.Node(FieldEnhance(unwrap=False, despike=False),
80+
name='fmapenh', mem_gb=4, n_procs=omp_nthreads)
8381

8482
workflow.connect([
8583
(bet, fmapenh, [('mask_file', 'in_mask'),

fmriprep/workflows/fieldmap/phdiff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def _pick1st(inlist):
6868
magmrg = pe.Node(IntraModalMerge(), name='magmrg')
6969

7070
# de-gradient the fields ("bias/illumination artifact")
71-
n4 = pe.Node(ants.N4BiasFieldCorrection(
72-
dimension=3, copy_header=True, num_threads=omp_nthreads), name='n4', n_procs=omp_nthreads)
71+
n4 = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True),
72+
name='n4', n_procs=omp_nthreads)
7373
bet = pe.Node(BETRPT(generate_report=True, frac=0.6, mask=True),
7474
name='bet')
7575
ds_fmap_mask = pe.Node(DerivativesDataSink(

fmriprep/workflows/fieldmap/unwarp.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ def init_sdc_unwarp_wf(reportlets_dir, omp_nthreads, fmap_bspline,
101101
ants_settings = pkgr.resource_filename(
102102
'fmriprep', 'data/fmap-any_registration_testing.json')
103103
fmap2ref_reg = pe.Node(
104-
ANTSRegistrationRPT(
105-
generate_report=True, from_file=ants_settings, output_inverse_warped_image=True,
106-
output_warped_image=True, num_threads=omp_nthreads),
104+
ANTSRegistrationRPT(generate_report=True, from_file=ants_settings,
105+
output_inverse_warped_image=True, output_warped_image=True),
107106
name='fmap2ref_reg', n_procs=omp_nthreads)
108107

109108
ds_reg = pe.Node(DerivativesDataSink(
@@ -437,8 +436,7 @@ def init_prepare_epi_wf(omp_nthreads, name="prepare_epi_wf"):
437436
ants_settings = pkgr.resource_filename('fmriprep',
438437
'data/translation_rigid.json')
439438
fmap2ref_reg = pe.Node(ants.Registration(from_file=ants_settings,
440-
output_warped_image=True,
441-
num_threads=omp_nthreads),
439+
output_warped_image=True),
442440
name='fmap2ref_reg', n_procs=omp_nthreads)
443441

444442
workflow = pe.Workflow(name=name)

fmriprep/workflows/util.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ def init_enhance_and_skullstrip_bold_wf(name='enhance_and_skullstrip_bold_wf',
112112
'bias_corrected_file',
113113
'out_report']),
114114
name='outputnode')
115-
n4_correct = pe.Node(
116-
ants.N4BiasFieldCorrection(dimension=3, copy_header=True, num_threads=omp_nthreads),
117-
name='n4_correct', n_procs=omp_nthreads)
115+
n4_correct = pe.Node(ants.N4BiasFieldCorrection(dimension=3, copy_header=True),
116+
name='n4_correct', n_procs=omp_nthreads)
118117
skullstrip_first_pass = pe.Node(fsl.BET(frac=0.2, mask=True),
119118
name='skullstrip_first_pass')
120119
unifize = pe.Node(afni.Unifize(t2=True, outputtype='NIFTI_GZ',
@@ -298,8 +297,8 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
298297

299298
mri_coreg = pe.Node(
300299
MRICoregRPT(dof=bold2t1w_dof, sep=[4], ftol=0.0001, linmintol=0.01,
301-
num_threads=omp_nthreads, generate_report=not use_bbr),
302-
name='mri_coreg', n_procs=omp_nthreads)
300+
generate_report=not use_bbr),
301+
name='mri_coreg', n_procs=omp_nthreads, mem_gb=32)
303302

304303
lta_concat = pe.Node(ConcatenateLTA(out_file='out.lta'), name='lta_concat')
305304
# XXX LTA-FSL-ITK may ultimately be able to be replaced with a straightforward
@@ -327,7 +326,7 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
327326
(lta2fsl_inv, fsl2itk_inv, [('out_fsl', 'transform_file')]),
328327
(fsl2itk_fwd, outputnode, [('itk_transform', 'itk_bold_to_t1')]),
329328
(fsl2itk_inv, outputnode, [('itk_transform', 'itk_t1_to_bold')]),
330-
])
329+
])
331330

332331
# Short-circuit workflow building, use initial registration
333332
if use_bbr is False:
@@ -341,14 +340,14 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
341340
bbregister = pe.Node(
342341
BBRegisterRPT(dof=bold2t1w_dof, contrast_type='t2', registered_file=True,
343342
out_lta_file=True, generate_report=True),
344-
name='bbregister')
343+
name='bbregister', mem_gb=12)
345344

346345
workflow.connect([
347346
(inputnode, bbregister, [('subjects_dir', 'subjects_dir'),
348347
('subject_id', 'subject_id'),
349348
('in_file', 'source_file')]),
350349
(mri_coreg, bbregister, [('out_lta_file', 'init_reg_file')]),
351-
])
350+
])
352351

353352
# Short-circuit workflow building, use boundary-based registration
354353
if use_bbr is True:
@@ -363,7 +362,7 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
363362
reports = pe.Node(niu.Merge(2), run_without_submitting=True, name='reports')
364363

365364
lta_ras2ras = pe.MapNode(fs.utils.LTAConvert(out_lta=True), iterfield=['in_lta'],
366-
name='lta_ras2ras')
365+
name='lta_ras2ras', mem_gb=2)
367366
compare_transforms = pe.Node(niu.Function(function=compare_xforms), name='compare_transforms')
368367

369368
select_transform = pe.Node(niu.Select(), run_without_submitting=True, name='select_transform')
@@ -386,7 +385,7 @@ def init_bbreg_wf(use_bbr, bold2t1w_dof, omp_nthreads, name='bbreg_wf'):
386385
(reports, select_report, [('out', 'inlist')]),
387386
(compare_transforms, select_report, [('out', 'index')]),
388387
(select_report, outputnode, [('out', 'out_report')]),
389-
])
388+
])
390389

391390
return workflow
392391

0 commit comments

Comments
 (0)