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

Conversation

NicolasGensollen
Copy link
Member

This PR proposes to move the adapter function merge_nifti_images_in_time_dimension_task from clinica.utils.image to clinica.pipelines.dwi.preprocessing.t1.tasks where other tasks for this pipeline are defined.
The function definition is kept in the image module.

@NicolasGensollen NicolasGensollen self-assigned this Apr 23, 2024
@NicolasGensollen NicolasGensollen added this to the v0.9.0 milestone Apr 23, 2024
@NicolasGensollen NicolasGensollen marked this pull request as ready for review April 23, 2024 14:58
@AliceJoubert
Copy link
Contributor

Thanks Nicolas ! I juste have a question ; should those functions be unit tested ? ì don't think I saw any corresponding unit test

@NicolasGensollen
Copy link
Member Author

Thanks Nicolas ! I juste have a question ; should those functions be unit tested ? ì don't think I saw any corresponding unit test

Thanks for the review @AliceJoubert !

The function merge_nifti_images_in_time_dimension is unit tested here:

def test_merge_nifti_images_in_time_dimension_wrong_file_number(tmp_path):
from clinica.utils.image import merge_nifti_images_in_time_dimension
with pytest.raises(
ValueError,
match="At least 2 files are required.",
):
merge_nifti_images_in_time_dimension(())
merge_nifti_images_in_time_dimension((tmp_path / "vol1.nii.gz"))
def test_merge_nifti_images_in_time_dimension_non_existing_file(tmp_path):
from clinica.utils.image import merge_nifti_images_in_time_dimension
with pytest.raises(
FileNotFoundError,
match="the following",
):
merge_nifti_images_in_time_dimension(
(tmp_path / "vol1.nii.gz", tmp_path / "vol2.nii.gz")
)
def test_merge_nifti_images_in_time_dimension_wrong_dimension(tmp_path):
from clinica.utils.image import merge_nifti_images_in_time_dimension
for i, input_data in enumerate((np.zeros((5, 5, 5, 10)), np.zeros((5, 5)))):
img = nib.Nifti1Image(input_data, affine=np.eye(4))
nib.save(img, tmp_path / f"foo{i}.nii.gz")
with pytest.raises(
ValueError,
match="Only 3D or 4D images can be concatenated.",
):
merge_nifti_images_in_time_dimension(
tuple(tmp_path / f"foo{i}.nii.gz" for i in range(2))
)

The adapter merge_nifti_images_in_time_dimension_task isn't tested by the unit test suite since it is a simple wrapper. It is indirectly tested by the non regression tests though.

@NicolasGensollen NicolasGensollen merged commit e2ce719 into aramis-lab:dev Apr 25, 2024
16 checks passed
@NicolasGensollen NicolasGensollen deleted the move-merge_nifti_images_in_time_dimension_task branch April 25, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants