diff --git a/docs/changes/newsfragments/227.enh b/docs/changes/newsfragments/227.enh new file mode 100644 index 0000000000..51e1b7bc10 --- /dev/null +++ b/docs/changes/newsfragments/227.enh @@ -0,0 +1 @@ +Adopt ``DataReader`` consistently throughout codebase to match with the documentation by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/understanding/data.rst b/docs/understanding/data.rst index 2961ab107e..e5f939e0a7 100644 --- a/docs/understanding/data.rst +++ b/docs/understanding/data.rst @@ -39,7 +39,7 @@ step only contains information about the datagrabber used. The :ref:`Data Reader ` step adds the ``data`` second-level key which is the actual data loaded into memory. The ``meta`` key in this step -adds information about the datareader used to read the data. +adds information about the DataReader used to read the data. .. code-block:: python diff --git a/docs/understanding/datareader.rst b/docs/understanding/datareader.rst index 87b8c31a53..52679ebd12 100644 --- a/docs/understanding/datareader.rst +++ b/docs/understanding/datareader.rst @@ -14,7 +14,7 @@ files in junifer. It reads the value of the key ``path`` for each them into memory. After reading the data into memory, it adds the key ``data`` to the same level as ``path`` and the value is the actual data in the memory. -Datareaders are meant to be used inside the datagrabber context but you can +DataReaders are meant to be used inside the datagrabber context but you can operate on them outside the context as long as the actual data is in the memory and the Python runtime has not garbage-collected it. diff --git a/docs/using/codeless.rst b/docs/using/codeless.rst index f053209bab..0b3601793b 100644 --- a/docs/using/codeless.rst +++ b/docs/using/codeless.rst @@ -107,12 +107,12 @@ Data Reader ^^^^^^^^^^^ As mentioned before, this section is entirely optional, as junifer only provides -one data reader (:class:`.DefaultDataReader`), which is the default in case the +one DataReader (:class:`.DefaultDataReader`), which is the default in case the section is not specified. In any case, the syntax of the section is the same as for the ``datagrabber`` -section, using the ``kind`` key to specify the datareader to use, and additional -keys to pass parameters to the datareader: +section, using the ``kind`` key to specify the DataReader to use, and additional +keys to pass parameters to the DataReader constructor: .. code-block:: yaml diff --git a/junifer/api/decorators.py b/junifer/api/decorators.py index 87ea51f89e..28969d93e9 100644 --- a/junifer/api/decorators.py +++ b/junifer/api/decorators.py @@ -35,20 +35,24 @@ def register_datagrabber(klass: Type) -> Type: def register_datareader(klass: Type) -> Type: - """Datareader registration decorator. + """Register DataReader. - Registers the datareader so it can be used by name. + Registers the DataReader so it can be used by name. Parameters ---------- klass: class - The class of the datareader to register. + The class of the DataReader to register. Returns ------- klass: class The unmodified input class. + Notes + ----- + It should only be used as a decorator. + """ register( step="datareader", diff --git a/junifer/datareader/default.py b/junifer/datareader/default.py index 52352dec21..2956e3aecf 100644 --- a/junifer/datareader/default.py +++ b/junifer/datareader/default.py @@ -1,4 +1,4 @@ -"""Provide class for default data reader.""" +"""Provide concrete implementation for default DataReader.""" # Authors: Federico Raimondo # Synchon Mandal @@ -32,7 +32,7 @@ @register_datareader class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin): - """Mixin class for default data reader.""" + """Concrete implementation for common data reading.""" def validate_input(self, input: List[str]) -> List[str]: """Validate input. @@ -48,6 +48,7 @@ def validate_input(self, input: List[str]) -> List[str]: list of str The actual elements of the input that will be processed by this pipeline step. + """ # Nothing to validate, any input is fine return input diff --git a/junifer/datareader/tests/test_default_reader.py b/junifer/datareader/tests/test_default_reader.py index 46c31f8721..b815220140 100644 --- a/junifer/datareader/tests/test_default_reader.py +++ b/junifer/datareader/tests/test_default_reader.py @@ -1,4 +1,4 @@ -"""Provide tests for default data reader.""" +"""Provide tests for DefaultDataReader.""" # Authors: Federico Raimondo # Synchon Mandal @@ -19,8 +19,8 @@ @pytest.mark.parametrize( "type_", [["T1w", "BOLD", "T2", "dwi"], [], ["whatever"]] ) -def test_validation(type_) -> None: - """Test validating input/output. +def test_DefaultDataReader_validation(type_) -> None: + """Test DefaultDataReader validating input/output. Parameters ---------- @@ -34,8 +34,8 @@ def test_validation(type_) -> None: assert reader.validate(type_) == type_ -def test_meta() -> None: - """Test reader metadata.""" +def test_DefaultDataReader_meta() -> None: + """Test DefaultDataReader metadata.""" reader = DefaultDataReader() nib_data_path = Path(nib_testing.data_path) @@ -52,8 +52,8 @@ def test_meta() -> None: @pytest.mark.parametrize( "fname", ["example4d.nii.gz", "reoriented_anat_moved.nii"] ) -def test_read_nifti(fname: str) -> None: - """Test reading NIFTI files. +def test_DefaultDataReader_nifti(fname: str) -> None: + """Test DefaultDataReader reading NIfTI files. Parameters ---------- @@ -85,8 +85,8 @@ def test_read_nifti(fname: str) -> None: assert output["BOLD"]["path"] == output2["BOLD"]["path"] -def test_read_unknown() -> None: - """Test (not) reading unknown files.""" +def test_DefaultDataReader_unknown() -> None: + """Test DefaultDataReader (not) reading unknown files.""" reader = DefaultDataReader() nib_data_path = Path(nib_testing.data_path) @@ -115,8 +115,8 @@ def test_read_unknown() -> None: reader.fit_transform(input) -def test_read_csv(tmp_path: Path) -> None: - """Test reading CSV files. +def test_DefaultDataReader_csv(tmp_path: Path) -> None: + """Test DefaultDataReader reading CSV files. Parameters ---------- diff --git a/junifer/markers/collection.py b/junifer/markers/collection.py index d45c132595..0f97311fba 100644 --- a/junifer/markers/collection.py +++ b/junifer/markers/collection.py @@ -25,8 +25,8 @@ class MarkerCollection: ---------- markers : list of marker-like The markers to compute. - datareader : datareader-like, optional - The datareader to use (default None). + datareader : DataReader-like object, optional + The DataReader to use (default None). preprocessing : preprocessing-like, optional The preprocessing steps to apply. storage : storage-like, optional