7.12. Adding Data Types¶
junifer supports most of the data types required for fMRI
but also provides a way to add custom data types in case you work with other
modalities like EEG.
7.12.1. How to add a data type¶
Check extending junifer on how to create a junifer extension if you have not done so.
Define the data type schema in the extension script like so:
from junifer.datagrabber import DataTypeSchema dtype_schema: DataTypeSchema = { "mandatory": ["pattern"], "optional": { "mask": { "mandatory": ["pattern"], "optional": [], }, }, }
The
DataTypeSchemahas two mandatory keys:mandatory: list of stroptional: dict of str andOptionalTypeSchema
mandatorydefines the keys that must be present when defining a pattern in a DataGrabber.optionaldefines the mapping from sub-types that are optional, to their patterns. The patterns in turn require amandatorykey and anoptionalkey both just being the keys that must be there if the optional key is found. It’s possible that the sub-type (maskin the example) can be absent from the dataset.
Register the data type before defining / using a DataGrabber like so:
from junifer.datagrabber import register_data_type ... # registers the data type as "dtype" register_data_type(name="dtype", schema=dtype_schema) ...