Skip to content

Commit

Permalink
[MAINT] Move merge_nifti_images_in_time_dimension_task in dwi tasks…
Browse files Browse the repository at this point in the history
… module (#1147)
  • Loading branch information
NicolasGensollen authored Apr 25, 2024
1 parent 3fdfea6 commit e2ce719
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
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

0 comments on commit e2ce719

Please sign in to comment.