Skip to content

Commit

Permalink
[FIX] Fix circular import with DTIBasedMeasure enumeration (#1373)
Browse files Browse the repository at this point in the history
* move DTIBasedMeasure to new clinica.utils.dwi module

* update tests
  • Loading branch information
NicolasGensollen authored Nov 14, 2024
1 parent 93292a0 commit 4d700d7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
13 changes: 2 additions & 11 deletions clinica/pipelines/dwi/dti/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""This module contains utilities used by the DWIDTI pipeline."""

from enum import Enum
from pathlib import Path
from typing import Dict, List, Tuple

from clinica.utils.dwi import DTIBasedMeasure

__all__ = [
"DTIBasedMeasure",
"compute_statistics_on_atlases",
"get_caps_filenames",
"rename_into_caps",
Expand All @@ -15,15 +15,6 @@
]


class DTIBasedMeasure(str, Enum):
"""Possible DTI measures."""

FRACTIONAL_ANISOTROPY = "FA"
MEAN_DIFFUSIVITY = "MD"
AXIAL_DIFFUSIVITY = "AD"
RADIAL_DIFFUSIVITY = "RD"


def compute_statistics_on_atlases(
registered_map: Path, name_map: str, dwi_preprocessed_file: Path
) -> List[Path]:
Expand Down
12 changes: 12 additions & 0 deletions clinica/utils/dwi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from enum import Enum

__all__ = ["DTIBasedMeasure"]


class DTIBasedMeasure(str, Enum):
"""Possible DTI measures."""

FRACTIONAL_ANISOTROPY = "FA"
MEAN_DIFFUSIVITY = "MD"
AXIAL_DIFFUSIVITY = "AD"
RADIAL_DIFFUSIVITY = "RD"
2 changes: 1 addition & 1 deletion clinica/utils/input_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections.abc import Iterable
from typing import Optional, Union

from clinica.pipelines.dwi.dti.utils import DTIBasedMeasure
from clinica.utils.dwi import DTIBasedMeasure
from clinica.utils.pet import ReconstructionMethod, SUVRReferenceRegion, Tracer

# BIDS
Expand Down
2 changes: 1 addition & 1 deletion test/nonregression/pipelines/dwi/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def run_dwi_dti(
input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path
) -> None:
from clinica.pipelines.dwi.dti.pipeline import DwiDti
from clinica.pipelines.dwi.dti.utils import DTIBasedMeasure
from clinica.utils.bids import BIDSFileName
from clinica.utils.dwi import DTIBasedMeasure

caps_dir = output_dir / "caps"

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/utils/test_input_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from clinica.pipelines.dwi.dti.utils import DTIBasedMeasure
from clinica.utils.dwi import DTIBasedMeasure
from clinica.utils.pet import ReconstructionMethod, Tracer


Expand Down
2 changes: 1 addition & 1 deletion test/unittests/utils/test_utils_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def test_clinica_file_reader_dwi_dti_error(tmp_path):


def test_clinica_file_reader_dwi_dti(tmp_path):
from clinica.pipelines.dwi.dti.utils import DTIBasedMeasure
from clinica.utils.dwi import DTIBasedMeasure
from clinica.utils.input_files import dwi_dti
from clinica.utils.inputs import clinica_file_reader, clinica_list_of_files_reader

Expand Down

0 comments on commit 4d700d7

Please sign in to comment.