Skip to content

Commit

Permalink
use dictionnary
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultdvx committed Dec 18, 2024
1 parent f431c7f commit c3b8df9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions clinicadl/transforms/extraction/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from pathlib import Path
from typing import Any, List, Optional, Tuple, Union

import nibabel as nib
import torch
import torchio as tio
from pydantic import computed_field

from clinicadl.dictionary.words import IMAGE, LABEL, SAMPLE
from clinicadl.dictionary.words import IMAGE, LABEL
from clinicadl.utils.config import ClinicaDLConfig
from clinicadl.utils.enum import ExtractionMethod

Expand Down Expand Up @@ -246,14 +245,14 @@ def _check_tio_subject(tio_subject: tio.Subject):
Checks that a TorchIO Subject is valid, i.e. a Subject with a TorchIO ScalarImage
named 'image' and a label named 'label'.
"""
if not hasattr(tio_subject, "image") or not isinstance(
if not hasattr(tio_subject, IMAGE) or not isinstance(
tio_subject.image, tio.ScalarImage
):
raise AttributeError(
"The TorchIO Subject must contain a ScalarImage named 'image'. Got only the following images: "
f"{tio_subject.get_images_names()}"
)
if not hasattr(tio_subject, "label"):
if not hasattr(tio_subject, LABEL):
raise AttributeError(
"The TorchIO Subject must contain an attribute named 'label'."
)
2 changes: 0 additions & 2 deletions clinicadl/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import torch
import torchio as tio

from clinicadl.dictionary.words import LABEL


def get_tio_image(
image: torch.Tensor,
Expand Down

0 comments on commit c3b8df9

Please sign in to comment.