junifer 0.0.5.dev93__py3-none-any.whl → 0.0.5.dev98__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 +2 -2
- junifer/datagrabber/pattern.py +17 -6
- junifer/datagrabber/tests/test_pattern.py +45 -0
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/METADATA +1 -1
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/RECORD +10 -10
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/AUTHORS.rst +0 -0
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/LICENSE.md +0 -0
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/WHEEL +0 -0
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/entry_points.txt +0 -0
- {junifer-0.0.5.dev93.dist-info → junifer-0.0.5.dev98.dist-info}/top_level.txt +0 -0
junifer/_version.py
CHANGED
@@ -12,5 +12,5 @@ __version__: str
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
13
13
|
version_tuple: VERSION_TUPLE
|
14
14
|
|
15
|
-
__version__ = version = '0.0.5.
|
16
|
-
__version_tuple__ = version_tuple = (0, 0, 5, '
|
15
|
+
__version__ = version = '0.0.5.dev98'
|
16
|
+
__version_tuple__ = version_tuple = (0, 0, 5, 'dev98')
|
junifer/datagrabber/pattern.py
CHANGED
@@ -214,18 +214,25 @@ class PatternDataGrabber(BaseDataGrabber):
|
|
214
214
|
t_replacements = [
|
215
215
|
x for x in self.replacements if f"{{{x}}}" in pattern
|
216
216
|
]
|
217
|
-
|
217
|
+
# Ops on re_pattern
|
218
|
+
# Remove negated unix glob pattern i.e., [!...] for re_pattern
|
219
|
+
re_pattern = re.sub(r"\[!.?\]", "", re_pattern)
|
220
|
+
# Remove enclosing square brackets from unix glob pattern i.e., [...]
|
221
|
+
# for re_pattern
|
222
|
+
re_pattern = re.sub(r"\[|\]", "", re_pattern)
|
223
|
+
# Iteratively replace the first of each with a named group definition
|
218
224
|
for t_r in t_replacements:
|
219
|
-
# Replace the first of each with a named group definition
|
220
225
|
re_pattern = re_pattern.replace(f"{{{t_r}}}", f"(?P<{t_r}>.*)", 1)
|
221
|
-
|
226
|
+
# Iteratively replace the second appearance of each with the named
|
227
|
+
# group back reference
|
222
228
|
for t_r in t_replacements:
|
223
|
-
# Replace the second appearance of each with the named group
|
224
|
-
# back reference
|
225
229
|
re_pattern = re_pattern.replace(f"{{{t_r}}}", f"(?P={t_r})")
|
226
|
-
|
230
|
+
# Ops on glob_pattern
|
231
|
+
# Iteratively replace replacements with wildcard i.e., *
|
232
|
+
# for glob_pattern
|
227
233
|
for t_r in t_replacements:
|
228
234
|
glob_pattern = glob_pattern.replace(f"{{{t_r}}}", "*")
|
235
|
+
|
229
236
|
return re_pattern, glob_pattern, t_replacements
|
230
237
|
|
231
238
|
def _replace_patterns_glob(self, element: Dict, pattern: str) -> str:
|
@@ -254,6 +261,10 @@ class PatternDataGrabber(BaseDataGrabber):
|
|
254
261
|
f"The element keys must be {self.replacements}, "
|
255
262
|
f"element has {list(element.keys())}."
|
256
263
|
)
|
264
|
+
# Remove negated unix glob pattern i.e., [!...]
|
265
|
+
pattern = re.sub(r"\[!.?\]", "", pattern)
|
266
|
+
# Remove enclosing square brackets from unix glob pattern i.e., [...]
|
267
|
+
pattern = re.sub(r"\[|\]", "", pattern)
|
257
268
|
return pattern.format(**element)
|
258
269
|
|
259
270
|
def _get_path_from_patterns(
|
@@ -236,6 +236,51 @@ def test_PatternDataGrabber(tmp_path: Path) -> None:
|
|
236
236
|
assert out1["VBM_GM"]["path"] != out2["VBM_GM"]["path"]
|
237
237
|
|
238
238
|
|
239
|
+
def test_PatternDataGrabber_unix_path_expansion(tmp_path: Path) -> None:
|
240
|
+
"""Test PatterDataGrabber for patterns with unix path expansion.
|
241
|
+
|
242
|
+
Parameters
|
243
|
+
----------
|
244
|
+
tmp_path : pathlib.Path
|
245
|
+
The path to the test directory.
|
246
|
+
|
247
|
+
"""
|
248
|
+
# Create test data root dir
|
249
|
+
freesurfer_dir = tmp_path / "derivatives" / "freesurfer"
|
250
|
+
freesurfer_dir.mkdir(parents=True, exist_ok=True)
|
251
|
+
# Create test data sub dirs and files
|
252
|
+
for dir_name in ["fsaverage", "sub-0001"]:
|
253
|
+
mri_dir = freesurfer_dir / dir_name / "mri"
|
254
|
+
mri_dir.mkdir(parents=True, exist_ok=True)
|
255
|
+
# Create files
|
256
|
+
(mri_dir / "T1.mgz").touch(exist_ok=True)
|
257
|
+
(mri_dir / "aseg.mgz").touch(exist_ok=True)
|
258
|
+
# Create datagrabber
|
259
|
+
dg = PatternDataGrabber(
|
260
|
+
datadir=tmp_path,
|
261
|
+
types=["FreeSurfer"],
|
262
|
+
patterns={
|
263
|
+
"FreeSurfer": {
|
264
|
+
"pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
|
265
|
+
"aseg": {
|
266
|
+
"pattern": (
|
267
|
+
"derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
|
268
|
+
)
|
269
|
+
},
|
270
|
+
},
|
271
|
+
},
|
272
|
+
replacements=["subject"],
|
273
|
+
)
|
274
|
+
# Check that "fsaverage" is filtered
|
275
|
+
elements = dg.get_elements()
|
276
|
+
assert elements == ["sub-0001"]
|
277
|
+
# Fetch data
|
278
|
+
out = dg["sub-0001"]
|
279
|
+
# Check paths are found
|
280
|
+
assert set(out["FreeSurfer"].keys()) == {"path", "aseg", "meta"}
|
281
|
+
assert list(out["FreeSurfer"]["aseg"].keys()) == ["path"]
|
282
|
+
|
283
|
+
|
239
284
|
def test_PatternDataGrabber_confounds_format_error_on_init() -> None:
|
240
285
|
"""Test PatterDataGrabber confounds format error on initialisation."""
|
241
286
|
with pytest.raises(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: junifer
|
3
|
-
Version: 0.0.5.
|
3
|
+
Version: 0.0.5.dev98
|
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,5 +1,5 @@
|
|
1
1
|
junifer/__init__.py,sha256=x1UR2jUcrUdm2HNl-3Qvyi4UUrU6ms5qm2qcmNY7zZk,391
|
2
|
-
junifer/_version.py,sha256=
|
2
|
+
junifer/_version.py,sha256=41cHsK1eRPpQ9ajnDhEe8UsfX7jGdL3It4yHcQyql1w,426
|
3
3
|
junifer/stats.py,sha256=jN22_qFvWYBU9ZIMnCSzN4iOscWnWrcrUPIdLeDkV64,6163
|
4
4
|
junifer/api/__init__.py,sha256=pSj8V8tmwOAQ3sshWJfRfB-n3z5bcJj3pHOBX4-8ONc,251
|
5
5
|
junifer/api/cli.py,sha256=53pews3mXkJ7DUDSkV51PbitYnuVAdQRkWG-gjO08Uw,16142
|
@@ -94,7 +94,7 @@ junifer/datagrabber/base.py,sha256=KgMSKfkwd4yLW4PhoJDoWMgcDkGmDoIs6jkgKyOJd9A,6
|
|
94
94
|
junifer/datagrabber/datalad_base.py,sha256=gP-DsyCd2F8W-aF2PXOg99Ntp2bj8QEtb535y06q39o,11009
|
95
95
|
junifer/datagrabber/dmcc13_benchmark.py,sha256=se9F6QVw9WX22MNld33OQv_BtdW-yPvXXu6kYykxLNw,12225
|
96
96
|
junifer/datagrabber/multiple.py,sha256=eXQIsvSNvD8GuEITjMaMoi1GwoeyWXXbQMRi-f2qgc4,4923
|
97
|
-
junifer/datagrabber/pattern.py,sha256=
|
97
|
+
junifer/datagrabber/pattern.py,sha256=4OcGSCwBpeQOj6_YZohJjRFC_L69y7MAKsoE4-XO2So,15949
|
98
98
|
junifer/datagrabber/pattern_datalad.py,sha256=R3LMeknT7tAXs2AN0XVPRf6tGkCMPgDfkNT2bfi7UNc,4526
|
99
99
|
junifer/datagrabber/utils.py,sha256=s0Ife1qKEwXP47GfoxQ0qGqSP8L8ZNAms3HAvrSFoGI,9406
|
100
100
|
junifer/datagrabber/aomic/__init__.py,sha256=R7yrRVBWsBW25CH0fw-KHpFwb_EC-MlPKDzssGfj5A0,281
|
@@ -113,7 +113,7 @@ junifer/datagrabber/tests/test_datagrabber_utils.py,sha256=x1nqFiHI9xHBQFwXji0DP
|
|
113
113
|
junifer/datagrabber/tests/test_datalad_base.py,sha256=SYxUB9_4YPMfrb7iJM-aJCWbGa3EJfYz31wAUCNa03s,16285
|
114
114
|
junifer/datagrabber/tests/test_dmcc13_benchmark.py,sha256=DcqkDXXBoabHFVbxekGR2NZyGeugGlxpOwXIwy38Ofg,9109
|
115
115
|
junifer/datagrabber/tests/test_multiple.py,sha256=Mx3xfDrQiWG2W5MW24P5L2XiSeALpJ2-jFlzWkKtu9w,5659
|
116
|
-
junifer/datagrabber/tests/test_pattern.py,sha256=
|
116
|
+
junifer/datagrabber/tests/test_pattern.py,sha256=H55jYRPfT3rMsoIQOAnWJgw3nGrkU7m2xFa3-ed6NQE,9527
|
117
117
|
junifer/datagrabber/tests/test_pattern_datalad.py,sha256=hxw_aXBwHjUo-aUrHescBA2dn1bSJxh-0oV8495iIEA,6483
|
118
118
|
junifer/datareader/__init__.py,sha256=_vtrLX_vxlHFD90gPa3gWnhTuvfWM7Uzyj6y8ZPaWm8,259
|
119
119
|
junifer/datareader/default.py,sha256=_ntvkcF0H089bHwj0VOLTKWp8RvP7qy2HyieWHuRp2c,6680
|
@@ -253,10 +253,10 @@ junifer/utils/logging.py,sha256=furcU3XIUpUvnpe4PEwzWWIWgmH4j2ZA4MQdvSGWjj0,9216
|
|
253
253
|
junifer/utils/tests/test_fs.py,sha256=WQS7cKlKEZ742CIuiOYYpueeAhY9PqlastfDVpVVtvE,923
|
254
254
|
junifer/utils/tests/test_helpers.py,sha256=k5qqfxK8dFyuewTJyR1Qn6-nFaYNuVr0ysc18bfPjyU,929
|
255
255
|
junifer/utils/tests/test_logging.py,sha256=l8oo-AiBV7H6_IzlsNcj__cLeZBUvgIGoaMszD9VaJg,7754
|
256
|
-
junifer-0.0.5.
|
257
|
-
junifer-0.0.5.
|
258
|
-
junifer-0.0.5.
|
259
|
-
junifer-0.0.5.
|
260
|
-
junifer-0.0.5.
|
261
|
-
junifer-0.0.5.
|
262
|
-
junifer-0.0.5.
|
256
|
+
junifer-0.0.5.dev98.dist-info/AUTHORS.rst,sha256=rmULKpchpSol4ExWFdm-qu4fkpSZPYqIESVJBZtGb6E,163
|
257
|
+
junifer-0.0.5.dev98.dist-info/LICENSE.md,sha256=MqCnOBu8uXsEOzRZWh9EBVfVz-kE9NkXcLCrtGXo2yU,34354
|
258
|
+
junifer-0.0.5.dev98.dist-info/METADATA,sha256=bhP82n2v_xWS0SXTrwNePMWFS8onrdxujcj-0DGXtIk,8234
|
259
|
+
junifer-0.0.5.dev98.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
260
|
+
junifer-0.0.5.dev98.dist-info/entry_points.txt,sha256=DxFvKq0pOqRunAK0FxwJcoDfV1-dZvsFDpD5HRqSDhw,48
|
261
|
+
junifer-0.0.5.dev98.dist-info/top_level.txt,sha256=4bAq1R2QFQ4b3hohjys2JBvxrl0GKk5LNFzYvz9VGcA,8
|
262
|
+
junifer-0.0.5.dev98.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|