Skip to content

Commit

Permalink
🔀 Merge hotfix/1.8.7-1 into hotfix/1.8.7-bids-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Dec 13, 2024
2 parents 8b84256 + 39507bd commit d865870
Show file tree
Hide file tree
Showing 18 changed files with 300 additions and 102 deletions.
4 changes: 4 additions & 0 deletions .github/Dockerfiles/base-standard.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ USER root
# Installing FreeSurfer
RUN apt-get update \
&& apt-get install --no-install-recommends -y bc \
&& if [ ! -e /lib/x86_64-linux-gnu/libcrypt.so.2 ]; then \
# until we upgrade to Python >=3.11
ln -s /lib/x86_64-linux-gnu/libcrypt.so.1 /lib/x86_64-linux-gnu/libcrypt.so.2; \
fi \
&& yes | mamba install tcsh \
&& yes | mamba clean --all \
&& cp -l `which tcsh` /bin/tcsh \
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.8.7.post1.dev3] - unreleased

### Added

- `desired_orientation` key in participant-level pipeline config under `pipeline_setup`.
- Required positional parameter "wf" in input and output of `ingress_pipeconfig_paths` function, where a node to reorient templates is added to the `wf`.
- Required positional parameter "orientation" to `resolve_resolution`.
- Optional positional argument "cfg" to `create_lesion_preproc`.
- Validation node to match the pixdim4 of CPAC processed bold outputs with the original raw bold sources.

### Changed

- Disabled variant image builds.
- Made orientation configurable (was hard-coded as "RPI").

### Fixed

Expand Down
56 changes: 30 additions & 26 deletions CPAC/anat_preproc/anat_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ def freesurfer_fsl_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
name=f'reorient_fs_brainmask_{node_id}',
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))
reorient_fs_brainmask.inputs.orientation = 'RPI'
reorient_fs_brainmask.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
reorient_fs_brainmask.inputs.outputtype = 'NIFTI_GZ'

wf.connect(convert_fs_brainmask_to_nifti, 'out_file',
Expand All @@ -1075,7 +1075,7 @@ def freesurfer_fsl_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
name=f'reorient_fs_T1_{node_id}',
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))
reorient_fs_T1.inputs.orientation = 'RPI'
reorient_fs_T1.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
reorient_fs_T1.inputs.outputtype = 'NIFTI_GZ'

wf.connect(convert_fs_T1_to_nifti, 'out_file',
Expand Down Expand Up @@ -1279,18 +1279,20 @@ def anatomical_init(wf, cfg, strat_pool, pipe_num, opt=None):
node, out = strat_pool.get_data('T1w')
wf.connect(node, out, anat_deoblique, 'in_file')

anat_reorient = pe.Node(interface=afni.Resample(),
name=f'anat_reorient_{pipe_num}',
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))
anat_reorient.inputs.orientation = 'RPI'
anat_reorient.inputs.outputtype = 'NIFTI_GZ'

wf.connect(anat_deoblique, 'out_file', anat_reorient, 'in_file')

outputs = {'desc-preproc_T1w': (anat_reorient, 'out_file'),
'desc-reorient_T1w': (anat_reorient, 'out_file'),
'desc-head_T1w': (anat_reorient, 'out_file')}
anat_reorient = pe.Node(
interface=afni.Resample(),
name=f"anat_reorient_{pipe_num}",
mem_gb=0,
mem_x=(0.0115, "in_file", "t"),
)
anat_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
anat_reorient.inputs.outputtype = "NIFTI_GZ"
wf.connect(anat_deoblique, "out_file", anat_reorient, "in_file")
outputs = {
"desc-preproc_T1w": (anat_reorient, "out_file"),
"desc-reorient_T1w": (anat_reorient, "out_file"),
"desc-head_T1w": (anat_reorient, "out_file"),
}

return (wf, outputs)

Expand Down Expand Up @@ -2106,18 +2108,20 @@ def anatomical_init_T2(wf, cfg, strat_pool, pipe_num, opt=None):
node, out = strat_pool.get_data('T2w')
wf.connect(node, out, T2_deoblique, 'in_file')

T2_reorient = pe.Node(interface=afni.Resample(),
name=f'T2_reorient_{pipe_num}',
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))
T2_reorient.inputs.orientation = 'RPI'
T2_reorient.inputs.outputtype = 'NIFTI_GZ'

wf.connect(T2_deoblique, 'out_file', T2_reorient, 'in_file')

outputs = {'desc-preproc_T2w': (T2_reorient, 'out_file'),
'desc-reorient_T2w': (T2_reorient, 'out_file'),
'desc-head_T2w': (T2_reorient, 'out_file')}
T2_reorient = pe.Node(
interface=afni.Resample(),
name=f"T2_reorient_{pipe_num}",
mem_gb=0,
mem_x=(0.0115, "in_file", "t"),
)
T2_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
T2_reorient.inputs.outputtype = "NIFTI_GZ"
wf.connect(T2_deoblique, "out_file", T2_reorient, "in_file")
outputs = {
"desc-preproc_T2w": (T2_reorient, "out_file"),
"desc-reorient_T2w": (T2_reorient, "out_file"),
"desc-head_T2w": (T2_reorient, "out_file"),
}

return (wf, outputs)

Expand Down
15 changes: 8 additions & 7 deletions CPAC/anat_preproc/lesion_preproc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

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


def inverse_lesion(lesion_path):
Expand Down Expand Up @@ -40,9 +39,9 @@ def inverse_lesion(lesion_path):
return lesion_out


def create_lesion_preproc(wf_name='lesion_preproc'):
"""
The main purpose of this workflow is to process lesions masks.
def create_lesion_preproc(cfg=None, wf_name="lesion_preproc"):
"""Process lesions masks.
Lesion mask file is deobliqued and reoriented in the same way as the T1 in
the anat_preproc function.
Expand Down Expand Up @@ -116,8 +115,10 @@ def create_lesion_preproc(wf_name='lesion_preproc'):
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))

lesion_reorient.inputs.orientation = 'RPI'
lesion_reorient.inputs.outputtype = 'NIFTI_GZ'
lesion_reorient.inputs.orientation = (
cfg.pipeline_setup["desired_orientation"] if cfg else "RPI"
)
lesion_reorient.inputs.outputtype = "NIFTI_GZ"

preproc.connect(
lesion_deoblique, 'out_file', lesion_reorient,
Expand Down
24 changes: 13 additions & 11 deletions CPAC/func_preproc/func_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,19 +534,21 @@ def func_reorient(wf, cfg, strat_pool, pipe_num, opt=None):
node, out = strat_pool.get_data('bold')
wf.connect(node, out, func_deoblique, 'in_file')

func_reorient = pe.Node(interface=afni_utils.Resample(),
name=f'func_reorient_{pipe_num}',
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))
func_reorient = pe.Node(
interface=afni_utils.Resample(),
name=f"func_reorient_{pipe_num}",
mem_gb=0,
mem_x=(0.0115, "in_file", "t"),
)

func_reorient.inputs.orientation = 'RPI'
func_reorient.inputs.outputtype = 'NIFTI_GZ'
func_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
func_reorient.inputs.outputtype = "NIFTI_GZ"

wf.connect(func_deoblique, 'out_file', func_reorient, 'in_file')
wf.connect(func_deoblique, "out_file", func_reorient, "in_file")

outputs = {
'desc-preproc_bold': (func_reorient, 'out_file'),
'desc-reorient_bold': (func_reorient, 'out_file')
"desc-preproc_bold": (func_reorient, "out_file"),
"desc-reorient_bold": (func_reorient, "out_file"),
}

return (wf, outputs)
Expand Down Expand Up @@ -1129,8 +1131,8 @@ def bold_mask_anatomical_refined(wf, cfg, strat_pool, pipe_num, opt=None):
mem_gb=0,
mem_x=(0.0115, 'in_file', 't'))

func_reorient.inputs.orientation = 'RPI'
func_reorient.inputs.outputtype = 'NIFTI_GZ'
func_reorient.inputs.orientation = cfg.pipeline_setup["desired_orientation"]
func_reorient.inputs.outputtype = "NIFTI_GZ"

wf.connect(func_deoblique, 'out_file',
func_reorient, 'in_file')
Expand Down
1 change: 1 addition & 0 deletions CPAC/longitudinal_pipeline/longitudinal_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ def func_longitudinal_template_wf(subject_id, strat_list, config):
resampled_template.inputs.template = template
resampled_template.inputs.template_name = template_name
resampled_template.inputs.tag = tag
resampled_template.inputs.orientation = config["desired_orientation"]

strat_init.update_resource_pool({
template_name: (resampled_template, 'resampled_template')
Expand Down
Loading

0 comments on commit d865870

Please sign in to comment.