diff --git a/docs/changes/newsfragments/346.enh b/docs/changes/newsfragments/346.enh new file mode 100644 index 000000000..b4176a8e4 --- /dev/null +++ b/docs/changes/newsfragments/346.enh @@ -0,0 +1 @@ +Adapt :class:`.DataladAOMICID1000`, :class:`.DataladAOMICPIOP1` and :class:`.DataladAOMICPIOP2` to support ``FreeSurfer`` data type by `Synchon Mandal`_ diff --git a/docs/changes/newsfragments/346.feature b/docs/changes/newsfragments/346.feature new file mode 100644 index 000000000..542fb4b72 --- /dev/null +++ b/docs/changes/newsfragments/346.feature @@ -0,0 +1 @@ +Add support for ``FreeSurfer`` data type for :class:`.PatternDataGrabber` by `Synchon Mandal`_ diff --git a/docs/understanding/data.rst b/docs/understanding/data.rst index 1d98f801c..294eb4cb8 100644 --- a/docs/understanding/data.rst +++ b/docs/understanding/data.rst @@ -115,6 +115,9 @@ Data Types * - ``VBM_WM`` - VBM White Matter segmentation (3D) - CAT output (`m0wp2` images) + * - ``VBM_CSF`` + - VBM Central Spinal Fluid segmentation (3D) + - CAT output (`m0wp3` images) * - ``fALFF`` - Voxel-wise fALFF image (3D) - fALFF computed with CONN toolbox @@ -124,3 +127,9 @@ Data Types * - ``LCOR`` - Local Correlation image (3D) - 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 diff --git a/junifer/datagrabber/aomic/id1000.py b/junifer/datagrabber/aomic/id1000.py index ae16d0ef9..5c1156c5d 100644 --- a/junifer/datagrabber/aomic/id1000.py +++ b/junifer/datagrabber/aomic/id1000.py @@ -24,8 +24,8 @@ class DataladAOMICID1000(PatternDataladDataGrabber): The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None). - types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \ - list of the options, optional + types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \ + "FreeSurfer"} or list of the options, optional AOMIC data types. If None, all available data types are selected. (default None). native_t1w : bool, optional @@ -112,6 +112,39 @@ class DataladAOMICID1000(PatternDataladDataGrabber): "{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 self.native_t1w = False diff --git a/junifer/datagrabber/aomic/piop1.py b/junifer/datagrabber/aomic/piop1.py index 2ebe94c5a..509a0c532 100644 --- a/junifer/datagrabber/aomic/piop1.py +++ b/junifer/datagrabber/aomic/piop1.py @@ -26,8 +26,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None). - types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \ - list of the options, optional + types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \ + "FreeSurfer"} or list of the options, optional AOMIC data types. If None, all available data types are selected. (default None). tasks : {"restingstate", "anticipation", "emomatching", "faces", \ @@ -147,6 +147,39 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber): "{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 self.native_t1w = False diff --git a/junifer/datagrabber/aomic/piop2.py b/junifer/datagrabber/aomic/piop2.py index 9fd6cbc23..cf6320f42 100644 --- a/junifer/datagrabber/aomic/piop2.py +++ b/junifer/datagrabber/aomic/piop2.py @@ -26,8 +26,8 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): The directory where the datalad dataset will be cloned. If None, the datalad dataset will be cloned into a temporary directory (default None). - types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI"} or \ - list of the options, optional + types: {"BOLD", "T1w", "VBM_CSF", "VBM_GM", "VBM_WM", "DWI", \ + "FreeSurfer"} or list of the options, optional AOMIC data types. If None, all available data types are selected. (default None). tasks : {"restingstate", "stopsignal", "workingmemory"} or \ @@ -144,6 +144,39 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber): "{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 self.native_t1w = False diff --git a/junifer/datagrabber/aomic/tests/test_id1000.py b/junifer/datagrabber/aomic/tests/test_id1000.py index 248753d88..890cc758a 100644 --- a/junifer/datagrabber/aomic/tests/test_id1000.py +++ b/junifer/datagrabber/aomic/tests/test_id1000.py @@ -7,7 +7,7 @@ # Synchon Mandal # License: AGPL -from typing import List, Union +from typing import List, Optional, Union import pytest @@ -17,112 +17,58 @@ from junifer.datagrabber.aomic.id1000 import DataladAOMICID1000 URI = "https://gin.g-node.org/juaml/datalad-example-aomic1000" -def test_DataladAOMICID1000() -> None: - """Test DataladAOMICID1000 DataGrabber.""" - dg = DataladAOMICID1000() +@pytest.mark.parametrize( + "type_, nested_types", + [ + ("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 dg.uri = URI with dg: + # Get all elements all_elements = dg.get_elements() + # Get test element test_element = all_elements[0] - + # Get test element data out = dg[test_element] - - # asserts type "BOLD" - assert "BOLD" in out - - assert ( - out["BOLD"]["path"].name == f"{test_element}_task-moviewatching_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" - ) - - 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 data type + assert type_ in out + assert out[type_]["path"].exists() + assert out[type_]["path"].is_file() + # Asserts data type metadata + assert "meta" in out[type_] + meta = out[type_]["meta"] assert "element" in meta assert "subject" in meta["element"] 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( diff --git a/junifer/datagrabber/aomic/tests/test_piop1.py b/junifer/datagrabber/aomic/tests/test_piop1.py index dfb79219f..31d3034f9 100644 --- a/junifer/datagrabber/aomic/tests/test_piop1.py +++ b/junifer/datagrabber/aomic/tests/test_piop1.py @@ -18,129 +18,87 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop1" @pytest.mark.parametrize( - "tasks", - [None, "restingstate"], + "type_, nested_types, tasks", + [ + ("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. 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. """ - dg = DataladAOMICPIOP1(tasks=tasks) + dg = DataladAOMICPIOP1(types=type_, tasks=tasks) # Set URI to Gin dg.uri = URI with dg: + # Get all elements all_elements = dg.get_elements() + # Get test element test_element = all_elements[0] - sub, task = test_element - + # Get test element data out = dg[test_element] - - # asserts type "BOLD" - assert "BOLD" in out - - # depending on task 'acquisition is different' - task_acqs = { - "anticipation": "seq", - "emomatching": "seq", - "faces": "mb3", - "gstroop": "seq", - "restingstate": "mb3", - "workingmemory": "seq", - } - acq = task_acqs[task] - new_task = f"{task}_acq-{acq}" - assert ( - out["BOLD"]["path"].name == f"{sub}_task-{new_task}_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" - ) - - 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"] + # Get all elements + all_elements = dg.get_elements() + # Get test element + test_element = all_elements[0] + # Get test element data + out = dg[test_element] + # Assert data type + assert type_ in out + # Check task name if BOLD + if type_ == "BOLD" and tasks is not None: + # Depending on task 'acquisition is different' + task_acqs = { + "anticipation": "seq", + "emomatching": "seq", + "faces": "mb3", + "gstroop": "seq", + "restingstate": "mb3", + "workingmemory": "seq", + } + assert task_acqs[test_element[1]] in out[type_]["path"].name + assert out[type_]["path"].exists() + assert out[type_]["path"].is_file() + # Asserts data type metadata + assert "meta" in out[type_] + meta = out[type_]["meta"] assert "element" in meta 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( diff --git a/junifer/datagrabber/aomic/tests/test_piop2.py b/junifer/datagrabber/aomic/tests/test_piop2.py index b316fdf3d..21c80a7ef 100644 --- a/junifer/datagrabber/aomic/tests/test_piop2.py +++ b/junifer/datagrabber/aomic/tests/test_piop2.py @@ -18,123 +18,67 @@ URI = "https://gin.g-node.org/juaml/datalad-example-aomicpiop2" @pytest.mark.parametrize( - "tasks", - [None, "restingstate"], + "type_, nested_types, tasks", + [ + ("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. 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. """ - dg = DataladAOMICPIOP2(tasks=tasks) + dg = DataladAOMICPIOP2(types=type_, tasks=tasks) # Set URI to Gin dg.uri = URI with dg: + # Get all elements all_elements = dg.get_elements() - - if tasks == "restingstate": - for el in all_elements: - assert el[1] == "restingstate" - + # Get test element test_element = all_elements[0] - sub, task = test_element + # Get test element data out = dg[test_element] - - # asserts type "BOLD" - assert "BOLD" in out - - new_task = f"{task}_acq-seq" - assert ( - out["BOLD"]["path"].name == f"{sub}_task-{new_task}_" - "space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz" - ) - - 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 data type + assert type_ in out + # Check task name if BOLD + if type_ == "BOLD" and tasks is not None: + assert test_element[1] in out[type_]["path"].name + assert out[type_]["path"].exists() + assert out[type_]["path"].is_file() + # Asserts data type metadata + assert "meta" in out[type_] + meta = out[type_]["meta"] assert "element" in meta 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( diff --git a/junifer/datagrabber/utils.py b/junifer/datagrabber/utils.py index 3a92473a4..3004ac451 100644 --- a/junifer/datagrabber/utils.py +++ b/junifer/datagrabber/utils.py @@ -53,6 +53,17 @@ PATTERNS_SCHEMA = { "mandatory": ["pattern"], "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": []}, + }, + }, } diff --git a/junifer/datareader/default.py b/junifer/datareader/default.py index 438e13ee0..2770c833d 100644 --- a/junifer/datareader/default.py +++ b/junifer/datareader/default.py @@ -103,8 +103,8 @@ class DefaultDataReader(PipelineStepMixin, UpdateMetaMixin): params = {} # For each type of data, try to read it for type_key, type_val in input.items(): - # Skip Warp data type - if type_key == "Warp": + # Skip Warp and FreeSurfer data type + if type_key in ["Warp", "FreeSurfer"]: continue # Check for malformed datagrabber specification diff --git a/tools/create_aomic1000_example_dataset.py b/tools/create_aomic1000_example_dataset.py index 6a26623f2..55aee2a31 100644 --- a/tools/create_aomic1000_example_dataset.py +++ b/tools/create_aomic1000_example_dataset.py @@ -24,7 +24,7 @@ with TemporaryDirectory() as tmpdir_name: base_dir = tmpdir / "derivatives" 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.mkdir() @@ -88,10 +88,46 @@ with TemporaryDirectory() as tmpdir_name: (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: with open(sub_dir / fname, "w") as f: 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) # use this to create the repo automatically, only possible for juaml owner # ds.create_sibling_gin( diff --git a/tools/create_aomicpiop1_example_dataset.py b/tools/create_aomicpiop1_example_dataset.py index d9690867c..42898b75b 100644 --- a/tools/create_aomicpiop1_example_dataset.py +++ b/tools/create_aomicpiop1_example_dataset.py @@ -20,7 +20,7 @@ with TemporaryDirectory() as tmpdir_name: base_dir = tmpdir / "derivatives" 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.mkdir() @@ -94,10 +94,46 @@ with TemporaryDirectory() as tmpdir_name: (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: with open(sub_dir / fname, "w") as f: 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) # use this to create the repo automatically, only possible for juaml owner # ds.create_sibling_gin( diff --git a/tools/create_aomicpiop2_example_dataset.py b/tools/create_aomicpiop2_example_dataset.py index 5d2187b78..0b58e8620 100644 --- a/tools/create_aomicpiop2_example_dataset.py +++ b/tools/create_aomicpiop2_example_dataset.py @@ -20,7 +20,7 @@ with TemporaryDirectory() as tmpdir_name: base_dir = tmpdir / "derivatives" 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.mkdir() @@ -92,10 +92,46 @@ with TemporaryDirectory() as tmpdir_name: (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: with open(sub_dir / fname, "w") as f: 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) # use this to create the repo automatically, only possible for juaml owner # ds.create_sibling_gin(