Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau committed Nov 20, 2024
1 parent 8bf2da8 commit 049bce9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/clinicaio/models/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from .enum import SUVRReferenceRegions, Tracer, AnatMRISuffix, PETSuffix, FMapSuffix, Modality, Extension
from enum import Enum

from dataclasses import dataclass
# questions: dependance à Pydantic ??


Expand Down Expand Up @@ -181,28 +181,35 @@ def __init__(self, value: int):
self.value = Index(value)


class SuffixEntity(Label):
pass

# CAPS Entities

class SUVREntity(Entity):
key = Label("suvr")
def __init__(self, value: str):
self.value = Label(SUVRReferenceRegions(value))



@dataclass
class BIDSPath:
subject: SubjectEntity
session: SessionEntity
modality: Modality
entities: Optional[list[Entity]]
suffix: Optional[SuffixEntity] # is suffix optional ?
extension: Optional[Extension]


def get_image(self):
def get_image(self) -> Path:
path_ = Path(str(self.subject)) / str(self.session) / str(self.modality)

filename = str(path_)
filename = str(self.subject) + "_" + str(self.session)

for entity in self.entities:
filename += "_" + str(entity)

filename += f".{(str(self.extension) if self.extension else '')}"
filename += f".{(str(self.suffix) if self.suffix else '')}"
filename += f".{(str(self.extension) if self.extension else '')}"

return path_ / filename

0 comments on commit 049bce9

Please sign in to comment.