[ENH]: Add support for FreeSurfer data type #346
14 changed files with 391 additions and 314 deletions
1
docs/changes/newsfragments/346.enh
Normal file
1
docs/changes/newsfragments/346.enh
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Adapt :class:`.DataladAOMICID1000`, :class:`.DataladAOMICPIOP1` and :class:`.DataladAOMICPIOP2` to support ``FreeSurfer`` data type by `Synchon Mandal`_
|
||||||
1
docs/changes/newsfragments/346.feature
Normal file
1
docs/changes/newsfragments/346.feature
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add support for ``FreeSurfer`` data type for :class:`.PatternDataGrabber` by `Synchon Mandal`_
|
||||||
|
|
@ -115,6 +115,9 @@ Data Types
|
||||||
* - ``VBM_WM``
|
* - ``VBM_WM``
|
||||||
- VBM White Matter segmentation (3D)
|
- VBM White Matter segmentation (3D)
|
||||||
- CAT output (`m0wp2` images)
|
- CAT output (`m0wp2` images)
|
||||||
|
* - ``VBM_CSF``
|
||||||
|
- VBM Central Spinal Fluid segmentation (3D)
|
||||||
|
- CAT output (`m0wp3` images)
|
||||||
* - ``fALFF``
|
* - ``fALFF``
|
||||||
- Voxel-wise fALFF image (3D)
|
- Voxel-wise fALFF image (3D)
|
||||||
- fALFF computed with CONN toolbox
|
- fALFF computed with CONN toolbox
|
||||||
|
|
@ -124,3 +127,9 @@ Data Types
|
||||||
* - ``LCOR``
|
* - ``LCOR``
|
||||||
- Local Correlation image (3D)
|
- Local Correlation image (3D)
|
||||||
- LCOR computed with CONN toolbox
|
- LCOR computed with CONN toolbox
|
||||||
|
* - ``DWI``
|
||||||
|
- Diffusion-weighted image (3D)
|
||||||
|
- Diffusion-weighted image (FSL or MRtrix output)
|
||||||
|
* - ``FreeSurfer``
|
||||||
|
- T1 image (3D)
|
||||||
|
- T1 image computed by FreeSurfer
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
||||||
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).
|
||||||
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
|
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
|
||||||
list of the options, optional
|
"FreeSurfer"} or list of the options, optional
|
||||||
AOMIC data types. If None, all available data types are selected.
|
AOMIC data types. If None, all available data types are selected.
|
||||||
(default None).
|
(default None).
|
||||||
native_t1w : bool, optional
|
native_t1w : bool, optional
|
||||||
|
|
@ -112,6 +112,39 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
||||||
"{subject}_desc-preproc_dwi.nii.gz"
|
"{subject}_desc-preproc_dwi.nii.gz"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
"FreeSurfer": {
|
||||||
|
"pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
|
||||||
|
"aseg": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"norm": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
# Use native T1w assets
|
# Use native T1w assets
|
||||||
self.native_t1w = False
|
self.native_t1w = False
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
||||||
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).
|
||||||
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
|
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
|
||||||
list of the options, optional
|
"FreeSurfer"} or list of the options, optional
|
||||||
AOMIC data types. If None, all available data types are selected.
|
AOMIC data types. If None, all available data types are selected.
|
||||||
(default None).
|
(default None).
|
||||||
tasks : {"restingstate", "anticipation", "emomatching", "faces", \
|
tasks : {"restingstate", "anticipation", "emomatching", "faces", \
|
||||||
|
|
@ -147,6 +147,39 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
||||||
"{subject}_desc-preproc_dwi.nii.gz"
|
"{subject}_desc-preproc_dwi.nii.gz"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
"FreeSurfer": {
|
||||||
|
"pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
|
||||||
|
"aseg": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"norm": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
# Use native T1w assets
|
# Use native T1w assets
|
||||||
self.native_t1w = False
|
self.native_t1w = False
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
||||||
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).
|
||||||
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \
|
types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \
|
||||||
list of the options, optional
|
"FreeSurfer"} or list of the options, optional
|
||||||
AOMIC data types. If None, all available data types are selected.
|
AOMIC data types. If None, all available data types are selected.
|
||||||
(default None).
|
(default None).
|
||||||
tasks : {"restingstate", "stopsignal", "workingmemory"} or \
|
tasks : {"restingstate", "stopsignal", "workingmemory"} or \
|
||||||
|
|
@ -144,6 +144,39 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
||||||
"{subject}_desc-preproc_dwi.nii.gz"
|
"{subject}_desc-preproc_dwi.nii.gz"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
"FreeSurfer": {
|
||||||
|
"pattern": "derivatives/freesurfer/[!f]{subject}/mri/T1.mg[z]",
|
||||||
|
"aseg": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/aseg.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"norm": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/mri/norm.mg[z]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_white": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.whit[e]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"lh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/lh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
"rh_pial": {
|
||||||
|
"pattern": (
|
||||||
|
"derivatives/freesurfer/[!f]{subject}/surf/rh.pia[l]"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
# Use native T1w assets
|
# Use native T1w assets
|
||||||
self.native_t1w = False
|
self.native_t1w = False
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# Synchon Mandal <s.mandal@fz-juelich.de>
|
# Synchon Mandal <s.mandal@fz-juelich.de>
|
||||||
# License: AGPL
|
# License: AGPL
|
||||||
|
|
||||||
from typing import List, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -17,112 +17,58 @@ from junifer.datagrabber.aomic.id1000 import DataladAOMICID1000
|
||||||
URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000"
|
URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000"
|
||||||
|
|
||||||
|
|
||||||
def test_DataladAOMICID1000() -> None:
|
@pytest.mark.parametrize(
|
||||||
"""Test DataladAOMICID1000 DataGrabber."""
|
"type_, nested_types",
|
||||||
dg = DataladAOMICID1000()
|
[
|
||||||
|
("BOLD", ["confounds", "mask"]),
|
||||||
|
("T1w", ["mask"]),
|
||||||
|
("VBM_CSF", None),
|
||||||
|
("VBM_GM", None),
|
||||||
|
("VBM_WM", None),
|
||||||
|
("DWI", None),
|
||||||
|
("FreeSurfer", None),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_DataladAOMICID1000(
|
||||||
|
type_: str,
|
||||||
|
nested_types: Optional[List[str]],
|
||||||
|
) -> None:
|
||||||
|
"""Test DataladAOMICID1000 DataGrabber.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
type_ : str
|
||||||
|
The parametrized type.
|
||||||
|
nested_types : list of str or None
|
||||||
|
The parametrized nested types.
|
||||||
|
|
||||||
|
"""
|
||||||
|
dg = DataladAOMICID1000(types=type_)
|
||||||
# Set URI to Gin
|
# Set URI to Gin
|
||||||
dg.uri = URI
|
dg.uri = URI
|
||||||
|
|
||||||
with dg:
|
with dg:
|
||||||
|
# Get all elements
|
||||||
all_elements = dg.get_elements()
|
all_elements = dg.get_elements()
|
||||||
|
# Get test element
|
||||||
test_element = all_elements[0]
|
test_element = all_elements[0]
|
||||||
|
# Get test element data
|
||||||
out = dg[test_element]
|
out = dg[test_element]
|
||||||
|
# Assert data type
|
||||||
# asserts type "BOLD"
|
assert type_ in out
|
||||||
assert "BOLD" in out
|
assert out[type_]["path"].exists()
|
||||||
|
assert out[type_]["path"].is_file()
|
||||||
assert (
|
# Asserts data type metadata
|
||||||
out["BOLD"]["path"].name == f"{test_element}_task-moviewatching_"
|
assert "meta" in out[type_]
|
||||||
"space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
meta = out[type_]["meta"]
|
||||||
)
|
|
||||||
|
|
||||||
assert out["BOLD"]["path"].exists()
|
|
||||||
assert out["BOLD"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type BOLD.confounds
|
|
||||||
assert "confounds" in out["BOLD"]
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["BOLD"]["confounds"]["path"].name
|
|
||||||
== f"{test_element}_task-moviewatching_"
|
|
||||||
"desc-confounds_regressors.tsv"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["BOLD"]["confounds"]["path"].exists()
|
|
||||||
assert out["BOLD"]["confounds"]["path"].is_file()
|
|
||||||
|
|
||||||
# assert BOLD.mask
|
|
||||||
assert out["BOLD"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "T1w"
|
|
||||||
assert "T1w" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["T1w"]["path"].name
|
|
||||||
== f"{test_element}_space-MNI152NLin2009cAsym_"
|
|
||||||
"desc-preproc_T1w.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["T1w"]["path"].exists()
|
|
||||||
assert out["T1w"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts T1w.mask
|
|
||||||
assert out["T1w"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "VBM_CSF"
|
|
||||||
assert "VBM_CSF" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_CSF"]["path"].name
|
|
||||||
== f"{test_element}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"CSF_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_CSF"]["path"].exists()
|
|
||||||
assert out["VBM_CSF"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_GM"
|
|
||||||
assert "VBM_GM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_GM"]["path"].name
|
|
||||||
== f"{test_element}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"GM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_GM"]["path"].exists()
|
|
||||||
assert out["VBM_GM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_WM"
|
|
||||||
assert "VBM_WM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_WM"]["path"].name
|
|
||||||
== f"{test_element}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"WM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_WM"]["path"].exists()
|
|
||||||
assert out["VBM_WM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "DWI"
|
|
||||||
assert "DWI" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["DWI"]["path"].name
|
|
||||||
== f"{test_element}_desc-preproc_dwi.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["DWI"]["path"].exists()
|
|
||||||
assert out["DWI"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts meta
|
|
||||||
assert "meta" in out["BOLD"]
|
|
||||||
meta = out["BOLD"]["meta"]
|
|
||||||
assert "element" in meta
|
assert "element" in meta
|
||||||
assert "subject" in meta["element"]
|
assert "subject" in meta["element"]
|
||||||
assert test_element == meta["element"]["subject"]
|
assert test_element == meta["element"]["subject"]
|
||||||
|
# Assert nested data type if not None
|
||||||
|
if nested_types is not None:
|
||||||
|
for nested_type in nested_types:
|
||||||
|
assert out[type_][nested_type]["path"].exists()
|
||||||
|
assert out[type_][nested_type]["path"].is_file()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
||||||
|
|
@ -18,129 +18,87 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tasks",
|
"type_, nested_types, tasks",
|
||||||
[None, "restingstate"],
|
[
|
||||||
|
("BOLD", ["confounds", "mask"], None),
|
||||||
|
("BOLD", ["confounds", "mask"], ["anticipation"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["emomatching", "faces"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["restingstate"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["workingmemory", "gstroop"]),
|
||||||
|
(
|
||||||
|
"BOLD",
|
||||||
|
["confounds", "mask"],
|
||||||
|
["anticipation", "faces", "restingstate"],
|
||||||
|
),
|
||||||
|
("T1w", ["mask"], None),
|
||||||
|
("VBM_CSF", None, None),
|
||||||
|
("VBM_GM", None, None),
|
||||||
|
("VBM_WM", None, None),
|
||||||
|
("DWI", None, None),
|
||||||
|
("FreeSurfer", None, None),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
def test_DataladAOMICPIOP1(tasks: Optional[str]) -> None:
|
def test_DataladAOMICPIOP1(
|
||||||
|
type_: str,
|
||||||
|
nested_types: Optional[List[str]],
|
||||||
|
tasks: Optional[List[str]],
|
||||||
|
) -> None:
|
||||||
"""Test DataladAOMICPIOP1 DataGrabber.
|
"""Test DataladAOMICPIOP1 DataGrabber.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
tasks : str or None
|
type_ : str
|
||||||
|
The parametrized type.
|
||||||
|
nested_types : list of str or None
|
||||||
|
The parametrized nested types.
|
||||||
|
tasks : list of str or None
|
||||||
The parametrized task values.
|
The parametrized task values.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dg = DataladAOMICPIOP1(tasks=tasks)
|
dg = DataladAOMICPIOP1(types=type_, tasks=tasks)
|
||||||
# Set URI to Gin
|
# Set URI to Gin
|
||||||
dg.uri = URI
|
dg.uri = URI
|
||||||
|
|
||||||
with dg:
|
with dg:
|
||||||
|
# Get all elements
|
||||||
all_elements = dg.get_elements()
|
all_elements = dg.get_elements()
|
||||||
|
# Get test element
|
||||||
test_element = all_elements[0]
|
test_element = all_elements[0]
|
||||||
sub, task = test_element
|
# Get test element data
|
||||||
|
|
||||||
out = dg[test_element]
|
out = dg[test_element]
|
||||||
|
# Get all elements
|
||||||
# asserts type "BOLD"
|
all_elements = dg.get_elements()
|
||||||
assert "BOLD" in out
|
# Get test element
|
||||||
|
test_element = all_elements[0]
|
||||||
# depending on task 'acquisition is different'
|
# Get test element data
|
||||||
task_acqs = {
|
out = dg[test_element]
|
||||||
"anticipation": "seq",
|
# Assert data type
|
||||||
"emomatching": "seq",
|
assert type_ in out
|
||||||
"faces": "mb3",
|
# Check task name if BOLD
|
||||||
"gstroop": "seq",
|
if type_ == "BOLD" and tasks is not None:
|
||||||
"restingstate": "mb3",
|
# Depending on task 'acquisition is different'
|
||||||
"workingmemory": "seq",
|
task_acqs = {
|
||||||
}
|
"anticipation": "seq",
|
||||||
acq = task_acqs[task]
|
"emomatching": "seq",
|
||||||
new_task = f"{task}_acq-{acq}"
|
"faces": "mb3",
|
||||||
assert (
|
"gstroop": "seq",
|
||||||
out["BOLD"]["path"].name == f"{sub}_task-{new_task}_"
|
"restingstate": "mb3",
|
||||||
"space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
"workingmemory": "seq",
|
||||||
)
|
}
|
||||||
|
assert task_acqs[test_element[1]] in out[type_]["path"].name
|
||||||
assert out["BOLD"]["path"].exists()
|
assert out[type_]["path"].exists()
|
||||||
assert out["BOLD"]["path"].is_file()
|
assert out[type_]["path"].is_file()
|
||||||
|
# Asserts data type metadata
|
||||||
# asserts type BOLD.confounds
|
assert "meta" in out[type_]
|
||||||
assert "confounds" in out["BOLD"]
|
meta = out[type_]["meta"]
|
||||||
|
|
||||||
assert (
|
|
||||||
out["BOLD"]["confounds"]["path"].name == f"{sub}_task-{new_task}_"
|
|
||||||
"desc-confounds_regressors.tsv"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["BOLD"]["confounds"]["path"].exists()
|
|
||||||
assert out["BOLD"]["confounds"]["path"].is_file()
|
|
||||||
|
|
||||||
# assert BOLD.mask
|
|
||||||
assert out["BOLD"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "T1w"
|
|
||||||
assert "T1w" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["T1w"]["path"].name == f"{sub}_space-MNI152NLin2009cAsym_"
|
|
||||||
"desc-preproc_T1w.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["T1w"]["path"].exists()
|
|
||||||
assert out["T1w"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts T1w.mask
|
|
||||||
assert out["T1w"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "VBM_CSF"
|
|
||||||
assert "VBM_CSF" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_CSF"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"CSF_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_CSF"]["path"].exists()
|
|
||||||
assert out["VBM_CSF"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_GM"
|
|
||||||
assert "VBM_GM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_GM"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"GM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_GM"]["path"].exists()
|
|
||||||
assert out["VBM_GM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_WM"
|
|
||||||
assert "VBM_WM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_WM"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"WM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_WM"]["path"].exists()
|
|
||||||
assert out["VBM_WM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "DWI"
|
|
||||||
assert "DWI" in out
|
|
||||||
|
|
||||||
assert out["DWI"]["path"].name == f"{sub}_desc-preproc_dwi.nii.gz"
|
|
||||||
|
|
||||||
assert out["DWI"]["path"].exists()
|
|
||||||
assert out["DWI"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts meta
|
|
||||||
assert "meta" in out["BOLD"]
|
|
||||||
meta = out["BOLD"]["meta"]
|
|
||||||
assert "element" in meta
|
assert "element" in meta
|
||||||
assert "subject" in meta["element"]
|
assert "subject" in meta["element"]
|
||||||
assert sub == meta["element"]["subject"]
|
assert test_element[0] == meta["element"]["subject"]
|
||||||
|
# Assert nested data type if not None
|
||||||
|
if nested_types is not None:
|
||||||
|
for nested_type in nested_types:
|
||||||
|
assert out[type_][nested_type]["path"].exists()
|
||||||
|
assert out[type_][nested_type]["path"].is_file()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
||||||
|
|
@ -18,123 +18,67 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop2"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tasks",
|
"type_, nested_types, tasks",
|
||||||
[None, "restingstate"],
|
[
|
||||||
|
("BOLD", ["confounds", "mask"], None),
|
||||||
|
("BOLD", ["confounds", "mask"], ["restingstate"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["restingstate", "stopsignal"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["workingmemory", "stopsignal"]),
|
||||||
|
("BOLD", ["confounds", "mask"], ["workingmemory"]),
|
||||||
|
("T1w", ["mask"], None),
|
||||||
|
("VBM_CSF", None, None),
|
||||||
|
("VBM_GM", None, None),
|
||||||
|
("VBM_WM", None, None),
|
||||||
|
("DWI", None, None),
|
||||||
|
("FreeSurfer", None, None),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
def test_DataladAOMICPIOP2(tasks: Optional[str]) -> None:
|
def test_DataladAOMICPIOP2(
|
||||||
|
type_: str,
|
||||||
|
nested_types: Optional[List[str]],
|
||||||
|
tasks: Optional[List[str]],
|
||||||
|
) -> None:
|
||||||
"""Test DataladAOMICPIOP2 DataGrabber.
|
"""Test DataladAOMICPIOP2 DataGrabber.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
tasks : str or None
|
type_ : str
|
||||||
|
The parametrized type.
|
||||||
|
nested_types : list of str or None
|
||||||
|
The parametrized nested types.
|
||||||
|
tasks : list of str or None
|
||||||
The parametrized task values.
|
The parametrized task values.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dg = DataladAOMICPIOP2(tasks=tasks)
|
dg = DataladAOMICPIOP2(types=type_, tasks=tasks)
|
||||||
# Set URI to Gin
|
# Set URI to Gin
|
||||||
dg.uri = URI
|
dg.uri = URI
|
||||||
|
|
||||||
with dg:
|
with dg:
|
||||||
|
# Get all elements
|
||||||
all_elements = dg.get_elements()
|
all_elements = dg.get_elements()
|
||||||
|
# Get test element
|
||||||
if tasks == "restingstate":
|
|
||||||
for el in all_elements:
|
|
||||||
assert el[1] == "restingstate"
|
|
||||||
|
|
||||||
test_element = all_elements[0]
|
test_element = all_elements[0]
|
||||||
sub, task = test_element
|
# Get test element data
|
||||||
out = dg[test_element]
|
out = dg[test_element]
|
||||||
|
# Assert data type
|
||||||
# asserts type "BOLD"
|
assert type_ in out
|
||||||
assert "BOLD" in out
|
# Check task name if BOLD
|
||||||
|
if type_ == "BOLD" and tasks is not None:
|
||||||
new_task = f"{task}_acq-seq"
|
assert test_element[1] in out[type_]["path"].name
|
||||||
assert (
|
assert out[type_]["path"].exists()
|
||||||
out["BOLD"]["path"].name == f"{sub}_task-{new_task}_"
|
assert out[type_]["path"].is_file()
|
||||||
"space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
# Asserts data type metadata
|
||||||
)
|
assert "meta" in out[type_]
|
||||||
|
meta = out[type_]["meta"]
|
||||||
assert out["BOLD"]["path"].exists()
|
|
||||||
assert out["BOLD"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type BOLD.confounds
|
|
||||||
assert "confounds" in out["BOLD"]
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["BOLD"]["confounds"]["path"].name == f"{sub}_task-{new_task}_"
|
|
||||||
"desc-confounds_regressors.tsv"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["BOLD"]["confounds"]["path"].exists()
|
|
||||||
assert out["BOLD"]["confounds"]["path"].is_file()
|
|
||||||
|
|
||||||
# assert BOLD.mask
|
|
||||||
assert out["BOLD"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "T1w"
|
|
||||||
assert "T1w" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["T1w"]["path"].name == f"{sub}_space-MNI152NLin2009cAsym_"
|
|
||||||
"desc-preproc_T1w.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["T1w"]["path"].exists()
|
|
||||||
assert out["T1w"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts T1w.mask
|
|
||||||
assert out["T1w"]["mask"]["path"].exists()
|
|
||||||
|
|
||||||
# asserts type "VBM_CSF"
|
|
||||||
assert "VBM_CSF" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_CSF"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"CSF_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_CSF"]["path"].exists()
|
|
||||||
assert out["VBM_CSF"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_GM"
|
|
||||||
assert "VBM_GM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_GM"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"GM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_GM"]["path"].exists()
|
|
||||||
assert out["VBM_GM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "VBM_WM"
|
|
||||||
assert "VBM_WM" in out
|
|
||||||
|
|
||||||
assert (
|
|
||||||
out["VBM_WM"]["path"].name
|
|
||||||
== f"{sub}_space-MNI152NLin2009cAsym_label-"
|
|
||||||
"WM_probseg.nii.gz"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert out["VBM_WM"]["path"].exists()
|
|
||||||
assert out["VBM_WM"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts type "DWI"
|
|
||||||
assert "DWI" in out
|
|
||||||
|
|
||||||
assert out["DWI"]["path"].name == f"{sub}_desc-preproc_dwi.nii.gz"
|
|
||||||
|
|
||||||
assert out["DWI"]["path"].exists()
|
|
||||||
assert out["DWI"]["path"].is_file()
|
|
||||||
|
|
||||||
# asserts meta
|
|
||||||
assert "meta" in out["BOLD"]
|
|
||||||
meta = out["BOLD"]["meta"]
|
|
||||||
assert "element" in meta
|
assert "element" in meta
|
||||||
assert "subject" in meta["element"]
|
assert "subject" in meta["element"]
|
||||||
assert sub == meta["element"]["subject"]
|
assert test_element[0] == meta["element"]["subject"]
|
||||||
|
# Assert nested data type if not None
|
||||||
|
if nested_types is not None:
|
||||||
|
for nested_type in nested_types:
|
||||||
|
assert out[type_][nested_type]["path"].exists()
|
||||||
|
assert out[type_][nested_type]["path"].is_file()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,17 @@ PATTERNS_SCHEMA = {
|
||||||
"mandatory": ["pattern"],
|
"mandatory": ["pattern"],
|
||||||
"optional": {},
|
"optional": {},
|
||||||
},
|
},
|
||||||
|
"FreeSurfer": {
|
||||||
|
"mandatory": ["pattern"],
|
||||||
|
"optional": {
|
||||||
|
"aseg": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
"norm": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
"lh_white": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
"rh_white": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
"lh_pial": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
"rh_pial": {"mandatory": ["pattern"], "optional": []},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,8 @@ class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin):
|
||||||
params = {}
|
params = {}
|
||||||
# For each type of data, try to read it
|
# For each type of data, try to read it
|
||||||
for type_key, type_val in input.items():
|
for type_key, type_val in input.items():
|
||||||
# Skip Warp data type
|
# Skip Warp and FreeSurfer data type
|
||||||
if type_key == "Warp":
|
if type_key in ["Warp", "FreeSurfer"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check for malformed datagrabber specification
|
# Check for malformed datagrabber specification
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
base_dir = tmpdir / "derivatives"
|
base_dir = tmpdir / "derivatives"
|
||||||
base_dir.mkdir(exist_ok=True, parents=True)
|
base_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
for dtype in ["dwipreproc", "fmriprep"]:
|
for dtype in ["dwipreproc", "fmriprep", "freesurfer"]:
|
||||||
dtype_dir = base_dir / dtype
|
dtype_dir = base_dir / dtype
|
||||||
dtype_dir.mkdir()
|
dtype_dir.mkdir()
|
||||||
|
|
||||||
|
|
@ -88,10 +88,46 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
elif dtype == "freesurfer":
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(sub_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
with open(sub_dir / fname, "w") as f:
|
with open(sub_dir / fname, "w") as f:
|
||||||
f.write("placeholder")
|
f.write("placeholder")
|
||||||
|
|
||||||
|
if dtype == "freesurfer":
|
||||||
|
for extra in ["fsaverage", "fsaverage5"]:
|
||||||
|
extra_dir = dtype_dir / extra
|
||||||
|
extra_dir.mkdir()
|
||||||
|
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(extra_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for fname in fnames:
|
||||||
|
with open(extra_dir / fname, "w") as f:
|
||||||
|
f.write("placeholder")
|
||||||
|
|
||||||
ds.save(recursive=True)
|
ds.save(recursive=True)
|
||||||
# use this to create the repo automatically, only possible for juaml owner
|
# use this to create the repo automatically, only possible for juaml owner
|
||||||
# ds.create_sibling_gin(
|
# ds.create_sibling_gin(
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
base_dir = tmpdir / "derivatives"
|
base_dir = tmpdir / "derivatives"
|
||||||
base_dir.mkdir(exist_ok=True, parents=True)
|
base_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
for dtype in ["dwipreproc", "fmriprep"]:
|
for dtype in ["dwipreproc", "fmriprep", "freesurfer"]:
|
||||||
dtype_dir = base_dir / dtype
|
dtype_dir = base_dir / dtype
|
||||||
dtype_dir.mkdir()
|
dtype_dir.mkdir()
|
||||||
|
|
||||||
|
|
@ -94,10 +94,46 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
elif dtype == "freesurfer":
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(sub_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
with open(sub_dir / fname, "w") as f:
|
with open(sub_dir / fname, "w") as f:
|
||||||
f.write("placeholder")
|
f.write("placeholder")
|
||||||
|
|
||||||
|
if dtype == "freesurfer":
|
||||||
|
for extra in ["fsaverage", "fsaverage5"]:
|
||||||
|
extra_dir = dtype_dir / extra
|
||||||
|
extra_dir.mkdir()
|
||||||
|
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(extra_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for fname in fnames:
|
||||||
|
with open(extra_dir / fname, "w") as f:
|
||||||
|
f.write("placeholder")
|
||||||
|
|
||||||
ds.save(recursive=True)
|
ds.save(recursive=True)
|
||||||
# use this to create the repo automatically, only possible for juaml owner
|
# use this to create the repo automatically, only possible for juaml owner
|
||||||
# ds.create_sibling_gin(
|
# ds.create_sibling_gin(
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
base_dir = tmpdir / "derivatives"
|
base_dir = tmpdir / "derivatives"
|
||||||
base_dir.mkdir(exist_ok=True, parents=True)
|
base_dir.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
for dtype in ["dwipreproc", "fmriprep"]:
|
for dtype in ["dwipreproc", "fmriprep", "freesurfer"]:
|
||||||
dtype_dir = base_dir / dtype
|
dtype_dir = base_dir / dtype
|
||||||
dtype_dir.mkdir()
|
dtype_dir.mkdir()
|
||||||
|
|
||||||
|
|
@ -92,10 +92,46 @@ with TemporaryDirectory() as tmpdir_name:
|
||||||
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
elif dtype == "freesurfer":
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(sub_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
for fname in fnames:
|
for fname in fnames:
|
||||||
with open(sub_dir / fname, "w") as f:
|
with open(sub_dir / fname, "w") as f:
|
||||||
f.write("placeholder")
|
f.write("placeholder")
|
||||||
|
|
||||||
|
if dtype == "freesurfer":
|
||||||
|
for extra in ["fsaverage", "fsaverage5"]:
|
||||||
|
extra_dir = dtype_dir / extra
|
||||||
|
extra_dir.mkdir()
|
||||||
|
|
||||||
|
for dname in ["mri", "surf"]:
|
||||||
|
(extra_dir / dname).mkdir()
|
||||||
|
|
||||||
|
fnames = [
|
||||||
|
("mri/T1.mgz"),
|
||||||
|
("mri/aseg.mgz"),
|
||||||
|
("mri/norm.mgz"),
|
||||||
|
("surf/lh.white"),
|
||||||
|
("surf/rh.white"),
|
||||||
|
("surf/lh.pial"),
|
||||||
|
("surf/rh.pial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for fname in fnames:
|
||||||
|
with open(extra_dir / fname, "w") as f:
|
||||||
|
f.write("placeholder")
|
||||||
|
|
||||||
ds.save(recursive=True)
|
ds.save(recursive=True)
|
||||||
# use this to create the repo automatically, only possible for juaml owner
|
# use this to create the repo automatically, only possible for juaml owner
|
||||||
# ds.create_sibling_gin(
|
# ds.create_sibling_gin(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue