Skip to content

Commit

Permalink
[MAINT] Move bids version constant definition to bids module (#1153)
Browse files Browse the repository at this point in the history
* move bids version definition

* update unit tests
  • Loading branch information
NicolasGensollen authored Apr 25, 2024
1 parent e2ce719 commit cfa5874
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clinica/iotools/bids_dataset_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cattr.gen import make_dict_unstructure_fn, override
from cattr.preconf.json import make_converter

BIDS_VERSION = "1.7.0"
from clinica.utils.bids import BIDS_VERSION


@define
Expand Down
14 changes: 12 additions & 2 deletions clinica/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
from pathlib import Path
from typing import Dict, Tuple, Union

__all__ = [
"BIDSLabel",
"BIDSFileName",
"BIDS_VERSION",
"Extension",
"Suffix",
]

BIDS_VERSION = "1.7.0"


class Extension(str, Enum):
"""Possible extensions in BIDS file names."""
Expand Down Expand Up @@ -114,7 +124,7 @@ def name(self) -> str:

@classmethod
def from_name(cls, filename: Union[str, PathLike]):
filename, extension = split_name_from_extension(filename)
filename, extension = _split_name_from_extension(filename)
entities, suffix = _tokenize_filename_no_ext(filename)
subject = entities.pop("sub")
session = entities.pop("ses")
Expand Down Expand Up @@ -164,7 +174,7 @@ def _tokenize_filename_no_ext(
return entities, suffix


def split_name_from_extension(filename: Union[str, PathLike]) -> Tuple[str, str]:
def _split_name_from_extension(filename: Union[str, PathLike]) -> Tuple[str, str]:
extension = ""
filename = Path(filename)
while "." in filename.name:
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/iotools/test_bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def expected_description_content(
) -> str:
import json

from clinica.iotools.bids_dataset_description import BIDS_VERSION
from clinica.utils.bids import BIDS_VERSION

expected_version = BIDS_VERSION if bids_version is None else bids_version
desc_dict = {
Expand Down

0 comments on commit cfa5874

Please sign in to comment.