diff --git a/docs/changes/newsfragments/405.change b/docs/changes/newsfragments/405.change new file mode 100644 index 000000000..2ab34d33b --- /dev/null +++ b/docs/changes/newsfragments/405.change @@ -0,0 +1 @@ +``native_t1w`` parameter has been replaced with ``space`` to allow :class:`.DataladAOMICID1000`, :class:`.DataladAOMICPIOP1` and :class:`.DataladAOMICPIOP2` to fetch data in all available spaces by `Fede Raimondo`_ diff --git a/docs/changes/newsfragments/405.enh b/docs/changes/newsfragments/405.enh new file mode 100644 index 000000000..3d0a069b3 --- /dev/null +++ b/docs/changes/newsfragments/405.enh @@ -0,0 +1 @@ +Update :class:`.DataladAOMICID1000`, :class:`.DataladAOMICPIOP1` and :class:`.DataladAOMICPIOP2` to fetch data in all available spaces by `Fede Raimondo`_ diff --git a/junifer/datagrabber/aomic/id1000.py b/junifer/datagrabber/aomic/id1000.py index 21022fad9..760faa50d 100644 --- a/junifer/datagrabber/aomic/id1000.py +++ b/junifer/datagrabber/aomic/id1000.py @@ -11,6 +11,7 @@ from pathlib import Path from typing import Union from ...api.decorators import register_datagrabber +from ...utils import raise_error from ..pattern_datalad import PatternDataladDataGrabber @@ -31,8 +32,8 @@ class DataladAOMICID1000(PatternDataladDataGrabber): "FreeSurfer"} or list of the options, optional AOMIC data types. If None, all available data types are selected. (default None). - native_t1w : bool, optional - Whether to use T1w in native space (default False). + space : {"native", "MNI152NLin2009cAsym"}, optional + The space to use for the data (default "MNI152NLin2009cAsym"). """ @@ -40,25 +41,40 @@ class DataladAOMICID1000(PatternDataladDataGrabber): self, datadir: Union[str, Path, None] = None, types: Union[str, list[str], None] = None, - native_t1w: bool = False, + space: str = "MNI152NLin2009cAsym", ) -> None: + valid_spaces = ["native", "MNI152NLin2009cAsym"] + if space not in ["native", "MNI152NLin2009cAsym"]: + raise_error( + f"Invalid space {space}. Must be one of {valid_spaces}" + ) + + # Descriptor for space in `anat` + sp_anat_desc = ( + "" if space == "native" else "space-MNI152NLin2009cAsym_" + ) + # Descriptor for space in `func` + sp_func_desc = ( + "space-T1w_" if space == "native" else "space-MNI152NLin2009cAsym_" + ) # The patterns patterns = { "BOLD": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-moviewatching_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" + f"{sp_func_desc}" + "desc-preproc_bold.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-moviewatching_" - "space-MNI152NLin2009cAsym_" + f"{sp_func_desc}" "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "confounds": { "pattern": ( @@ -68,46 +84,59 @@ class DataladAOMICID1000(PatternDataladDataGrabber): ), "format": "fmriprep", }, + "reference": { + "pattern": ( + "derivatives/fmriprep/{subject}/func/" + "{subject}_task-moviewatching_" + f"{sp_func_desc}" + "boldref.nii.gz" + ), + }, }, "T1w": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-preproc_T1w.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, }, "VBM_CSF": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "CSF_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-CSF_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_GM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "GM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-GM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_WM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "WM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-WM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "DWI": { "pattern": ( @@ -148,51 +177,38 @@ class DataladAOMICID1000(PatternDataladDataGrabber): ) }, }, - } - # Use native T1w assets - self.native_t1w = False - if native_t1w: - self.native_t1w = True - patterns.update( + "Warp": [ { - "T1w": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-preproc_T1w.nii.gz" - ), - "space": "native", - "mask": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-brain_mask.nii.gz" - ), - "space": "native", - }, - }, - "Warp": [ - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-MNI152NLin2009cAsym_to-T1w_" - "mode-image_xfm.h5" - ), - "src": "MNI152NLin2009cAsym", - "dst": "native", - "warper": "ants", - }, - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-T1w_to-MNI152NLin2009cAsym_" - "mode-image_xfm.h5" - ), - "src": "native", - "dst": "MNI152NLin2009cAsym", - "warper": "ants", - }, - ], - } - ) + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-MNI152NLin2009cAsym_to-T1w_" + "mode-image_xfm.h5" + ), + "src": "MNI152NLin2009cAsym", + "dst": "native", + "warper": "ants", + }, + { + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-T1w_to-MNI152NLin2009cAsym_" + "mode-image_xfm.h5" + ), + "src": "native", + "dst": "MNI152NLin2009cAsym", + "warper": "ants", + }, + ], + } + if space == "native": + patterns["BOLD"]["prewarp_space"] = "MNI152NLin2009cAsym" + + else: + patterns["BOLD"]["prewarp_space"] = "native" + + # Use native T1w assets + self.space = space + # Set default types if types is None: types = list(patterns.keys()) diff --git a/junifer/datagrabber/aomic/piop1.py b/junifer/datagrabber/aomic/piop1.py index 80df49081..3afc74f03 100644 --- a/junifer/datagrabber/aomic/piop1.py +++ b/junifer/datagrabber/aomic/piop1.py @@ -37,8 +37,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): "gstroop", "workingmemory"} or list of the options, optional AOMIC PIOP1 task sessions. If None, all available task sessions are selected (default None). - native_t1w : bool, optional - Whether to use T1w in native space (default False). + space : {"native", "MNI152NLin2009cAsym"}, optional + The space to use for the data (default "MNI152NLin2009cAsym"). Raises ------ @@ -52,8 +52,13 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): datadir: Union[str, Path, None] = None, types: Union[str, list[str], None] = None, tasks: Union[str, list[str], None] = None, - native_t1w: bool = False, + space: str = "MNI152NLin2009cAsym", ) -> None: + valid_spaces = ["native", "MNI152NLin2009cAsym"] + if space not in ["native", "MNI152NLin2009cAsym"]: + raise_error( + f"Invalid space {space}. Must be one of {valid_spaces}" + ) # Declare all tasks all_tasks = [ "restingstate", @@ -78,22 +83,32 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): " dataset!" ) self.tasks = tasks + # Descriptor for space in `anat` + sp_anat_desc = ( + "" if space == "native" else "space-MNI152NLin2009cAsym_" + ) + # Descriptor for space in `func` + sp_func_desc = ( + "space-T1w_" if space == "native" else "space-MNI152NLin2009cAsym_" + ) # The patterns patterns = { "BOLD": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-{task}_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" + f"{sp_func_desc}" + "desc-preproc_bold.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-{task}_" - "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz" + f"{sp_func_desc}" + "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "confounds": { "pattern": ( @@ -103,46 +118,59 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): ), "format": "fmriprep", }, + "reference": { + "pattern": ( + "derivatives/fmriprep/{subject}/func/" + "{subject}_task-{task}_" + f"{sp_func_desc}" + "boldref.nii.gz" + ), + }, }, "T1w": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-preproc_T1w.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, }, "VBM_CSF": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "CSF_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-CSF_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_GM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "GM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-GM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_WM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "WM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-WM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "DWI": { "pattern": ( @@ -183,51 +211,38 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): ) }, }, - } - # Use native T1w assets - self.native_t1w = False - if native_t1w: - self.native_t1w = True - patterns.update( + "Warp": [ { - "T1w": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-preproc_T1w.nii.gz" - ), - "space": "native", - "mask": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-brain_mask.nii.gz" - ), - "space": "native", - }, - }, - "Warp": [ - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-MNI152NLin2009cAsym_to-T1w_" - "mode-image_xfm.h5" - ), - "src": "MNI152NLin2009cAsym", - "dst": "native", - "warper": "ants", - }, - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-T1w_to-MNI152NLin2009cAsym_" - "mode-image_xfm.h5" - ), - "src": "native", - "dst": "MNI152NLin2009cAsym", - "warper": "ants", - }, - ], - } - ) + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-MNI152NLin2009cAsym_to-T1w_" + "mode-image_xfm.h5" + ), + "src": "MNI152NLin2009cAsym", + "dst": "native", + "warper": "ants", + }, + { + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-T1w_to-MNI152NLin2009cAsym_" + "mode-image_xfm.h5" + ), + "src": "native", + "dst": "MNI152NLin2009cAsym", + "warper": "ants", + }, + ], + } + + if space == "native": + patterns["BOLD"]["prewarp_space"] = "MNI152NLin2009cAsym" + else: + patterns["BOLD"]["prewarp_space"] = "native" + + # Use native T1w assets + self.space = space + # Set default types if types is None: types = list(patterns.keys()) diff --git a/junifer/datagrabber/aomic/piop2.py b/junifer/datagrabber/aomic/piop2.py index 338a20bd2..7bee74f61 100644 --- a/junifer/datagrabber/aomic/piop2.py +++ b/junifer/datagrabber/aomic/piop2.py @@ -37,8 +37,8 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): list of the options, optional AOMIC PIOP2 task sessions. If None, all available task sessions are selected (default None). - native_t1w : bool, optional - Whether to use T1w in native space (default False). + space : {"native", "MNI152NLin2009cAsym"}, optional + The space to use for the data (default "MNI152NLin2009cAsym"). Raises ------ @@ -52,8 +52,13 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): datadir: Union[str, Path, None] = None, types: Union[str, list[str], None] = None, tasks: Union[str, list[str], None] = None, - native_t1w: bool = False, + space: str = "MNI152NLin2009cAsym", ) -> None: + valid_spaces = ["native", "MNI152NLin2009cAsym"] + if space not in ["native", "MNI152NLin2009cAsym"]: + raise_error( + f"Invalid space {space}. Must be one of {valid_spaces}" + ) # Declare all tasks all_tasks = [ "restingstate", @@ -76,22 +81,32 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): " dataset!" ) self.tasks = tasks + # Descriptor for space in `anat` + sp_anat_desc = ( + "" if space == "native" else "space-MNI152NLin2009cAsym_" + ) + # Descriptor for space in `func` + sp_func_desc = ( + "space-T1w_" if space == "native" else "space-MNI152NLin2009cAsym_" + ) # The patterns patterns = { "BOLD": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-{task}_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" + f"{sp_func_desc}" + "desc-preproc_bold.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/func/" "{subject}_task-{task}_" - "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz" + f"{sp_func_desc}" + "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "confounds": { "pattern": ( @@ -101,46 +116,59 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): ), "format": "fmriprep", }, + "reference": { + "pattern": ( + "derivatives/fmriprep/{subject}/func/" + "{subject}_task-{task}_" + f"{sp_func_desc}" + "boldref.nii.gz" + ), + }, }, "T1w": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-preproc_T1w.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, "mask": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_" + "{subject}_" + f"{sp_anat_desc}" "desc-brain_mask.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, }, "VBM_CSF": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "CSF_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-CSF_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_GM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "GM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-GM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "VBM_WM": { "pattern": ( "derivatives/fmriprep/{subject}/anat/" - "{subject}_space-MNI152NLin2009cAsym_label-" - "WM_probseg.nii.gz" + "{subject}_" + f"{sp_anat_desc}" + "label-WM_probseg.nii.gz" ), - "space": "MNI152NLin2009cAsym", + "space": space, }, "DWI": { "pattern": ( @@ -181,51 +209,38 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): ) }, }, - } - # Use native T1w assets - self.native_t1w = False - if native_t1w: - self.native_t1w = True - patterns.update( + "Warp": [ { - "T1w": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-preproc_T1w.nii.gz" - ), - "space": "native", - "mask": { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_desc-brain_mask.nii.gz" - ), - "space": "native", - }, - }, - "Warp": [ - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-MNI152NLin2009cAsym_to-T1w_" - "mode-image_xfm.h5" - ), - "src": "MNI152NLin2009cAsym", - "dst": "native", - "warper": "ants", - }, - { - "pattern": ( - "derivatives/fmriprep/{subject}/anat/" - "{subject}_from-T1w_to-MNI152NLin2009cAsym_" - "mode-image_xfm.h5" - ), - "src": "native", - "dst": "MNI152NLin2009cAsym", - "warper": "ants", - }, - ], - } - ) + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-MNI152NLin2009cAsym_to-T1w_" + "mode-image_xfm.h5" + ), + "src": "MNI152NLin2009cAsym", + "dst": "native", + "warper": "ants", + }, + { + "pattern": ( + "derivatives/fmriprep/{subject}/anat/" + "{subject}_from-T1w_to-MNI152NLin2009cAsym_" + "mode-image_xfm.h5" + ), + "src": "native", + "dst": "MNI152NLin2009cAsym", + "warper": "ants", + }, + ], + } + + if space == "native": + patterns["BOLD"]["prewarp_space"] = "MNI152NLin2009cAsym" + else: + patterns["BOLD"]["prewarp_space"] = "native" + + # Use native T1w assets + self.space = space + # Set default types if types is None: types = list(patterns.keys()) diff --git a/junifer/datagrabber/aomic/tests/test_id1000.py b/junifer/datagrabber/aomic/tests/test_id1000.py index 53ec16b3f..2e850fc81 100644 --- a/junifer/datagrabber/aomic/tests/test_id1000.py +++ b/junifer/datagrabber/aomic/tests/test_id1000.py @@ -18,20 +18,25 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000" @pytest.mark.parametrize( - "type_, nested_types", + "type_, nested_types, space", [ - ("BOLD", ["confounds", "mask"]), - ("T1w", ["mask"]), - ("VBM_CSF", None), - ("VBM_GM", None), - ("VBM_WM", None), - ("DWI", None), - ("FreeSurfer", None), + ("BOLD", ["confounds", "mask", "reference"], "MNI152NLin2009cAsym"), + ("BOLD", ["confounds", "mask", "reference"], "native"), + ("T1w", ["mask"], "MNI152NLin2009cAsym"), + ("T1w", ["mask"], "native"), + ("VBM_CSF", None, "MNI152NLin2009cAsym"), + ("VBM_CSF", None, "native"), + ("VBM_GM", None, "MNI152NLin2009cAsym"), + ("VBM_GM", None, "native"), + ("VBM_WM", None, "MNI152NLin2009cAsym"), + ("DWI", None, "MNI152NLin2009cAsym"), + ("FreeSurfer", None, "MNI152NLin2009cAsym"), ], ) def test_DataladAOMICID1000( type_: str, nested_types: Optional[list[str]], + space: str, ) -> None: """Test DataladAOMICID1000 DataGrabber. @@ -41,9 +46,11 @@ def test_DataladAOMICID1000( The parametrized type. nested_types : list of str or None The parametrized nested types. + space: str + The parametrized space. """ - dg = DataladAOMICID1000(types=type_) + dg = DataladAOMICID1000(types=type_, space=space) # Set URI to Gin dg.uri = URI diff --git a/junifer/datagrabber/aomic/tests/test_piop1.py b/junifer/datagrabber/aomic/tests/test_piop1.py index 1dda1b523..dc33a0adc 100644 --- a/junifer/datagrabber/aomic/tests/test_piop1.py +++ b/junifer/datagrabber/aomic/tests/test_piop1.py @@ -18,30 +18,62 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1" @pytest.mark.parametrize( - "type_, nested_types, tasks", + "type_, nested_types, tasks, space", [ - ("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"], + ["confounds", "mask", "reference"], + None, + "MNI152NLin2009cAsym", ), - ("T1w", ["mask"], None), - ("VBM_CSF", None, None), - ("VBM_GM", None, None), - ("VBM_WM", None, None), - ("DWI", None, None), - ("FreeSurfer", None, None), + ("BOLD", ["confounds", "mask", "reference"], None, "native"), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["anticipation"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["emomatching", "faces"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["restingstate"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["workingmemory", "gstroop"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["anticipation", "faces", "restingstate"], + "MNI152NLin2009cAsym", + ), + ("T1w", ["mask"], None, "MNI152NLin2009cAsym"), + ("T1w", ["mask"], None, "native"), + ("VBM_CSF", None, None, "MNI152NLin2009cAsym"), + ("VBM_CSF", None, None, "native"), + ("VBM_GM", None, None, "MNI152NLin2009cAsym"), + ("VBM_GM", None, None, "native"), + ("VBM_WM", None, None, "MNI152NLin2009cAsym"), + ("VBM_WM", None, None, "native"), + ("DWI", None, None, "MNI152NLin2009cAsym"), + ("FreeSurfer", None, None, "MNI152NLin2009cAsym"), ], ) def test_DataladAOMICPIOP1( type_: str, nested_types: Optional[list[str]], tasks: Optional[list[str]], + space: str, ) -> None: """Test DataladAOMICPIOP1 DataGrabber. @@ -53,9 +85,11 @@ def test_DataladAOMICPIOP1( The parametrized nested types. tasks : list of str or None The parametrized task values. + space: str + The parametrized space. """ - dg = DataladAOMICPIOP1(types=type_, tasks=tasks) + dg = DataladAOMICPIOP1(types=type_, tasks=tasks, space=space) # Set URI to Gin dg.uri = URI diff --git a/junifer/datagrabber/aomic/tests/test_piop2.py b/junifer/datagrabber/aomic/tests/test_piop2.py index f7e556bb4..dc5454511 100644 --- a/junifer/datagrabber/aomic/tests/test_piop2.py +++ b/junifer/datagrabber/aomic/tests/test_piop2.py @@ -18,25 +18,56 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop2" @pytest.mark.parametrize( - "type_, nested_types, tasks", + "type_, nested_types, tasks, space", [ - ("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), + ( + "BOLD", + ["confounds", "mask", "reference"], + None, + "MNI152NLin2009cAsym", + ), + ("BOLD", ["confounds", "mask", "reference"], None, "native"), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["restingstate"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["restingstate", "stopsignal"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["workingmemory", "stopsignal"], + "MNI152NLin2009cAsym", + ), + ( + "BOLD", + ["confounds", "mask", "reference"], + ["workingmemory"], + "MNI152NLin2009cAsym", + ), + ("T1w", ["mask"], None, "MNI152NLin2009cAsym"), + ("T1w", ["mask"], None, "native"), + ("VBM_CSF", None, None, "MNI152NLin2009cAsym"), + ("VBM_CSF", None, None, "native"), + ("VBM_GM", None, None, "MNI152NLin2009cAsym"), + ("VBM_GM", None, None, "native"), + ("VBM_WM", None, None, "MNI152NLin2009cAsym"), + ("VBM_WM", None, None, "native"), + ("DWI", None, None, "MNI152NLin2009cAsym"), + ("FreeSurfer", None, None, "MNI152NLin2009cAsym"), ], ) def test_DataladAOMICPIOP2( type_: str, nested_types: Optional[list[str]], tasks: Optional[list[str]], + space: str, ) -> None: """Test DataladAOMICPIOP2 DataGrabber. @@ -48,9 +79,11 @@ def test_DataladAOMICPIOP2( The parametrized nested types. tasks : list of str or None The parametrized task values. + space: str + The parametrized space. """ - dg = DataladAOMICPIOP2(types=type_, tasks=tasks) + dg = DataladAOMICPIOP2(types=type_, tasks=tasks, space=space) # Set URI to Gin dg.uri = URI diff --git a/tools/create_aomic1000_example_dataset.py b/tools/create_aomic1000_example_dataset.py index 11bc9576a..f13989a1a 100644 --- a/tools/create_aomic1000_example_dataset.py +++ b/tools/create_aomic1000_example_dataset.py @@ -4,6 +4,7 @@ # Vera Komeyer # Xuan Li # License: AGPL + from pathlib import Path from tempfile import TemporaryDirectory @@ -39,30 +40,70 @@ with TemporaryDirectory() as tmpdir_name: (sub_dir / dname).mkdir() fnames = [ + # T1w native + f"anat/{t_sub}_desc-preproc_T1w.nii.gz", + # T1w MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc" "_T1w.nii.gz" ), + # T1w brain mask native + f"anat/{t_sub}_desc-brain_mask.nii.gz", + # T1w brain mask MNI152NLin2009cAsym + ( + f"anat/{t_sub}_space-MNI152NLin2009cAsym_" + "desc-brain_mask.nii.gz" + ), + # CSF native + f"anat/{t_sub}_label-CSF_probseg.nii.gz", + # CSF MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "CSF_probseg.nii.gz" ), + # GM native + f"anat/{t_sub}_label-GM_probseg.nii.gz", + # GM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "GM_probseg.nii.gz" ), + # WM native + f"anat/{t_sub}_label-WM_probseg.nii.gz", + # WM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "WM_probseg.nii.gz" ), + # BOLD native + ( + f"func/{t_sub}_task-moviewatching_space-" + "T1w_desc-preproc_bold.nii.gz" + ), + # BOLD MNI152NLin2009cAsym ( f"func/{t_sub}_task-moviewatching_space-" "MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" ), + # BOLD brain mask native + ( + f"func/{t_sub}_task-moviewatching_" + "space-T1w_desc-brain_mask.nii.gz" + ), + # BOLD brain mask MNI152NLin2009cAsym + ( + f"func/{t_sub}_task-moviewatching_" + "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz" + ), + ( + f"func/{t_sub}_task-moviewatching_space-" + "T1w_desc-preproc_bold.json" + ), ( f"func/{t_sub}_task-moviewatching_space-" "MNI152NLin2009cAsym_desc-preproc_bold.json" ), + # BOLD confounds ( f"func/{t_sub}_task-moviewatching_desc-confounds" "_regressors.tsv" @@ -71,13 +112,15 @@ with TemporaryDirectory() as tmpdir_name: f"func/{t_sub}_task-moviewatching_desc-confounds" "_regressors.json" ), + # BOLD reference native ( f"func/{t_sub}_task-moviewatching_" - "space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz" + "space-T1w_boldref.nii.gz" ), + # BOLD reference MNI152NLin2009cAsym ( - f"anat/{t_sub}_space-MNI152NLin2009cAsym_" - "desc-brain_mask.nii.gz" + f"func/{t_sub}_task-moviewatching_" + "space-MNI152NLin2009cAsym_boldref.nii.gz" ), ] diff --git a/tools/create_aomicpiop1_example_dataset.py b/tools/create_aomicpiop1_example_dataset.py index 6b8bd420b..1f46bd321 100644 --- a/tools/create_aomicpiop1_example_dataset.py +++ b/tools/create_aomicpiop1_example_dataset.py @@ -5,6 +5,7 @@ # Xuan Li # Leonard Sasse # License: AGPL + from pathlib import Path from tempfile import TemporaryDirectory @@ -35,22 +36,37 @@ with TemporaryDirectory() as tmpdir_name: (sub_dir / dname).mkdir() fnames = [ + # T1w native + f"anat/{t_sub}_desc-preproc_T1w.nii.gz", + # T1w MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc" "_T1w.nii.gz" ), + # T1w brain mask native + f"anat/{t_sub}_desc-brain_mask.nii.gz", + # T1w brain mask MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_" "desc-brain_mask.nii.gz" ), + # CSF native + f"anat/{t_sub}_label-CSF_probseg.nii.gz", + # CSF MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "CSF_probseg.nii.gz" ), + # GM native + f"anat/{t_sub}_label-GM_probseg.nii.gz", + # GM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "GM_probseg.nii.gz" ), + # WM native + f"anat/{t_sub}_label-WM_probseg.nii.gz", + # WM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "WM_probseg.nii.gz" @@ -66,18 +82,35 @@ with TemporaryDirectory() as tmpdir_name: "workingmemory_acq-seq", ] for t in tasks: + # BOLD native + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-preproc_bold.nii.gz" + ) + # BOLD MNI152NLin2009cAsym fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" ) + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-preproc_bold.json" + ) fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-preproc_bold.json" ) + # BOLD brain mask native + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-brain_mask.nii.gz" + ) + # BOLD brain mask MNI152NLin2009cAsym fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-brain_mask.nii.gz" ) + # BOLD confounds fnames.append( f"func/{t_sub}_task-{t}_desc-confounds" "_regressors.tsv" @@ -86,6 +119,15 @@ with TemporaryDirectory() as tmpdir_name: f"func/{t_sub}_task-{t}_desc-confounds" "_regressors.json" ) + # BOLD reference native + fnames.append( + f"func/{t_sub}_task-{t}_" "space-T1w_boldref.nii.gz" + ) + # BOLD reference MNI152NLin2009cAsym + fnames.append( + f"func/{t_sub}_task-{t}_" + "space-MNI152NLin2009cAsym_boldref.nii.gz" + ) elif dtype == "dwipreproc": dname = "dwi" diff --git a/tools/create_aomicpiop2_example_dataset.py b/tools/create_aomicpiop2_example_dataset.py index d4c76a12c..b17072728 100644 --- a/tools/create_aomicpiop2_example_dataset.py +++ b/tools/create_aomicpiop2_example_dataset.py @@ -5,6 +5,7 @@ # Xuan Li # Leonard Sasse # License: AGPL + from pathlib import Path from tempfile import TemporaryDirectory @@ -35,22 +36,37 @@ with TemporaryDirectory() as tmpdir_name: (sub_dir / dname).mkdir() fnames = [ + # T1w native + f"anat/{t_sub}_desc-preproc_T1w.nii.gz", + # T1w MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc" "_T1w.nii.gz" ), + # T1w brain mask native + f"anat/{t_sub}_desc-brain_mask.nii.gz", + # T1w brain mask MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym" "_desc-brain_mask.nii.gz" ), + # CSF native + f"anat/{t_sub}_label-CSF_probseg.nii.gz", + # CSF MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "CSF_probseg.nii.gz" ), + # GM native + f"anat/{t_sub}_label-GM_probseg.nii.gz", + # GM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "GM_probseg.nii.gz" ), + # WM native + f"anat/{t_sub}_label-WM_probseg.nii.gz", + # WM MNI152NLin2009cAsym ( f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-" "WM_probseg.nii.gz" @@ -64,18 +80,35 @@ with TemporaryDirectory() as tmpdir_name: "workingmemory_acq-seq", ] for t in tasks: + # BOLD native + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-preproc_bold.nii.gz" + ) + # BOLD MNI152NLin2009cAsym fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" ) + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-preproc_bold.json" + ) fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-preproc_bold.json" ) + # BOLD brain mask native + fnames.append( + f"func/{t_sub}_task-{t}_space-" + "T1w_desc-brain_mask.nii.gz" + ) + # BOLD brain mask MNI152NLin2009cAsym fnames.append( f"func/{t_sub}_task-{t}_space-" "MNI152NLin2009cAsym_desc-brain_mask.nii.gz" ) + # BOLD confounds fnames.append( f"func/{t_sub}_task-{t}_desc-confounds" "_regressors.tsv" @@ -84,6 +117,15 @@ with TemporaryDirectory() as tmpdir_name: f"func/{t_sub}_task-{t}_desc-confounds" "_regressors.json" ) + # BOLD reference native + fnames.append( + f"func/{t_sub}_task-{t}_" "space-T1w_boldref.nii.gz" + ) + # BOLD reference MNI152NLin2009cAsym + fnames.append( + f"func/{t_sub}_task-{t}_" + "space-MNI152NLin2009cAsym_boldref.nii.gz" + ) elif dtype == "dwipreproc": dname = "dwi"