Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Resource Pool

Radiome edited this page Jun 16, 2021 · 1 revision

Resource Pool is a Radiome structure to feed resources to workflows, and store resources generated by the workflows. As a key-value mapping, it provides the relation between ResourceKey and Resource, with the advantage of querying features so sub-select specific ResourceKeys:

from radiome.core.resource_pool import ResourcePool, ResourceKey as R, Resource

rp = ResourcePool()

rp[R('sub-A00008326_ses-BAS2_task-pCASL_bold')] = \
    Resource('s3://fcp-indi/data/Projects/RocklandSample/RawDataBIDSLatest/sub-A00008326/ses-BAS2/func/sub-A00008326_ses-BAS2_task-pCASL_bold.nii.gz')

The ResourceKey class takes a String or a set of keywork arguments, which uses the keyword as BIDS keys.

from radiome.core.resource_pool import ResourceKey as R

# All these examples represent the same ResourceKey

R('sub-A00008326_ses-BAS2_task-pCASL_bold')
R('bold', sub='A00008326', ses='BAS2', task='pCASL')
R(sub='A00008326', ses='BAS2', task='pCASL', suffix='bold')
R('task-pCASL_bold', sub='A00008326', ses='BAS2')

This class is specialized to act as subsets and supersets of other ResourceKeys, enabling its usage as filters in the ResourcePool.

# subset ⊆ superset
R('sub-A00008326_ses-BAS2_mask') in R('sub-A00008326_mask')

and it has two query operators: * and ^. The asterisk allow to filter for ResourceKeys that has any value for a specific key, but the key is present. For the caret operator, it filter for ResourceKeys that does not has a specific key:

R('sub-A00008326_ses-BAS2_mask') in R('sub-*_ses-BAS2_mask')
R('sub-A00008326_ses-BAS2_mask') in R('sub-*_ses-*_mask')
R('sub-A00008326_mask') not in R('sub-A00008326_ses-*_mask')

R('sub-A00008326_mask') in R('sub-A00008326_ses-^_mask')
R('sub-A00008326_ses-BAS2_mask') not in R('sub-A00008326_ses-^_mask')

To handle different preprocessing strategies, a specialization of the ResourcePool and ResourceKey are created.

R('sub-A00008326_desc-skullstripping-afni+nuis-gsr_bold')

This structure makes it possible to match resources from the same stragety in a StrategyResourcePool, or resources from previous steps, e.g.:

# These resources participate in the same

R('sub-A00008326_T1w')
R('sub-A00008326_desc-skullstripping-afni_mask')
R('sub-A00008326_desc-skullstripping-afni+nuis-gsr_bold')

Clone this wiki locally