refactor: consistent use of DataGrabber #226

Merged
synchon merged 32 commits from chore/dg-cleanup into main 2023-06-20 10:27:52 +00:00
48 changed files with 442 additions and 410 deletions

View file

@ -0,0 +1 @@
Adopt ``DataGrabber`` consistently throughout codebase to match with the documentation by `Synchon Mandal`_

View file

@ -22,7 +22,7 @@ data type including source and previous transformation steps.
The :ref:`Data Grabber <datagrabber>` step adds the ``path`` second-level key The :ref:`Data Grabber <datagrabber>` step adds the ``path`` second-level key
which gives the path to the file containing the data. The ``meta`` key in this which gives the path to the file containing the data. The ``meta`` key in this
step only contains information about the datagrabber used. step only contains information about the DataGrabber used.
.. code-block:: python .. code-block:: python

View file

@ -9,29 +9,29 @@ Description
----------- -----------
The ``DataGrabber`` is an object that can provide an interface to datasets you The ``DataGrabber`` is an object that can provide an interface to datasets you
want to work with in junifer. Every concrete implementation of a datagrabber is want to work with in junifer. Every concrete implementation of a DataGrabber is
aware of a particular dataset's structure and thus allows you to fetch specific aware of a particular dataset's structure and thus allows you to fetch specific
elements of interest from the dataset. It adds the ``path`` key to each elements of interest from the dataset. It adds the ``path`` key to each
:ref:`data type <data_types>` in the :ref:`Data object <data_object>`. :ref:`data type <data_types>` in the :ref:`Data object <data_object>`.
Datagrabbers are intended to be used as context managers. When used within a DataGrabbers are intended to be used as context managers. When used within a
context, a datagrabber takes care of any pre and post steps for interacting with context, a DataGrabber takes care of any pre and post steps for interacting with
the dataset, for example, downloading and cleaning up. As the interface the dataset, for example, downloading and cleaning up. As the interface
is consistent, you always use the same procedure to interact with the datagrabber. is consistent, you always use the same procedure to interact with the DataGrabber.
For example, a concrete implementation of :class:`.DataladDataGrabber` can For example, a concrete implementation of :class:`.DataladDataGrabber` can
provide junifer with data from a Datalad dataset. Of course, datagrabbers are not provide junifer with data from a Datalad dataset. Of course, DataGrabbers are not
only meant to work with Datalad datasets but any dataset. only meant to work with Datalad datasets but any dataset.
If you are interested in using already provided datagrabbers, please go to If you are interested in using already provided DataGrabbers, please go to
:doc:`../builtin`. And, if you want to implement your own datagrabber, you need :doc:`../builtin`. And, if you want to implement your own DataGrabber, you need
to provide concrete implementations of base classes already provided. to provide concrete implementations of base classes already provided.
Base Classes Base Classes
------------ ------------
In this section, we showcase different abstract base classes you might want to In this section, we showcase different abstract base classes you might want to
use to implement your own datagrabber. use to implement your own DataGrabber.
.. list-table:: .. list-table::
:widths: auto :widths: auto
@ -41,16 +41,16 @@ use to implement your own datagrabber.
- Description - Description
* - :class:`.BaseDataGrabber` * - :class:`.BaseDataGrabber`
- | The abstract base class providing you an interface to implement your - | The abstract base class providing you an interface to implement your
| own datagrabber. You should try to avoid using this directly and | own DataGrabber. You should try to avoid using this directly and
| instead use :class:`.PatternDataGrabber` or | instead use :class:`.PatternDataGrabber` or
| :class:`.DataladDataGrabber`. To build your own custom *low-level* | :class:`.DataladDataGrabber`. To build your own custom *low-level*
| datagrabber, you need to override the ``get_elements_keys``, | DataGrabber, you need to override the ``get_elements_keys``,
| ``get_elements`` and ``get_item`` methods, and most of the time you | ``get_elements`` and ``get_item`` methods, and most of the time you
| should also override other existing methods like ``__enter__`` and | should also override other existing methods like ``__enter__`` and
| ``__exit__``. | ``__exit__``.
* - :class:`.PatternDataGrabber` * - :class:`.PatternDataGrabber`
- | It implements functionality to help you define the pattern of the - | It implements functionality to help you define the pattern of the
| dataset you want to get. For example, you know that T1 images are | dataset you want to get. For example, you know that T1w images are
| found in a directory following the pattern: | found in a directory following the pattern:
| ``{subject}/anat/{subject}_T1w.nii.gz`` inside of the dataset. Now you | ``{subject}/anat/{subject}_T1w.nii.gz`` inside of the dataset. Now you
| can provide this to the :class:`.PatternDataGrabber` and it will be | can provide this to the :class:`.PatternDataGrabber` and it will be

View file

@ -75,10 +75,10 @@ Data Grabber
^^^^^^^^^^^^ ^^^^^^^^^^^^
The ``datagrabber`` section must be configured using the ``kind`` key to specify The ``datagrabber`` section must be configured using the ``kind`` key to specify
the datagrabber to use. Additional keys correspond to the parameters of the the DataGrabber to use. Additional keys correspond to the parameters of the
datagrabber. DataGrabber constructor.
For example, to use the :class:`.DataladAOMICPIOP1` datagrabber, we just need to For example, to use the :class:`.DataladAOMICPIOP1` DataGrabber, we just need to
specify its name as the ``kind`` key. specify its name as the ``kind`` key.
.. code-block:: yaml .. code-block:: yaml
@ -86,8 +86,9 @@ specify its name as the ``kind`` key.
datagrabber: datagrabber:
kind: DataladAOMICPIOP1 kind: DataladAOMICPIOP1
However, it is also possible to pass parameters to the datagrabber. In this case, However, it is also possible to pass parameters to the DataGrabber constructor.
we can restrict the datagrabber to fetch only the ``restingstate`` task. In this case, we can restrict the DataGrabber to fetch only the ``restingstate``
task.
.. code-block:: yaml .. code-block:: yaml

View file

@ -1,8 +1,8 @@
""" """
Generic BIDS datagrabber for datalad. Generic BIDS DataGrabber for datalad.
===================================== =====================================
This example uses a generic BIDS datagraber to get the data from a BIDS dataset This example uses a generic BIDS DataGraber to get the data from a BIDS dataset
store in a datalad remote sibling. store in a datalad remote sibling.
Authors: Federico Raimondo Authors: Federico Raimondo
@ -20,9 +20,9 @@ configure_logging(level="INFO")
############################################################################### ###############################################################################
# The BIDS datagrabber requires three parameters: the types of data we want, # The BIDS DataGrabber requires three parameters: the types of data we want,
# the specific pattern that matches each type, and the variables that will be # the specific pattern that matches each type, and the variables that will be
# replaced int he patterns. # replaced in the patterns.
types = ["T1w", "BOLD"] types = ["T1w", "BOLD"]
patterns = { patterns = {
"T1w": "{subject}/anat/{subject}_T1w.nii.gz", "T1w": "{subject}/anat/{subject}_T1w.nii.gz",
@ -30,15 +30,15 @@ patterns = {
} }
replacements = ["subject"] replacements = ["subject"]
############################################################################### ###############################################################################
# Additionally, a datalad datagrabber requires the URI of the remote sibling # Additionally, a datalad-based DataGrabber requires the URI of the remote
# and the location of the dataset within the remote sibling. # sibling and the location of the dataset within the remote sibling.
repo_uri = "https://gin.g-node.org/juaml/datalad-example-bids" repo_uri = "https://gin.g-node.org/juaml/datalad-example-bids"
rootdir = "example_bids" rootdir = "example_bids"
############################################################################### ###############################################################################
# Now we can use the datagrabber within a `with` context # Now we can use the DataGrabber within a `with` context.
# One thing we can do with any datagrabber is iterate over the elements. # One thing we can do with any DataGrabber is iterate over the elements.
# In this case, each element of the datagrabber is one session. # In this case, each element of the DataGrabber is one session.
with PatternDataladDataGrabber( with PatternDataladDataGrabber(
rootdir=rootdir, rootdir=rootdir,
types=types, types=types,
@ -50,9 +50,9 @@ with PatternDataladDataGrabber(
print(elem) print(elem)
############################################################################### ###############################################################################
# Another feature of the datagrabber is the ability to get a specific # Another feature of the DataGrabber is the ability to get a specific
# element by its name. In this case, we index `sub-01` and we get the file # element by its name. In this case, we index `sub-01` and we get the file
# paths for the two types of data we want (T1w and bold). # paths for the two types of data we want (T1w and BOLD).
with PatternDataladDataGrabber( with PatternDataladDataGrabber(
rootdir=rootdir, rootdir=rootdir,
types=types, types=types,

View file

@ -25,7 +25,7 @@ from junifer.utils import configure_logging
configure_logging(level="INFO") configure_logging(level="INFO")
############################################################################## ##############################################################################
# Define the datagrabber interface # Define the DataGrabber interface
datagrabber = { datagrabber = {
"kind": "SPMAuditoryTestingDataGrabber", "kind": "SPMAuditoryTestingDataGrabber",
} }

View file

@ -11,20 +11,24 @@ from ..pipeline.registry import register
def register_datagrabber(klass: Type) -> Type: def register_datagrabber(klass: Type) -> Type:
"""Datagrabber registration decorator. """Register DataGrabber.
Registers the datagrabber so it can be used by name. Registers the DataGrabber so it can be used by name.
Parameters Parameters
---------- ----------
klass: class klass: class
The class of the datagrabber to register. The class of the DataGrabber to register.
Returns Returns
------- -------
klass: class klass: class
The unmodified input class. The unmodified input class.
Notes
-----
It should only be used as a decorator.
""" """
register( register(
step="datagrabber", step="datagrabber",

View file

@ -24,17 +24,17 @@ from .utils import yaml
def _get_datagrabber(datagrabber_config: Dict) -> BaseDataGrabber: def _get_datagrabber(datagrabber_config: Dict) -> BaseDataGrabber:
"""Get datagrabber. """Get DataGrabber.
Parameters Parameters
---------- ----------
datagrabber_config : dict datagrabber_config : dict
The config to get the datagrabber using. The config to get the DataGrabber using.
Returns Returns
------- -------
dict object
The datagrabber. The DataGrabber.
""" """
datagrabber_params = datagrabber_config.copy() datagrabber_params = datagrabber_config.copy()
@ -90,8 +90,8 @@ def run(
workdir : str or pathlib.Path workdir : str or pathlib.Path
Directory where the pipeline will be executed. Directory where the pipeline will be executed.
datagrabber : dict datagrabber : dict
Datagrabber to use. Must have a key ``kind`` with the kind of DataGrabber to use. Must have a key ``kind`` with the kind of
datagrabber to use. All other keys are passed to the datagrabber DataGrabber to use. All other keys are passed to the DataGrabber
init function. init function.
markers : list of dict markers : list of dict
List of markers to extract. Each marker is a dict with at least two List of markers to extract. Each marker is a dict with at least two
@ -108,7 +108,7 @@ def run(
preprocessor to use. All other keys are passed to the preprocessor preprocessor to use. All other keys are passed to the preprocessor
init function (default None). init function (default None).
elements : str or tuple or list of str or tuple, optional elements : str or tuple or list of str or tuple, optional
Element(s) to process. Will be used to index the datagrabber Element(s) to process. Will be used to index the DataGrabber
(default None). (default None).
""" """
@ -220,7 +220,7 @@ def queue(
overwrite : bool, optional overwrite : bool, optional
Whether to overwrite if job directory already exists (default False). Whether to overwrite if job directory already exists (default False).
elements : str or tuple or list of str or tuple, optional elements : str or tuple or list of str or tuple, optional
Element(s) to process. Will be used to index the datagrabber Element(s) to process. Will be used to index the DataGrabber
(default None). (default None).
**kwargs : dict **kwargs : dict
The keyword arguments to pass to the job queue system. The keyword arguments to pass to the job queue system.
@ -339,7 +339,7 @@ def _queue_condor(
yaml_config : pathlib.Path yaml_config : pathlib.Path
The path to the YAML config file. The path to the YAML config file.
elements : list of str or tuple elements : list of str or tuple
Element(s) to process. Will be used to index the datagrabber. Element(s) to process. Will be used to index the DataGrabber.
config : dict config : dict
The configuration to be used for queueing the job. The configuration to be used for queueing the job.
env : dict, optional env : dict, optional
@ -559,7 +559,7 @@ def _queue_slurm(
yaml_config : pathlib.Path yaml_config : pathlib.Path
The path to the YAML config file. The path to the YAML config file.
elements : str or tuple or list[str or tuple], optional elements : str or tuple or list[str or tuple], optional
Element(s) to process. Will be used to index the datagrabber Element(s) to process. Will be used to index the DataGrabber
(default None). (default None).
config : dict config : dict
The configuration to be used for queueing the job. The configuration to be used for queueing the job.

View file

@ -1,4 +1,4 @@
"""Provide class for AOMIC1000 VBM juseless datalad datagrabber.""" """Provide concrete implementation for AOMIC ID1000 VBM DataGrabber."""
# Authors: Felix Hoffstaedter <f.hoffstaedter@fz-juelich.de> # Authors: Felix Hoffstaedter <f.hoffstaedter@fz-juelich.de>
# Synchon Mandal <s.mandal@fz-juelich.de> # Synchon Mandal <s.mandal@fz-juelich.de>
@ -13,13 +13,13 @@ from ....datagrabber import PatternDataladDataGrabber
@register_datagrabber @register_datagrabber
class JuselessDataladAOMICID1000VBM(PatternDataladDataGrabber): class JuselessDataladAOMICID1000VBM(PatternDataladDataGrabber):
"""Juseless AOMICID1000 VBM Data Grabber class. """Concrete implementation for Juseless AOMIC ID1000 VBM data fetching.
Implements a Data Grabber to access the AOMICID1000 VBM data in Juseless. Implements a DataGrabber to access the AOMIC ID1000 VBM data in Juseless.
Parameters Parameters
---------- ----------
datadir : str or pathlib.Path, optional datadir : str or pathlib.Path or None, optional
The directory where the datalad dataset will be cloned. If None, The directory where the datalad dataset will be cloned. If None,
the datalad dataset will be cloned into a temporary directory the datalad dataset will be cloned into a temporary directory
(default None). (default None).

View file

@ -1,4 +1,4 @@
"""Provide class for CamCAN VBM juseless datalad datagrabber.""" """Provide concrete implementation for CamCAN VBM DataGrabber."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -14,13 +14,13 @@ from ....datagrabber import PatternDataladDataGrabber
@register_datagrabber @register_datagrabber
class JuselessDataladCamCANVBM(PatternDataladDataGrabber): class JuselessDataladCamCANVBM(PatternDataladDataGrabber):
"""Juseless CamCAN VBM Data Grabber class. """Concrete implementation for Juseless CamCAN VBM data fetching.
Implements a Data Grabber to access the CamCAN VBM data in Juseless. Implements a DataGrabber to access the CamCAN VBM data in Juseless.
Parameters Parameters
---------- ----------
datadir : str or pathlib.Path, optional datadir : str or pathlib.Path or None, optional
The directory where the datalad dataset will be cloned. If None, The directory where the datalad dataset will be cloned. If None,
the datalad dataset will be cloned into a temporary directory the datalad dataset will be cloned into a temporary directory
(default None). (default None).

View file

@ -1,4 +1,4 @@
"""Provide class for IXI VBM juseless datalad datagrabber.""" """Provide concrete implementation for IXI VBM DataGrabber."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -15,19 +15,20 @@ from ....utils import raise_error
@register_datagrabber @register_datagrabber
class JuselessDataladIXIVBM(PatternDataladDataGrabber): class JuselessDataladIXIVBM(PatternDataladDataGrabber):
"""Juseless IXI VBM Data Grabber class. """Concrete implementation for Juseless IXI VBM data fetching.
Implements a Data Grabber to access the IXI VBM data in Juseless. Implements a DataGrabber to access the IXI VBM data in Juseless.
Parameters Parameters
---------- ----------
datadir : str or pathlib.Path, optional datadir : str or pathlib.Path or None, optional
The directory where the datalad dataset will be cloned. If None, The directory where the datalad dataset will be cloned. If None,
the datalad dataset will be cloned into a temporary directory the datalad dataset will be cloned into a temporary directory
(default None). (default None).
sites : {"Guys", "HH", "IOP"} or list of the options, optional. sites : {"Guys", "HH", "IOP"} or list of the options or None, optional
Which sites to access data from. If None, all available sites are Which sites to access data from. If None, all available sites are
selected (default None). selected (default None).
""" """
def __init__( def __init__(

View file

@ -1,4 +1,4 @@
"""Provide tests for AOMICID1000 VBM juseless datagrabber.""" """Provide tests for JuselessDataladAOMICID1000VBM."""
# Authors: Felix Hoffstaedter <f.hoffstaedter@fz-juelich.de> # Authors: Felix Hoffstaedter <f.hoffstaedter@fz-juelich.de>
# Synchon Mandal <s.mandal@fz-juelich.de> # Synchon Mandal <s.mandal@fz-juelich.de>
@ -19,8 +19,8 @@ if socket.gethostname() != "juseless":
configure_logging(level="DEBUG") configure_logging(level="DEBUG")
def test_juselessdataladaomicid1000vbm_datagrabber() -> None: def test_JuselessDataladAOMICID1000VBM() -> None:
"""Test datalad AOMICID1000VBM datagrabber.""" """Test JuselessDataladAOMICID1000VBM."""
with JuselessDataladAOMICID1000VBM() as dg: with JuselessDataladAOMICID1000VBM() as dg:
all_elements = dg.get_elements() all_elements = dg.get_elements()
test_element = all_elements[0] test_element = all_elements[0]

View file

@ -1,4 +1,4 @@
"""Provide tests for CamCAN VBM juseless datagrabber.""" """Provide tests for JuselessDataladCamCANVBM."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -20,8 +20,8 @@ if socket.gethostname() != "juseless":
configure_logging(level="DEBUG") configure_logging(level="DEBUG")
def test_juselessdataladcamcanvbm_datagrabber() -> None: def test_JuselessDataladCamCANVBM() -> None:
"""Test datalad CamCANVBM datagrabber.""" """Test JuselessDataladCamCANVBM."""
with JuselessDataladCamCANVBM() as dg: with JuselessDataladCamCANVBM() as dg:
all_elements = dg.get_elements() all_elements = dg.get_elements()
test_element = all_elements[0] test_element = all_elements[0]

View file

@ -1,4 +1,4 @@
"""Provide tests for IXI VBM juseless datagrabber.""" """Provide tests for JuselessDataladIXIVBM."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -20,8 +20,8 @@ if socket.gethostname() != "juseless":
configure_logging(level="DEBUG") configure_logging(level="DEBUG")
def test_juselessdataladixivbm_datagrabber() -> None: def test_JuselessDataladIXIVBM() -> None:
"""Test datalad IXIVBM datagrabber.""" """Test JuselessDataladIXIVBM."""
with JuselessDataladIXIVBM() as dg: with JuselessDataladIXIVBM() as dg:
all_elements = dg.get_elements() all_elements = dg.get_elements()
test_element = all_elements[0] test_element = all_elements[0]
@ -33,8 +33,8 @@ def test_juselessdataladixivbm_datagrabber() -> None:
assert out["VBM_GM"]["path"].exists() assert out["VBM_GM"]["path"].exists()
def test_juselessdataladixivbm_datagrabber_invalid_site() -> None: def test_JuselessDataladIXIVBM_invalid_site() -> None:
"""Test datalad IXIVBM datagrabber with invalid site.""" """Test JuselessDataladIXIVBM with invalid site."""
with pytest.raises(ValueError, match="notavalidsite not a valid site"): with pytest.raises(ValueError, match="notavalidsite not a valid site"):
with JuselessDataladIXIVBM(sites="notavalidsite"): with JuselessDataladIXIVBM(sites="notavalidsite"):
pass pass

View file

@ -1,4 +1,4 @@
"""Provide tests for UCLA juseless datagrabber.""" """Provide tests for JuselessUCLA."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -21,8 +21,8 @@ if socket.gethostname() != "juseless":
configure_logging(level="DEBUG") configure_logging(level="DEBUG")
def test_juseless_ucla_datagrabber() -> None: def test_JuselessUCLA() -> None:
"""Test juseless ucla datagrabber.""" """Test JuselessUCLA."""
with JuselessUCLA() as dg: with JuselessUCLA() as dg:
all_elements = dg.get_elements() all_elements = dg.get_elements()
test_element = all_elements[0] test_element = all_elements[0]
@ -46,8 +46,8 @@ def test_juseless_ucla_datagrabber() -> None:
"tasks", "tasks",
[None, "rest", ["rest", "stopsignal"]], [None, "rest", ["rest", "stopsignal"]],
) )
def test_juseless_ucla_datagrabber_task_params(tasks: Optional[str]) -> None: def test_JuselessUCLA_task_params(tasks: Optional[str]) -> None:
"""Test juseless ucla datagrabber with different task parameters. """Test JuselessUCLA with different task parameters.
Parameters Parameters
---------- ----------
@ -81,8 +81,8 @@ def test_juseless_ucla_datagrabber_task_params(tasks: Optional[str]) -> None:
assert el[1] in ["rest", "stopsignal"] assert el[1] in ["rest", "stopsignal"]
def test_juseless_ucla_datagrabber_invalid_tasks() -> None: def test_JuselessUCLA_invalid_tasks() -> None:
"""Test juseless ucla datagrabber with invalid task parameters.""" """Test JuselessUCLA with invalid task parameters."""
with pytest.raises( with pytest.raises(
ValueError, match="invalid is not a valid task in the UCLA" ValueError, match="invalid is not a valid task in the UCLA"
): ):

View file

@ -1,4 +1,4 @@
"""Provide tests for juseless datagrabber.""" """Provide tests for JuselessDataladUKBVBM."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -20,8 +20,8 @@ if socket.gethostname() != "juseless":
configure_logging(level="DEBUG") configure_logging(level="DEBUG")
def test_juselessdataladukbvbm_datagrabber() -> None: def test_JuselessDataladUKBVBM() -> None:
"""Test datalad UKBVBM datagrabber.""" """Test JuselessDataladUKBVBM."""
with JuselessDataladUKBVBM() as dg: with JuselessDataladUKBVBM() as dg:
all_elements = dg.get_elements() all_elements = dg.get_elements()
test_element = all_elements[0] test_element = all_elements[0]

View file

@ -1,4 +1,4 @@
"""Provide a concrete implementation for UCLA dataset.""" """Provide concrete implementation for UCLA DataGrabber."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -14,16 +14,18 @@ from ....utils import raise_error
@register_datagrabber @register_datagrabber
class JuselessUCLA(PatternDataGrabber): class JuselessUCLA(PatternDataGrabber):
"""Concrete implementation for pattern-based data fetching of UCLA data. """Concrete implementation for Juseless UCLA data fetching.
Implements a DataGrabber to access the UCLA data in Juseless.
Parameters Parameters
---------- ----------
datadir : str or Path, optional datadir : str or pathlib.Path, optional
The directory where the dataset is stored The directory where the dataset is stored
(default '/data/project/psychosis_thalamus/data/fmriprep'). (default "/data/project/psychosis_thalamus/data/fmriprep").
tasks : {"rest", "bart", "bht", "pamenc", "pamret", \ tasks : {"rest", "bart", "bht", "pamenc", "pamret", \
"scap", "taskswitch", "stopsignal"} or \ "scap", "taskswitch", "stopsignal"} or \
list of the options, optional list of the options or None, optional
UCLA task sessions. If None, all available task sessions are UCLA task sessions. If None, all available task sessions are
selected (default None). selected (default None).
@ -118,5 +120,6 @@ class JuselessUCLA(PatternDataGrabber):
elements : list elements : list
The list of elements that can be grabbed in the dataset after The list of elements that can be grabbed in the dataset after
imposing constraints based on specified tasks. imposing constraints based on specified tasks.
""" """
return [x for x in super().get_elements() if x[1] in self.tasks] return [x for x in super().get_elements() if x[1] in self.tasks]

View file

@ -1,4 +1,4 @@
"""Provide class for juseless datalad datagrabber.""" """Provide concrete implementation for UKB VBM DataGrabber."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
@ -14,13 +14,13 @@ from ....datagrabber import PatternDataladDataGrabber
@register_datagrabber @register_datagrabber
class JuselessDataladUKBVBM(PatternDataladDataGrabber): class JuselessDataladUKBVBM(PatternDataladDataGrabber):
"""Juseless UKB VBM Data Grabber class. """Concrete implementation for Juseless UKB VBM data fetching.
Implements a Data Grabber to access the UKB VBM data in Juseless. Implements a DataGrabber to access the UKB VBM data in Juseless.
Parameters Parameters
---------- ----------
datadir : str or pathlib.Path, optional datadir : str or pathlib.Path or None, optional
The directory where the datalad dataset will be cloned. If None, The directory where the datalad dataset will be cloned. If None,
the datalad dataset will be cloned into a temporary directory the datalad dataset will be cloned into a temporary directory
(default None). (default None).

View file

@ -1,32 +0,0 @@
"""Provide tests for juseless datagrabber."""
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de>
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL
import socket
import pytest
from junifer.datagrabber.hcp import DataladHCP1200
from junifer.utils.logging import configure_logging
# Check if the test is running on juseless
if socket.gethostname() != "juseless":
pytest.skip("These tests are only for juseless", allow_module_level=True)
configure_logging(level="DEBUG")
def test_juselessdataladhcp_datagrabber() -> None:
"""Test datalad HCP datagrabber."""
with DataladHCP1200() as dg:
all_elements = dg.get_elements()
test_element = all_elements[0]
out = dg[test_element]
assert out["BOLD"]["path"].exists()
assert out["BOLD"]["path"].isfile()

View file

@ -2,6 +2,7 @@
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de> # Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
# Leonard Sasse <l.sasse@fz-juelich.de> # Leonard Sasse <l.sasse@fz-juelich.de>
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL # License: AGPL
@ -12,5 +13,5 @@ from .pattern import PatternDataGrabber
from .pattern_datalad import PatternDataladDataGrabber from .pattern_datalad import PatternDataladDataGrabber
from .aomic import DataladAOMICID1000, DataladAOMICPIOP1, DataladAOMICPIOP2 from .aomic import DataladAOMICID1000, DataladAOMICPIOP1, DataladAOMICPIOP2
from .hcp import HCP1200, DataladHCP1200 from .hcp1200 import HCP1200, DataladHCP1200
from .multiple import MultipleDataGrabber from .multiple import MultipleDataGrabber

Some files were not shown because too many files have changed in this diff Show more