Skip to content

Commit

Permalink
Merge pull request #1428 from FCP-INDI/convergence/memory-estimates
Browse files Browse the repository at this point in the history
⚡️ Update memory and threading estimates
  • Loading branch information
sgiavasis authored Jan 30, 2021
2 parents c65eeb1 + aeae2ae commit 827ca3e
Show file tree
Hide file tree
Showing 72 changed files with 841 additions and 146 deletions.
5 changes: 3 additions & 2 deletions CPAC/alff/alff.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import os
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
from nipype.interfaces.afni import preprocess
import nipype.interfaces.utility as util
from CPAC.alff.utils import get_opt_string
Expand Down Expand Up @@ -169,7 +169,8 @@ def create_alff(wf_name='alff_workflow'):

# filtering
bandpass = pe.Node(interface=preprocess.Bandpass(),
name='bandpass_filtering')
name='bandpass_filtering',
mem_gb=13.0)
bandpass.inputs.outputtype = 'NIFTI_GZ'
bandpass.inputs.out_file = os.path.join(os.path.curdir,
'residual_filtered.nii.gz')
Expand Down
2 changes: 1 addition & 1 deletion CPAC/anat_preproc/anat_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from nipype.interfaces import ants
from nipype.interfaces import fsl
from nipype.interfaces.fsl import utils as fsl_utils
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from CPAC.anat_preproc.ants import init_brain_extraction_wf
from nipype.interfaces import freesurfer
Expand Down
4 changes: 2 additions & 2 deletions CPAC/anat_preproc/ants.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def init_brain_extraction_wf(tpl_target_path,

copy_xform = pe.Node(CopyXForm(
fields=['out_file', 'out_mask', 'bias_corrected', 'bias_image']),
name='copy_xform', run_without_submitting=True)
name='copy_xform', run_without_submitting=True, mem_gb=2.5)

trunc = pe.MapNode(ImageMath(operation='TruncateImageIntensity', op2='0.01 0.999 256'),
name='truncate_images', iterfield=['op1'])
Expand Down Expand Up @@ -417,7 +417,7 @@ def init_atropos_wf(name='atropos_wf',

copy_xform = pe.Node(CopyXForm(
fields=['out_mask', 'out_segm', 'out_tpms']),
name='copy_xform', run_without_submitting=True)
name='copy_xform', run_without_submitting=True, mem_gb=2.5)

# Run atropos (core node)
atropos = pe.Node(Atropos(
Expand Down
2 changes: 1 addition & 1 deletion CPAC/anat_preproc/lesion_preproc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from nipype.interfaces import afni
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util


Expand Down
2 changes: 1 addition & 1 deletion CPAC/aroma/aroma.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from nipype.interfaces import fsl
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from nipype.interfaces.fsl.aroma import ICA_AROMA

Expand Down
2 changes: 1 addition & 1 deletion CPAC/aroma/aroma_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import glob
import nipype.interfaces.io as nio
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
from nipype.interfaces.fsl import ImageStats
#rom nose.tools import *
## This script runs the warp_nipype workflow to execute the interfaces and with the inputs already provided
Expand Down
2 changes: 1 addition & 1 deletion CPAC/connectome/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from nipype.interfaces.base import BaseInterface, \
BaseInterfaceInputSpec, traits, File, TraitedSpec
Expand Down
2 changes: 1 addition & 1 deletion CPAC/cwas/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import os
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util

from CPAC.utils.interfaces.function import Function
Expand Down
2 changes: 1 addition & 1 deletion CPAC/distortion_correction/distortion_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import nibabel as nb

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
from nipype.interfaces import afni, fsl
import nipype.interfaces.utility as util
import nipype.interfaces.ants as ants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import os
import nipype.interfaces.io as nio
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe

from CPAC.utils.test_resources import setup_test_wf
from CPAC.func_preproc.func_preproc import create_func_preproc
Expand Down
2 changes: 1 addition & 1 deletion CPAC/easy_thresh/easy_thresh.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.fsl as fsl
import nipype.interfaces.utility as util

Expand Down
2 changes: 1 addition & 1 deletion CPAC/func_preproc/func_ingress.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from nipype import logging
logger = logging.getLogger('workflow')

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe

import nipype.interfaces.afni as afni

Expand Down
10 changes: 6 additions & 4 deletions CPAC/func_preproc/func_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

logger = logging.getLogger('workflow')

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.fsl as fsl
import nipype.interfaces.utility as util
from nipype.interfaces import afni
Expand Down Expand Up @@ -683,7 +683,7 @@ def motion_correct_connections(wf, cfg, strat_pool, pipe_num, opt):
elif opt == 'mcflirt':
func_motion_correct_A = pe.Node(
interface=fsl.MCFLIRT(save_mats=True, save_plots=True),
name=f'func_motion_correct_mcflirt_{pipe_num}')
name=f'func_motion_correct_mcflirt_{pipe_num}', mem_gb=2.5)

func_motion_correct_A.inputs.save_mats = True
func_motion_correct_A.inputs.save_plots = True
Expand Down Expand Up @@ -1609,15 +1609,17 @@ def func_normalize(wf, cfg, strat_pool, pipe_num, opt=None):
'''

func_normalize = pe.Node(interface=fsl.ImageMaths(),
name=f'func_normalize_{pipe_num}')
name=f'func_normalize_{pipe_num}',
mem_gb=3.0)
func_normalize.inputs.op_string = '-ing 10000'
func_normalize.inputs.out_data_type = 'float'

node, out = strat_pool.get_data('desc-brain_bold')
wf.connect(node, out, func_normalize, 'in_file')

func_mask_normalize = pe.Node(interface=fsl.ImageMaths(),
name=f'func_mask_normalize_{pipe_num}')
name=f'func_mask_normalize_{pipe_num}',
mem_gb=3.0)
func_mask_normalize.inputs.op_string = '-Tmin -bin'
func_mask_normalize.inputs.out_data_type = 'char'

Expand Down
4 changes: 2 additions & 2 deletions CPAC/generate_motion_statistics/generate_motion_statistics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import numpy as np
import nibabel as nb
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from CPAC.utils.interfaces.function import Function

Expand Down Expand Up @@ -191,7 +191,7 @@ def motion_power_statistics(name='motion_stats',
output_names=['out_file'],
function=calculate_DVARS,
as_module=True),
name='cal_DVARS')
name='cal_DVARS', mem_gb=3.5)

# calculate mean DVARS
wf.connect(input_node, 'motion_correct', cal_DVARS, 'func_brain')
Expand Down
2 changes: 1 addition & 1 deletion CPAC/group_analysis/group_analysis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.fsl as fsl
import nipype.interfaces.utility as util
from CPAC.easy_thresh import easy_thresh
Expand Down
9 changes: 6 additions & 3 deletions CPAC/image_utils/spatial_smoothing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nipype.interfaces.fsl as fsl
from nipype.interfaces.afni import preprocess as afni
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from CPAC.utils import Outputs

Expand Down Expand Up @@ -51,13 +51,16 @@ def spatial_smoothing(wf_name, fwhm, input_image_type='func_derivative',
', '.join(image_types)))

if opt == 'FSL':
output_smooth_mem_gb = 4.0
if input_image_type == 'func_derivative_multi':
output_smooth = pe.MapNode(interface=fsl.MultiImageMaths(),
name='smooth_multi',
iterfield=['in_file'])
iterfield=['in_file'],
mem_gb=output_smooth_mem_gb)
else:
output_smooth = pe.Node(interface=fsl.MultiImageMaths(),
name='smooth')
name='smooth',
mem_gb=output_smooth_mem_gb)

elif opt == 'AFNI':
if input_image_type == 'func_derivative_multi':
Expand Down
2 changes: 1 addition & 1 deletion CPAC/image_utils/statistical_transforms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nipype.interfaces.fsl as fsl
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from nipype.interfaces.afni import preprocess
from CPAC.registration import create_fsl_fnirt_nonlinear_reg, \
Expand Down
2 changes: 1 addition & 1 deletion CPAC/image_utils/tests/test_smooth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util

from CPAC.utils.test_mocks import configuration_strategy_mock
Expand Down
2 changes: 1 addition & 1 deletion CPAC/isc/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
from nipype.interfaces.base import BaseInterface, \
BaseInterfaceInputSpec, traits, File, TraitedSpec
Expand Down
2 changes: 1 addition & 1 deletion CPAC/longitudinal_pipeline/longitudinal_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import six
import numpy as np
import nibabel as nib
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
import nipype.interfaces.fsl as fsl
from nipype.interfaces.fsl import ConvertXFM
Expand Down
2 changes: 1 addition & 1 deletion CPAC/longitudinal_pipeline/longitudinal_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from nipype import config
from nipype import logging
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.afni as afni
import nipype.interfaces.fsl as fsl
import nipype.interfaces.io as nio
Expand Down
2 changes: 1 addition & 1 deletion CPAC/median_angle/median_angle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util


Expand Down
2 changes: 1 addition & 1 deletion CPAC/network_centrality/network_centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_centrality_wf(wf_name, method_option, weight_options,
the initialized nipype workflow for the afni centrality command
"""

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
import CPAC.network_centrality.utils as utils

Expand Down
5 changes: 3 additions & 2 deletions CPAC/network_centrality/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.fsl as fsl
import nipype.interfaces.utility as util

Expand Down Expand Up @@ -84,7 +84,8 @@ def network_centrality(wf, cfg, strat_pool, pipe_num, opt=None):
# Resample the functional mni to the centrality mask resolution
resample_functional_to_template = pe.Node(
interface=fsl.FLIRT(),
name=f'resample_functional_to_template_{pipe_num}')
name=f'resample_functional_to_template_{pipe_num}',
mem_gb=4.0)

resample_functional_to_template.inputs.set(
interp='trilinear',
Expand Down
30 changes: 17 additions & 13 deletions CPAC/nuisance/nuisance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import numpy as np
import nibabel as nb
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util
import CPAC

Expand Down Expand Up @@ -981,7 +981,8 @@ def create_regressor_workflow(nuisance_selectors,
anat_resample = pe.Node(
interface=fsl.FLIRT(),
name='{}_flirt'
.format(anatomical_at_resolution_key)
.format(anatomical_at_resolution_key),
mem_gb=8.0
)
anat_resample.inputs.apply_isoxfm = regressor_selector["extraction_resolution"]

Expand All @@ -1003,7 +1004,8 @@ def create_regressor_workflow(nuisance_selectors,
func_resample = pe.Node(
interface=fsl.FLIRT(),
name='{}_flirt'
.format(functional_at_resolution_key)
.format(functional_at_resolution_key),
mem_gb=8.0
)
func_resample.inputs.apply_xfm = True

Expand Down Expand Up @@ -1124,7 +1126,7 @@ def create_regressor_workflow(nuisance_selectors,
'compcor_file'],
function=calc_compcor_components,
imports=compcor_imports),
name='{}_DetrendPC'.format(regressor_type), mem_gb=2.0)
name='{}_DetrendPC'.format(regressor_type), mem_gb=12.5)

compcor_node.inputs.num_components = regressor_selector['summary']['components']

Expand All @@ -1147,13 +1149,14 @@ def create_regressor_workflow(nuisance_selectors,
'import nibabel as nb',
'from nipype import logging']

cosfilter_node = pe.Node(util.Function(input_names=['input_image_path',
'timestep'],
output_names=[
'cosfiltered_img'],
function=cosine_filter,
imports=cosfilter_imports),
name='{}_cosine_filter'.format(regressor_type))
cosfilter_node = pe.Node(
util.Function(input_names=['input_image_path',
'timestep'],
output_names=['cosfiltered_img'],
function=cosine_filter,
imports=cosfilter_imports),
name='{}_cosine_filter'.format(regressor_type),
mem_gb=8.0)
nuisance_wf.connect(
summary_filter_input[0], summary_filter_input[1],
cosfilter_node, 'input_image_path'
Expand Down Expand Up @@ -1225,7 +1228,8 @@ def create_regressor_workflow(nuisance_selectors,

mean_node = pe.Node(
afni.ROIStats(quiet=False, args='-1Dformat'),
name='{}_mean'.format(regressor_type)
name='{}_mean'.format(regressor_type),
mem_gb=5.0
)
nuisance_wf.connect(
summary_method_input[0], summary_method_input[1],
Expand Down Expand Up @@ -1561,7 +1565,7 @@ def filtering_bold_and_regressors(nuisance_selectors,
'regressor_file'],
function=bandpass_voxels,
as_module=True),
name='frequency_filter'
name='frequency_filter', mem_gb=6.0
)

frequency_filter.inputs.bandpass_freqs = [
Expand Down
2 changes: 1 addition & 1 deletion CPAC/nuisance/tests/test_nuisance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import yaml
import glob

import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
import nipype.interfaces.utility as util

from CPAC.nuisance import create_nuisance_regression_workflow
Expand Down
5 changes: 3 additions & 2 deletions CPAC/nuisance/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import nipype.interfaces.ants as ants
import nipype.interfaces.fsl as fsl
import nipype.interfaces.utility as util
import nipype.pipeline.engine as pe
from CPAC.pipeline import nipype_pipeline_engine as pe
from nipype.interfaces import afni

from CPAC.nuisance.utils.compcor import calc_compcor_components
Expand Down Expand Up @@ -319,7 +319,8 @@ def generate_summarize_tissue_mask(nuisance_wf,
elif step == 'resolution':
mask_to_epi = pe.Node(interface=fsl.FLIRT(),
name='{}_flirt'
.format(node_mask_key))
.format(node_mask_key),
mem_gb=8.0)

mask_to_epi.inputs.interp = 'nearestneighbour'

Expand Down
Loading

0 comments on commit 827ca3e

Please sign in to comment.