clinicadl.data.utils.remove_tensors¶
- clinicadl.data.utils.remove_tensors(description_json: Path | str) None[source]¶
To delete tensors in a dataset.
It will remove all the tensors saved with
BidsDataset.to_tensorsassociated with the input.jsonfile.- Parameters:
description_json (PathType) – Path to the
.jsonfile associated to the tensor conversion you want to delete.
Examples
from clinicadl.data.datasets import BidsDataset from clinicadl.data.utils import remove_tensors from clinicadl.io.bids import BidsFileType from pathlib import Path dataset = BidsDataset( bids="bids_path", file_type=BidsFileType(data_type="anat", suffix="T1w") ) dataset.to_tensors() # the json file is "bids_path/derivatives/tensors/src-T1w_conv-raw_description.json"
>>> remove_tensors("bids_path/derivatives/tensors/src-T1w_conv-raw_description.json") >>> Path("bids_path/derivatives/tensors/src-T1w_conv-raw_description.json").is_file() False >>> Path("bids_path/derivatives/tensors/src-T1w_conv-raw_participantsXsessions.tsv").is_file() False >>> Path("bids_path/derivatives/tensors/sub-000/ses-M000/sub-000_ses-M000_src-T1w_conv-raw_tensors.pt").is_file() False