You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should define what the API should look like for reading BIDS and CAPS datasets.
Here are some thoughts to start the discussion:
classVisit:
"""Defines a visit in a longitudinal dataset."""subject: Subjectsession: SessionclassDataset:
"""Base abstract class for datasets."""root: PathclassLongitudinalDataset(Dataset):
"""Base class for longitudinal datasets with subjects and sessions layout."""subjects: list[Subject]
defget_subject_metadata(self, subject: Subject|None) ->pd.DataFrame:
"""Return the metadata of participants.tsv for the given subject or all of them."""
...
defget_sessions(self, subject: Subject) ->list[Session]:
"""Get the sessions for given subject."""
...
defget_visits() ->list[Visit]:
"""Return all the visits."""
...
defget_session_metadata(self, subject: Subject, session: Session|None) ->pd.DataFrame:
"""Return the metadata of sessions.tsv for the provided visit (if session is None, merge all sessions for given subject)."""
...
defget_modalities(visit: Visit|None) ->Set[Modality]:
"""Return all the modalities for the given visit or in the dataset."""
...
defget_scans_metadata(self, visit: Visit) ->pd.DataFrame:
"""Return the metadata of scans.tsv for the provided visit."""
...
classBIDSDataset(LongitudinalDataset):
description: BIDSDatasetDescriptionfiles: list[BIDSPath]
defget_files(
self,
subject: Subject|None,
session: Session|None,
modality: Modality|None,
entities: list[Entity] |None,
extension: Extension|None,
) ->list[BIDSPath]:
"""Return all files matching the provided parameters."""
...
classCAPSDataset(LongitudinalDataset):
description: CAPSDatasetDescriptionclassCAPSGroupDataset(LongitudinalDataset):
...
# This is already implemented in Clinica:classDatasetType(str, Enum):
RAW="raw"DERIVATIVE="derivative"classBIDSDatasetDescription:
name: strbids_version: Version=BIDS_VERSIONdataset_type: DatasetType=DatasetType.RAWclassCAPSDatasetDescription:
name: strbids_version: Version=BIDS_VERSIONcaps_version: Version=CAPS_VERSIONdataset_type: DatasetType=DatasetType.DERIVATIVEprocessing: MutableSequence[CAPSProcessingDescription] = []
classCAPSProcessingDescription:
name: strdate: IsoDateauthor: strmachine: strinput_path: strclinica_version: Versiondependencies: List[SoftwareDependency]
Usage would more or less look like that:
dataset=BIDSDataset.from_path("./bids")
session_df=dataset.get_session_metadata()
dataset.get_files(modality="T1w", extension=".nii.gz") # Get T1w nifty images for all visitsdataset.get_files(subject="sub-01", extension=".json") # Get all JSON files for subject sub-01dataset.get_files(
subject="sub-01",
session="ses-M000",
modality="pet",
entities=[{"prefix": "trc", "value": Tracer.18FFDG}], # not sure how to nicely provide these filtersextension=".nii.gz",
) # Get the PET scan for subject sub-01 and session M000 with tracer 18FFDG
The text was updated successfully, but these errors were encountered:
We should define what the API should look like for reading BIDS and CAPS datasets.
Here are some thoughts to start the discussion:
Usage would more or less look like that:
The text was updated successfully, but these errors were encountered: