9.1.1. Data Grabbers#
Provide imports for datagrabber sub-package.
- class junifer.datagrabber.BaseDataGrabber(types, datadir)#
Abstract base class for DataGrabber.
For every interface that is required, one needs to provide a concrete implementation of this abstract class.
- Parameters:
- types
list
ofstr
The types of data to be grabbed.
- datadir
str
orpathlib.Path
The directory where the data is / will be stored.
- types
- Attributes:
datadir
pathlib.Path
Get data directory path.
- property datadir: Path#
Get data directory path.
- Returns:
pathlib.Path
Path to the data directory. Can be overridden by subclasses.
- abstract get_element_keys()#
Get element keys.
For each item in the
element
tuple passed to__getitem__()
, this method returns the corresponding key(s).
- abstract get_elements()#
Get elements.
- Returns:
list
List of elements that can be grabbed. The elements can be strings, tuples or any object that will be then used as a key to index the DataGrabber.
- abstract get_item(**element)#
Get the specified item from the dataset.
- class junifer.datagrabber.DataladAOMICID1000(datadir=None, types=None)#
Concrete implementation for datalad-based data fetching of AOMIC ID1000.
- Parameters:
- datadir
str
orPath
orNone
, optional The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None).
- types: {“BOLD”, “BOLD_confounds”, “T1w”, “probseg_CSF”, “probseg_GM”, “probseg_WM”, “DWI”} or a list of the options, optional
AOMIC data types. If None, all available data types are selected. (default None).
- datadir
- class junifer.datagrabber.DataladAOMICPIOP1(datadir=None, types=None, tasks=None)#
Concrete implementation for pattern-based data fetching of AOMIC PIOP1.
- Parameters:
- datadir
str
orPath
orNone
, optional The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None).
- types: {“BOLD”, “BOLD_confounds”, “T1w”, “probseg_CSF”, “probseg_GM”, “probseg_WM”, “DWI”} or a list of the options, optional
AOMIC data types. If None, all available data types are selected. (default None).
- tasks{“restingstate”, “anticipation”, “emomatching”, “faces”, “gstroop”, “workingmemory”} or
list
of the options, optional AOMIC PIOP1 task sessions. If None, all available task sessions are selected (default None).
- datadir
- get_elements()#
Implement fetching list of subjects in the dataset.
- class junifer.datagrabber.DataladAOMICPIOP2(datadir=None, types=None, tasks=None)#
Concrete implementation for pattern-based data fetching of AOMIC PIOP2.
- Parameters:
- datadir
str
orPath
orNone
, optional The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None).
- types: {“BOLD”, “BOLD_confounds”, “T1w”, “probseg_CSF”, “probseg_GM”, “probseg_WM”, “DWI”} or a list of the options, optional
AOMIC data types. If None, all available data types are selected. (default None).
- tasks{“restingstate”, “stopsignal”, “workingmemory”} or
list
of the options, optional AOMIC PIOP2 task sessions. If None, all available task sessions are selected (default None).
- datadir
- class junifer.datagrabber.DataladDataGrabber(rootdir='.', datadir=None, uri=None, **kwargs)#
Abstract base class for datalad-based data fetching.
Defines a DataGrabber that gets data from a datalad sibling.
- Parameters:
- rootdir
str
orpathlib.Path
, optional The path within the datalad dataset to the root directory (default “.”).
- datadir
str
orpathlib.Path
orNone
, optional That directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None).
- uri
str
orNone
, optional URI of the datalad sibling (default None).
- **kwargs
Keyword arguments passed to superclass.
- rootdir
See also
BaseDataGrabber
Abstract base class for DataGrabber.
PatternDataGrabber
Concrete implementation for pattern-based data fetching.
PatternDataladDataGrabber
Concrete implementation for pattern and datalad based data fetching.
Notes
This class is intended to be used as a superclass of a subclass with multiple inheritance.
Methods
install:
Installs (clones) the datalad dataset into the
datadir
. This method is called automatically when the datagrabber is used within a context.remove:
Removes the datalad dataset from the
datadir
. This method is called automatically when the datagrabber is used within a context.- cleanup()#
Cleanup the datalad dataset.
- property datadir: Path#
Get data directory path.
- Returns:
pathlib.Path
Path to the data directory.
- install()#
Install the datalad dataset into the
datadir
.- Raises:
ValueError
If the dataset is already installed but with a different ID.
- class junifer.datagrabber.DataladHCP1200(datadir=None, tasks=None, phase_encodings=None, ica_fix=False)#
Concrete implementation for datalad-based data fetching of HCP1200.
- Parameters:
- datadir
str
orPath
orNone
, optional The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None).
- tasks{“REST1”, “REST2”, “SOCIAL”, “WM”, “RELATIONAL”, “EMOTION”, “LANGUAGE”, “GAMBLING”, “MOTOR”} or
list
of the options orNone
, optional HCP task sessions. If None, all available task sessions are selected (default None).
- phase_encodings{“LR”, “RL”} or
list
of the options orNone
, optional HCP phase encoding directions. If None, both will be used (default None).
- ica_fixbool, optional
Whether to retrieve data that was processed with ICA+FIX. Only “REST1” and “REST2” tasks are available with ICA+FIX (default False).
- datadir
- class junifer.datagrabber.HCP1200(datadir, tasks=None, phase_encodings=None, ica_fix=False, **kwargs)#
Concrete implementation for pattern-based data fetching of HCP1200.
- Parameters:
- datadir
str
orPath
, optional The directory where the data is / will be stored.
- tasks{“REST1”, “REST2”, “SOCIAL”, “WM”, “RELATIONAL”, “EMOTION”, “LANGUAGE”, “GAMBLING”, “MOTOR”} or
list
of the options orNone
, optional HCP task sessions. If None, all available task sessions are selected (default None).
- phase_encodings{“LR”, “RL”} or
list
of the options orNone
, optional HCP phase encoding directions. If None, both will be used (default None).
- ica_fixbool, optional
Whether to retrieve data that was processed with ICA+FIX. Only “REST1” and “REST2” tasks are available with ICA+FIX (default False).
- **kwargs
Keyword arguments passed to superclass.
- datadir
- get_elements()#
Implement fetching list of elements in the dataset.
- Returns:
list
The list of elements that can be grabbed in the dataset.
- get_item(subject, task, phase_encoding)#
Implement single element indexing in the database.
- class junifer.datagrabber.MultipleDataGrabber(datagrabbers, **kwargs)#
Concrete implementation for multi sourced data fetching.
Implements a DataGrabber which can be used to fetch data from multiple DataGrabbers.
- Parameters:
- datagrabbers
list
of DataGrabber-like objects The DataGrabbers to use for fetching data.
- **kwargs
Keyword arguments passed to superclass.
- datagrabbers
- get_element_keys()#
Get element keys.
For each item in the
element
tuple passed to__getitem__()
, this method returns the corresponding key(s).
- get_elements()#
Get elements.
- Returns:
list
List of elements that can be grabbed. The elements can be strings, tuples or any object that will be then used as a key to index the the DataGrabber. The element should be present in all of the related DataGrabbers.
- class junifer.datagrabber.PatternDataGrabber(types, patterns, replacements, datadir, confounds_format=None)#
Concrete implementation for pattern-based data fetching.
Implements a DataGrabber that understands patterns to grab data.
- Parameters:
- types
list
ofstr
The types of data to be grabbed.
- patterns
dict
Patterns for each type of data as a dictionary. The keys are the types and the values are the patterns. Each occurrence of the string
{subject}
in the pattern will be replaced by the indexed element.- replacements
str
orlist
ofstr
Replacements in the patterns for each item in the “element” tuple.
- datadir
str
orpathlib.Path
The directory where the data is / will be stored.
- confounds_format{“fmriprep”, “adhoc”} or
None
, optional The format of the confounds for the dataset (default None).
- types
- get_element_keys()#
Get element keys.
For each item in the “element” tuple, this functions returns the corresponding key, that is, the
replacements
of patterns defined in the constructor.
- get_elements()#
Implement fetching list of elements in the dataset.
It will use regex to search for “replacements” in the “patterns” and return the intersection of the results for each type i.e., build a list of elements that have all the required types.
- Returns:
list
The list of elements that can be grabbed in the dataset.
- get_item(**element)#
Implement single element indexing in the database.
This method constructs a real path to the requested item’s data, by replacing the
patterns
with actual values passed via**element
.
- class junifer.datagrabber.PatternDataladDataGrabber(types, patterns, **kwargs)#
Concrete implementation for pattern and datalad based data fetching.
Implements a DataGrabber that gets data from a datalad sibling, interpreting patterns.
- Parameters:
- types
list
ofstr
The types of data to be grabbed.
- patterns
dict
Patterns for each type of data as a dictionary. The keys are the types and the values are the patterns. Each occurrence of the string
{subject}
in the pattern will be replaced by the indexed element.- **kwargs
Keyword arguments passed to superclass.
- types
See also
DataladDataGrabber
Abstract base class for datalad-based data fetching.
PatternDataGrabber
Concrete implementation for pattern-based data fetching.