infer_task_from_image
- bidsaid.metadata.infer_task_from_image(nifti_file_or_img, task_volume_map)[source]
Infer the task based on the number of volumes in a 4D NIfTI image.
Parameters
- nifti_file_or_img
str,Path, orNifti1Image Path to the NIfTI file or a NIfTI image.
- task_volume_map
dict[str, int]ordict[int, str] A mapping of the task names to the expected number of volumes.
Returns
- str
The task name.
Example
>>> from bidsaid.io import simulate_nifti_image >>> from bidsaid.metadata import infer_task_from_image >>> img = simulate_nifti_image((100, 100, 100, 260)) >>> task_volume_map = {"flanker": 300, "nback": 260} >>> infer_task_from_image(img, task_volume_map) "nback"
- nifti_file_or_img