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

[MAINT] Move merge_nifti_images_in_time_dimension_task in dwi tasks module #1147

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clinica/pipelines/dwi/preprocessing/t1/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,10 @@ def rename_into_caps_task(
Path(b_vectors_preproc_filename),
Path(b0_brain_mask_filename),
)


def merge_nifti_images_in_time_dimension_task(image1: str, image2: str) -> str:
"""Merges the two provided volumes in the time (4th) dimension."""
from clinica.utils.image import merge_nifti_images_in_time_dimension

return str(merge_nifti_images_in_time_dimension((image1, image2)))
2 changes: 1 addition & 1 deletion clinica/pipelines/dwi/preprocessing/t1/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def b0_flirt_pipeline(num_b0s: int, name: str = "b0_coregistration"):
import nipype.pipeline.engine as pe
from nipype.interfaces import fsl

from clinica.utils.image import merge_nifti_images_in_time_dimension_task
from .tasks import merge_nifti_images_in_time_dimension_task

inputnode = pe.Node(niu.IdentityInterface(fields=["in_file"]), name="inputnode")
fslroi_ref = pe.Node(fsl.ExtractROI(args="0 1"), name="b0_reference")
Expand Down
15 changes: 7 additions & 8 deletions clinica/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import numpy as np
from nibabel.nifti1 import Nifti1Image

__all__ = [
"compute_aggregated_volume",
"get_new_image_like",
"merge_nifti_images_in_time_dimension",
"remove_dummy_dimension_from_image",
]


def compute_aggregated_volume(
image_filename: PathLike,
Expand Down Expand Up @@ -142,14 +149,6 @@ def _check_volumes_from_images(images: Tuple[Path, ...]) -> Tuple[np.ndarray, ..
return tuple(four_dimensional_volumes)


def merge_nifti_images_in_time_dimension_task(image1: str, image2: str) -> str:
"""Merges the two provided volumes in the time (4th) dimension."""
# This is needed because Nipype needs to have self-contained functions
from clinica.utils.image import merge_nifti_images_in_time_dimension # noqa

return str(merge_nifti_images_in_time_dimension((image1, image2)))


def remove_dummy_dimension_from_image(image: str, output: str) -> str:
"""Remove all dummy dimensions (i.e. equal to 1) from an image.

Expand Down
Loading