junifer 0.0.8.dev349__py3-none-any.whl → 0.0.9.dev6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
junifer/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.0.8.dev349'
22
- __version_tuple__ = version_tuple = (0, 0, 8, 'dev349')
21
+ __version__ = version = '0.0.9.dev6'
22
+ __version_tuple__ = version_tuple = (0, 0, 9, 'dev6')
23
23
 
24
- __commit_id__ = commit_id = 'g2b4aae01d'
24
+ __commit_id__ = commit_id = 'g945cebd37'
junifer/api/functions.py CHANGED
@@ -21,6 +21,7 @@ from ..markers import BaseMarker
21
21
  from ..pipeline import (
22
22
  MarkerCollection,
23
23
  PipelineComponentRegistry,
24
+ PipelineStepMixin,
24
25
  WorkDirManager,
25
26
  )
26
27
  from ..preprocess import BasePreprocessor
@@ -70,6 +71,28 @@ def _get_datagrabber(datagrabber_config: dict) -> DataGrabberLike:
70
71
  )
71
72
 
72
73
 
74
+ def _get_datareader(datareader_config: dict) -> PipelineStepMixin:
75
+ """Get DataReader.
76
+
77
+ Parameters
78
+ ----------
79
+ datareader_config : dict
80
+ The config to get the DataReader using.
81
+
82
+ Returns
83
+ -------
84
+ object
85
+ The DataReader.
86
+
87
+ """
88
+ return PipelineComponentRegistry().build_component_instance(
89
+ step="datareader",
90
+ name=datareader_config.pop("kind"),
91
+ baseclass=PipelineStepMixin,
92
+ init_params=datareader_config,
93
+ )
94
+
95
+
73
96
  def _get_preprocessor(preprocessing_config: dict) -> PreprocessorLike:
74
97
  """Get Preprocessor.
75
98
 
@@ -182,6 +205,7 @@ def run(
182
205
  storage: dict,
183
206
  preprocessors: list[dict] | None = None,
184
207
  elements: Elements | None = None,
208
+ datareader: dict | None = None,
185
209
  ) -> None:
186
210
  """Run the pipeline on the selected element.
187
211
 
@@ -210,6 +234,11 @@ def run(
210
234
  elements : list or None, optional
211
235
  Element(s) to process. Will be used to index the DataGrabber
212
236
  (default None).
237
+ datareader : dict or None, optional
238
+ DataReader to use. Must have a key ``kind`` with the kind of
239
+ DataReader to use. All other keys are passed to the DataReader
240
+ constructor. If None, will use :class:`.DefaultDataReader`
241
+ (default None).
213
242
 
214
243
  Raises
215
244
  ------
@@ -249,9 +278,16 @@ def run(
249
278
  else:
250
279
  built_preprocessors = None
251
280
 
281
+ # Get datareader to use (if provided)
282
+ if datareader is not None:
283
+ datareader_object = _get_datareader(datareader.copy())
284
+ else:
285
+ datareader_object = None
286
+
252
287
  # Create new marker collection
253
288
  mc = MarkerCollection(
254
289
  markers=built_markers,
290
+ datareader=datareader_object,
255
291
  preprocessors=built_preprocessors,
256
292
  storage=storage_object,
257
293
  )
@@ -21,9 +21,10 @@ from ruamel.yaml import YAML
21
21
 
22
22
  import junifer.testing.registry # noqa: F401
23
23
  from junifer.api import collect, list_elements, parse_yaml, queue, reset, run
24
- from junifer.api.decorators import register_marker
24
+ from junifer.api.decorators import register_datareader, register_marker
25
25
  from junifer.datagrabber import DataType, PatternDataGrabber
26
26
  from junifer.datagrabber.base import BaseDataGrabber
27
+ from junifer.datareader import DefaultDataReader
27
28
  from junifer.markers import BaseMarker
28
29
  from junifer.pipeline import (
29
30
  MarkerCollection,
@@ -224,6 +225,52 @@ def test_run_single_element_with_preprocessing(
224
225
  assert len(files) == 1
225
226
 
226
227
 
228
+ def test_run_single_element_with_datareader(
229
+ tmp_path: Path,
230
+ markers: list[dict[str, str]],
231
+ storage: dict[str, str],
232
+ ) -> None:
233
+ """Test run function with single element and a DataReader.
234
+
235
+ Parameters
236
+ ----------
237
+ tmp_path : pathlib.Path
238
+ The path to the test directory.
239
+ markers : list of dict
240
+ Testing markers as list of dictionary.
241
+ storage : dict
242
+ Testing storage as dictionary.
243
+
244
+ """
245
+
246
+ @register_datareader
247
+ class CountingDataReader(DefaultDataReader):
248
+ """DataReader counting the elements it reads."""
249
+
250
+ n_read: ClassVar[int] = 0
251
+
252
+ def _fit_transform(self, input, params=None):
253
+ CountingDataReader.n_read += 1
254
+ return super()._fit_transform(input, params)
255
+
256
+ # Set storage
257
+ storage["uri"] = str((tmp_path / "out.hdf5").resolve())
258
+ # Run operations
259
+ run(
260
+ workdir=tmp_path,
261
+ datagrabber=_datagrabber.copy(),
262
+ markers=markers,
263
+ storage=storage,
264
+ elements=["sub-01"],
265
+ datareader={"kind": "CountingDataReader"},
266
+ )
267
+ # Check the DataReader was used
268
+ assert CountingDataReader.n_read == 1
269
+ # Check files
270
+ files = list(tmp_path.glob("*.hdf5"))
271
+ assert len(files) == 1
272
+
273
+
227
274
  @pytest.mark.parametrize(
228
275
  "element, expect",
229
276
  [
junifer/cli/cli.py CHANGED
@@ -193,6 +193,8 @@ def run(
193
193
  markers = config["markers"]
194
194
  # Fetch storage
195
195
  storage = config["storage"]
196
+ # Fetch datareader
197
+ datareader = config.get("datareader")
196
198
  # Fetch preprocessors
197
199
  preprocessors = config.get("preprocess")
198
200
  # Convert to list if single preprocessor
@@ -208,6 +210,7 @@ def run(
208
210
  storage=storage,
209
211
  preprocessors=preprocessors,
210
212
  elements=elements,
213
+ datareader=datareader,
211
214
  )
212
215
 
213
216
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: junifer
3
- Version: 0.0.8.dev349
3
+ Version: 0.0.9.dev6
4
4
  Summary: JUelich NeuroImaging FEature extractoR
5
5
  Author-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
6
6
  Maintainer-email: Fede Raimondo <f.raimondo@fz-juelich.de>, Synchon Mandal <s.mandal@fz-juelich.de>
@@ -1,13 +1,13 @@
1
1
  junifer/__init__.py,sha256=2McgH1yNue6Z1V26-uN_mfMjbTcx4CLhym-DMBl5xA4,266
2
2
  junifer/__init__.pyi,sha256=SsTvgq2Dod6UqJN96GH1lCphH6hJQQurEJHGNhHjGUI,508
3
- junifer/_version.py,sha256=913VI4mfcgL8gv1u73-Z9x0UsteJJKKCSifYKT9Cxlw,545
3
+ junifer/_version.py,sha256=mxTtW49B4vO_Y8j5kOe5ACVr91pjDNIjy8g8J52bupM,541
4
4
  junifer/conftest.py,sha256=zNA1SDU5MtF1Wp_6nbo1PRYtN4gsYjH1PTBFa_PfWLw,2856
5
5
  junifer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  junifer/stats.py,sha256=dOENKWWVjXq--OebL4pci_4UYEDKjxR_lWYvcus7OOc,6247
7
7
  junifer/api/__init__.py,sha256=aAXW_KAEGQ8aAP5Eni2G1R4MWBF7UgjKOgM6akLuJco,252
8
8
  junifer/api/__init__.pyi,sha256=weBgoe0MwCaSAmoDl-4sAaYxsshNFbSDAUYHi-CoE7o,255
9
9
  junifer/api/decorators.py,sha256=7yFhb63zRuyd9uyV_8e7gr4oD0yvZAC4So6CYlwm4tY,4723
10
- junifer/api/functions.py,sha256=Oxu4KNUZIOQWMtWUqAyjTtsnOjsVzH_39Gj1jTODu9M,21118
10
+ junifer/api/functions.py,sha256=6sLdXKWFYgOfQsGqNtK2lEmwuqoRY24MU2cXaQ7qCYg,22153
11
11
  junifer/api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  junifer/api/queue_context/__init__.py,sha256=glr8x4aMm4EvVrHywDIlugdNlwD1RzqV2FTDNPqYQZ4,204
13
13
  junifer/api/queue_context/__init__.pyi,sha256=L1snkn0qGyzxIM8_d5LNMrpYYu9ecC0favO334QqId4,391
@@ -41,10 +41,10 @@ junifer/api/res/fsl/img2imgcoord,sha256=Zmaw3oJYrEltcXiPyEubXry9ppAq3SND52tdDWGg
41
41
  junifer/api/res/fsl/run_fsl_docker.sh,sha256=cFkGz0Kx6pp9R3c0N-lgP703IbmN7LuCtrbuqAdgtd0,1293
42
42
  junifer/api/res/fsl/std2imgcoord,sha256=-X5wRH6XMl0yqnTACJX6MFhO8DFOEWg42MHRxGvimXg,49
43
43
  junifer/api/tests/test_decorators.py,sha256=2-ajsMWqXvGdHDnNU4ueSd5GcJ8ROIYOX8tFrJINbaI,2062
44
- junifer/api/tests/test_functions.py,sha256=2fxBQChqMYztiGCsoE4Jo04ol1LBs9qJthftYY3cOL8,45732
44
+ junifer/api/tests/test_functions.py,sha256=_8ymqJILPQ2YNrHhC5RpCUWpa3WC2aSC7UT5OepMFDQ,47046
45
45
  junifer/cli/__init__.py,sha256=L0gTMTtz8s09_adrqgJtufbwqTSfSYhh5MMPifrneQY,378
46
46
  junifer/cli/__init__.pyi,sha256=PiV4znUnzSeuSSJGz-RT8N21PiMqoSMwYcypi7nt2Js,40
47
- junifer/cli/cli.py,sha256=p_yC3jVqM-hmWL-Ik17f24gP8ofYhN9Bb7WOZ5gWbkA,16121
47
+ junifer/cli/cli.py,sha256=DNSK7eRpDMxGpBgDRX3rzqy3Ny26HF2sHcLuQiMrn64,16217
48
48
  junifer/cli/parser.py,sha256=kUGFxZzGJzGEv5Ws9og5eV6T08-Teza6nktGS6jKu4I,3704
49
49
  junifer/cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  junifer/cli/utils.py,sha256=Db_Q4XPR9bcfTeCkG59-eOKCqXv2lY2DF1NsDqtLcFs,3325
@@ -393,10 +393,10 @@ junifer/utils/tests/test_config.py,sha256=7ltIXuwb_W4Mv_1dxQWyiyM10XgUAfsWKV6D_i
393
393
  junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
394
394
  junifer/utils/tests/test_helpers.py,sha256=fJ3NfwR6QXB4RuZvFFo9v02_RXJjIQCFig8pLnT3sLQ,1803
395
395
  junifer/utils/tests/test_logging.py,sha256=kptAMU-N7r-Buu_H0JGKjGTsVKyjN3FwFelrRrbL4g0,2947
396
- junifer-0.0.8.dev349.dist-info/licenses/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
397
- junifer-0.0.8.dev349.dist-info/licenses/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
398
- junifer-0.0.8.dev349.dist-info/METADATA,sha256=_GCXc9O4PcED0iB6iATIlUx-qY8RDAsTd51tXaCwKas,9116
399
- junifer-0.0.8.dev349.dist-info/WHEEL,sha256=16fc_9Rp854SLcdhaDEjr0u65p0e3FhZxihNgcnCE98,91
400
- junifer-0.0.8.dev349.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
401
- junifer-0.0.8.dev349.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
402
- junifer-0.0.8.dev349.dist-info/RECORD,,
396
+ junifer-0.0.9.dev6.dist-info/licenses/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
397
+ junifer-0.0.9.dev6.dist-info/licenses/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
398
+ junifer-0.0.9.dev6.dist-info/METADATA,sha256=SO9mWZukleFFL2dzsXti1tk2mif9HQYww0USfFcpoK0,9114
399
+ junifer-0.0.9.dev6.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
400
+ junifer-0.0.9.dev6.dist-info/entry_points.txt,sha256=6O8ru0BP-SP7YMUZiizFNoaZ2HvJpadO2G7nKk4PwjI,48
401
+ junifer-0.0.9.dev6.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
402
+ junifer-0.0.9.dev6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.1.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5