Skip to content

Commit

Permalink
🔀 Merge hotfix/1.8.7-1 into hotfix/1.8.7-pixdim4
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Dec 12, 2024
2 parents 400d8c1 + cc0ff4d commit ca1f275
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 108 deletions.
26 changes: 17 additions & 9 deletions .github/scripts/autoversioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.

# Update version comment strings
cd CPAC
function wait_for_git_lock() {
while [ -f "./.git/index.lock" ]; do
echo "Waiting for the git lock file to be removed..."
sleep 1
done
}

cd CPAC || exit 1
VERSION=$(python -c "from info import __version__; print(('.'.join(('.'.join(__version__[::-1].split('-')[1].split('.')[1:])[::-1], __version__.split('-')[1])) if '-' in __version__ else __version__).split('+', 1)[0])")
cd ..
echo "v${VERSION}" > version
Expand All @@ -30,8 +37,8 @@ else
# Linux and others
find ./CPAC/resources/configs -name "*.yml" -exec sed -i'' -r "${_SED_COMMAND}" {} \;
fi
git add version
VERSIONS=( `git show $(git log --pretty=format:'%h' -n 2 version | tail -n 1):version` `cat version` )
wait_for_git_lock && git add version
VERSIONS=( `git show $(git log --pretty=format:'%h' -n 1 version | tail -n 1):version` `cat version` )
export PATTERN="(declare|typeset) -a"
if [[ "$(declare -p VERSIONS)" =~ $PATTERN ]]
then
Expand All @@ -52,11 +59,12 @@ then
done
unset IFS
fi
git add CPAC/resources/configs .github/Dockerfiles
wait_for_git_lock && git add CPAC/resources/configs .github/Dockerfiles

# Overwrite top-level Dockerfiles with the CI Dockerfiles
cp .github/Dockerfiles/C-PAC.develop-jammy.Dockerfile Dockerfile
cp .github/Dockerfiles/C-PAC.develop-ABCD-HCP-bionic.Dockerfile variant-ABCD-HCP.Dockerfile
cp .github/Dockerfiles/C-PAC.develop-fMRIPrep-LTS-xenial.Dockerfile variant-fMRIPrep-LTS.Dockerfile
cp .github/Dockerfiles/C-PAC.develop-lite-jammy.Dockerfile variant-lite.Dockerfile
git add *Dockerfile
wait_for_git_lock && cp .github/Dockerfiles/C-PAC.develop-jammy.Dockerfile Dockerfile
wait_for_git_lock && cp .github/Dockerfiles/C-PAC.develop-lite-jammy.Dockerfile variant-lite.Dockerfile
for DOCKERFILE in $(ls *Dockerfile)
do
wait_for_git_lock && git add $DOCKERFILE
done
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ 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").

### Removed

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 ca1f275

Please sign in to comment.