Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove n_procs for nodes that do not use multiple cores #1256

Merged
merged 14 commits into from
Sep 12, 2024
7 changes: 0 additions & 7 deletions xcp_d/workflows/anatomical/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
workflow = Workflow(name=name)

output_dir = config.execution.xcp_d_dir
omp_nthreads = config.nipype.omp_nthreads

inputnode = pe.Node(
niu.IdentityInterface(
Expand Down Expand Up @@ -108,7 +107,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
),
name=f"get_number_of_frames_{image_type}",
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
workflow.connect([
(inputnode, get_number_of_frames, [(inputnode_anat_name, "anat_file")]),
Expand All @@ -132,7 +130,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
name=f"modify_brainsprite_template_scene_{image_type}",
iterfield=["slice_number"],
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
modify_brainsprite_template_scene.inputs.scene_template = brainsprite_scene_template
workflow.connect([
Expand All @@ -157,7 +154,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
name=f"create_framewise_pngs_{image_type}",
iterfield=["scene_file"],
mem_gb=1,
omp_nthreads=omp_nthreads,
)
workflow.connect([
(modify_brainsprite_template_scene, create_framewise_pngs, [
Expand All @@ -174,7 +170,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
),
name=f"make_mosaic_{image_type}",
mem_gb=1,
omp_nthreads=omp_nthreads,
)

workflow.connect([(create_framewise_pngs, make_mosaic_node, [("out_file", "png_files")])])
Expand Down Expand Up @@ -211,7 +206,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
),
name=f"modify_pngs_template_scene_{image_type}",
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
omp_nthreads=omp_nthreads,
)
modify_pngs_template_scene.inputs.scene_template = pngs_scene_template
workflow.connect([
Expand All @@ -238,7 +232,6 @@ def init_brainsprite_figures_wf(t1w_available, t2w_available, name="brainsprite_
name=f"create_scenewise_pngs_{image_type}",
iterfield=["scene_name_or_number"],
mem_gb=1,
omp_nthreads=omp_nthreads,
)
workflow.connect([
(modify_pngs_template_scene, create_scenewise_pngs, [("out_file", "scene_file")]),
Expand Down
24 changes: 1 addition & 23 deletions xcp_d/workflows/anatomical/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ def init_warp_surfaces_to_template_wf(
# First, we create the Connectome WorkBench-compatible transform files.
update_xfm_wf = init_ants_xfm_to_fsl_wf(
mem_gb=1,
omp_nthreads=omp_nthreads,
name="update_xfm_wf",
)
workflow.connect([
Expand Down Expand Up @@ -510,7 +509,6 @@ def init_generate_hcp_surfaces_wf(name="generate_hcp_surfaces_wf"):
workflow = Workflow(name=name)

output_dir = config.execution.xcp_d_dir
omp_nthreads = config.nipype.omp_nthreads

inputnode = pe.Node(
niu.IdentityInterface(
Expand All @@ -532,7 +530,6 @@ def init_generate_hcp_surfaces_wf(name="generate_hcp_surfaces_wf"):
SurfaceAverage(),
name="generate_midthickness",
mem_gb=2,
n_procs=omp_nthreads,
)
workflow.connect([
(inputnode, generate_midthickness, [
Expand Down Expand Up @@ -565,7 +562,6 @@ def init_generate_hcp_surfaces_wf(name="generate_hcp_surfaces_wf"):
inflate_surface = pe.Node(
SurfaceGenerateInflated(iterations_scale_value=0.75),
mem_gb=2,
omp_nthreads=omp_nthreads,
name="inflate_surface",
)
workflow.connect([
Expand Down Expand Up @@ -614,7 +610,7 @@ def init_generate_hcp_surfaces_wf(name="generate_hcp_surfaces_wf"):


@fill_doc
def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
def init_ants_xfm_to_fsl_wf(mem_gb, name="ants_xfm_to_fsl_wf"):
"""Modify ANTS-style fMRIPrep transforms to work with Connectome Workbench/FSL FNIRT.

XXX: Does this only work if the template is MNI152NLin6Asym?
Expand All @@ -628,14 +624,12 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):

wf = init_ants_xfm_to_fsl_wf(
mem_gb=0.1,
omp_nthreads=1,
name="ants_xfm_to_fsl_wf",
)

Parameters
----------
%(mem_gb)s
%(omp_nthreads)s
%(name)s
Default is "ants_xfm_to_fsl_wf".

Expand Down Expand Up @@ -679,7 +673,6 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
),
name="disassemble_h5",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([(inputnode, disassemble_h5, [("anat_to_template_xfm", "in_file")])])

Expand All @@ -693,7 +686,6 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
),
name="disassemble_h5_inv",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([(inputnode, disassemble_h5_inv, [("template_to_anat_xfm", "in_file")])])

Expand Down Expand Up @@ -726,7 +718,6 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
),
name="get_xyz_components",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
get_inv_xyz_components = pe.Node(
C3d(
Expand All @@ -736,7 +727,6 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
),
name="get_inv_xyz_components",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([
(disassemble_h5, get_xyz_components, [("displacement_field", "in_file")]),
Expand All @@ -748,41 +738,35 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
niu.Select(index=[0]),
name="select_x_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
select_inv_x_component = pe.Node(
niu.Select(index=[0]),
name="select_inv_x_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)

# Select y-component
select_y_component = pe.Node(
niu.Select(index=[1]),
name="select_y_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
select_inv_y_component = pe.Node(
niu.Select(index=[1]),
name="select_inv_y_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)

# Select z-component
select_z_component = pe.Node(
niu.Select(index=[2]),
name="select_z_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
select_inv_z_component = pe.Node(
niu.Select(index=[2]),
name="select_inv_z_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([
(get_xyz_components, select_x_component, [("out_files", "inlist")]),
Expand All @@ -800,13 +784,11 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
BinaryMath(expression="img * -1"),
tsalo marked this conversation as resolved.
Show resolved Hide resolved
name="reverse_y_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
reverse_inv_y_component = pe.Node(
BinaryMath(expression="img * -1"),
name="reverse_inv_y_component",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([
(select_y_component, reverse_y_component, [("out", "in_file")]),
Expand All @@ -818,13 +800,11 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
niu.Merge(3),
name="collect_new_components",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
collect_new_inv_components = pe.Node(
niu.Merge(3),
name="collect_new_inv_components",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([
(select_x_component, collect_new_components, [("out", "in1")]),
Expand All @@ -840,13 +820,11 @@ def init_ants_xfm_to_fsl_wf(mem_gb, omp_nthreads, name="ants_xfm_to_fsl_wf"):
Merge(),
name="remerge_warpfield",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
remerge_inv_warpfield = pe.Node(
Merge(),
name="remerge_inv_warpfield",
mem_gb=mem_gb,
n_procs=omp_nthreads,
)
workflow.connect([
(collect_new_components, remerge_warpfield, [("out", "in_files")]),
Expand Down
3 changes: 0 additions & 3 deletions xcp_d/workflows/anatomical/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def init_postprocess_anat_wf(
workflow = Workflow(name=name)
output_dir = config.execution.xcp_d_dir
input_type = config.workflow.input_type
omp_nthreads = config.nipype.omp_nthreads

inputnode = pe.Node(
niu.IdentityInterface(
Expand Down Expand Up @@ -168,7 +167,6 @@ def init_postprocess_anat_wf(
),
name="warp_t1w_to_template",
mem_gb=2,
n_procs=omp_nthreads,
tsalo marked this conversation as resolved.
Show resolved Hide resolved
)
workflow.connect([
(inputnode, warp_t1w_to_template, [
Expand All @@ -189,7 +187,6 @@ def init_postprocess_anat_wf(
),
name="warp_t2w_to_template",
mem_gb=2,
n_procs=omp_nthreads,
tsalo marked this conversation as resolved.
Show resolved Hide resolved
)
workflow.connect([
(inputnode, warp_t2w_to_template, [
Expand Down
2 changes: 0 additions & 2 deletions xcp_d/workflows/bold/cifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def init_postprocess_cifti_wf(
dummy_scans = config.workflow.dummy_scans
despike = config.workflow.despike
atlases = config.execution.atlases
omp_nthreads = config.nipype.omp_nthreads

TR = run_data["bold_metadata"]["RepetitionTime"]

Expand Down Expand Up @@ -217,7 +216,6 @@ def init_postprocess_cifti_wf(
ConvertTo32(),
name="downcast_data",
mem_gb=mem_gbx["timeseries"],
n_procs=omp_nthreads,
)

workflow.connect([
Expand Down
9 changes: 0 additions & 9 deletions xcp_d/workflows/bold/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def init_alff_wf(
ComputeALFF(TR=TR, low_pass=low_pass, high_pass=high_pass),
mem_gb=mem_gb["resampled"],
mattcieslak marked this conversation as resolved.
Show resolved Hide resolved
name="alff_compt",
n_procs=omp_nthreads,
)
workflow.connect([
(inputnode, alff_compt, [
Expand Down Expand Up @@ -201,7 +200,6 @@ def init_alff_wf(
smooth_data = pe.Node(
Smooth(fwhm=smoothing),
name="niftismoothing",
n_procs=omp_nthreads,
)
workflow.connect([
(alff_compt, smooth_data, [("alff", "in_file")]),
Expand Down Expand Up @@ -241,7 +239,6 @@ def init_alff_wf(
FixCiftiIntent(),
name="fix_cifti_intent",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)
workflow.connect([
(alff_compt, smooth_data, [("alff", "in_file")]),
Expand Down Expand Up @@ -330,39 +327,33 @@ def init_reho_cifti_wf(
CiftiSeparateMetric(metric="CORTEX_LEFT", direction="COLUMN"),
name="separate_lh",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)
rh_surf = pe.Node(
CiftiSeparateMetric(metric="CORTEX_RIGHT", direction="COLUMN"),
name="separate_rh",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)
subcortical_nifti = pe.Node(
CiftiSeparateVolumeAll(direction="COLUMN"),
name="separate_subcortical",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)

# Calculate the reho by hemipshere
lh_reho = pe.Node(
SurfaceReHo(surf_hemi="L"),
name="reho_lh",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)
rh_reho = pe.Node(
SurfaceReHo(surf_hemi="R"),
name="reho_rh",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)
subcortical_reho = pe.Node(
ReHoNamePatch(neighborhood="vertices"),
name="reho_subcortical",
mem_gb=mem_gb["resampled"],
n_procs=omp_nthreads,
)

# Merge the surfaces and subcortical structures back into a CIFTI
Expand Down
2 changes: 0 additions & 2 deletions xcp_d/workflows/bold/nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def init_postprocess_nifti_wf(
dummy_scans = config.workflow.dummy_scans
despike = config.workflow.despike
atlases = config.execution.atlases
omp_nthreads = config.nipype.omp_nthreads

TR = run_data["bold_metadata"]["RepetitionTime"]

Expand Down Expand Up @@ -227,7 +226,6 @@ def init_postprocess_nifti_wf(
ConvertTo32(),
name="downcast_data",
mem_gb=mem_gbx["timeseries"],
n_procs=omp_nthreads,
)

workflow.connect([
Expand Down
Loading