Add aomic masks #179
10 changed files with 190 additions and 64 deletions
|
|
@ -40,6 +40,9 @@ Enhancements
|
|||
- Add support for nilearn computed masks (``compute_epi_mask``, ``compute_brain_mask``, ``compute_background_mask``,
|
||||
|
oops yeah always get that wrong oops yeah always get that wrong
|
||||
``fetch_icbm152_brain_gm_mask``) (:gh:`175` by `Fede Raimondo`_).
|
||||
|
||||
- Add fMRIPrep brain masks to the datagrabber patterns for all datagrabbers in the aomic sub-package
|
||||
(:gh:`177` by `Leonard Sasse`_).
|
||||
|
||||
Bugs
|
||||
~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
# License: AGPL
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from typing import Union, Dict
|
||||
|
||||
from junifer.datagrabber import PatternDataladDataGrabber
|
||||
|
||||
|
|
@ -34,7 +34,9 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|||
types = [
|
||||
"BOLD",
|
||||
"BOLD_confounds",
|
||||
"BOLD_mask",
|
||||
"T1w",
|
||||
"T1w_mask",
|
||||
"probseg_CSF",
|
||||
"probseg_GM",
|
||||
"probseg_WM",
|
||||
|
|
@ -52,11 +54,22 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|||
"sub-{subject}_task-moviewatching_"
|
||||
"desc-confounds_regressors.tsv"
|
||||
),
|
||||
"BOLD_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/func/"
|
||||
"sub-{subject}_task-moviewatching_"
|
||||
"space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
"T1w": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-preproc_T1w.nii.gz"
|
||||
),
|
||||
"T1w_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
"probseg_CSF": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_label-"
|
||||
|
|
@ -88,3 +101,22 @@ class DataladAOMICID1000(PatternDataladDataGrabber):
|
|||
replacements=replacements,
|
||||
confounds_format="fmriprep",
|
||||
)
|
||||
|
||||
def get_item(self, subject: str) -> Dict:
|
||||
"""Index one element in the dataset.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
subject : str
|
||||
The subject ID.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : dict
|
||||
Dictionary of paths for each type of data required for the
|
||||
specified element.
|
||||
"""
|
||||
out = super().get_item(subject=subject)
|
||||
out["BOLD"]["mask_item"] = "BOLD_mask"
|
||||
out["T1w"]["mask_item"] = "T1w_mask"
|
||||
return out
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|||
types = [
|
||||
"BOLD",
|
||||
"BOLD_confounds",
|
||||
"BOLD_mask",
|
||||
"T1w",
|
||||
"T1w_mask",
|
||||
"probseg_CSF",
|
||||
"probseg_GM",
|
||||
"probseg_WM",
|
||||
|
|
@ -83,11 +85,21 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|||
"sub-{subject}_task-{task}_"
|
||||
"desc-confounds_regressors.tsv"
|
||||
),
|
||||
"BOLD_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/func/"
|
||||
"sub-{subject}_task-{task}_"
|
||||
"space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
||||
),
|
||||
"T1w": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-preproc_T1w.nii.gz"
|
||||
),
|
||||
"T1w_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
"probseg_CSF": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_label-"
|
||||
|
|
@ -149,6 +161,8 @@ class DataladAOMICPIOP1(PatternDataladDataGrabber):
|
|||
new_task = f"{task}_acq-{acq}"
|
||||
|
||||
out = super().get_item(subject=subject, task=new_task)
|
||||
out["BOLD"]["mask_item"] = "BOLD_mask"
|
||||
out["T1w"]["mask_item"] = "T1w_mask"
|
||||
return out
|
||||
|
||||
def get_elements(self) -> List:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
# License: AGPL
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Union
|
||||
from typing import List, Union, Dict
|
||||
|
||||
from junifer.datagrabber import PatternDataladDataGrabber
|
||||
|
||||
|
|
@ -40,7 +40,9 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|||
types = [
|
||||
"BOLD",
|
||||
"BOLD_confounds",
|
||||
"BOLD_mask",
|
||||
"T1w",
|
||||
"T1w_mask",
|
||||
"probseg_CSF",
|
||||
"probseg_GM",
|
||||
"probseg_WM",
|
||||
|
|
@ -80,11 +82,21 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|||
"sub-{subject}_task-{task}_acq-seq_"
|
||||
"desc-confounds_regressors.tsv"
|
||||
),
|
||||
"BOLD_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/func/"
|
||||
"sub-{subject}_task-{task}_acq-seq_space"
|
||||
"-MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
||||
),
|
||||
"T1w": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-preproc_T1w.nii.gz"
|
||||
),
|
||||
"T1w_mask": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
"probseg_CSF": (
|
||||
"derivatives/fmriprep/sub-{subject}/anat/"
|
||||
"sub-{subject}_space-MNI152NLin2009cAsym_label-"
|
||||
|
|
@ -127,3 +139,25 @@ class DataladAOMICPIOP2(PatternDataladDataGrabber):
|
|||
"""
|
||||
all_elements = super().get_elements()
|
||||
return [x for x in all_elements if x[1] in self.tasks]
|
||||
|
||||
def get_item(self, subject: str, task: str) -> Dict:
|
||||
"""Index one element in the dataset.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
subject : str
|
||||
The subject ID.
|
||||
task : str
|
||||
The task to get. Possible values are:
|
||||
{"restingstate", "stopsignal", "emomatching", "workingmemory"}
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : dict
|
||||
Dictionary of paths for each type of data required for the
|
||||
specified element.
|
||||
"""
|
||||
out = super().get_item(subject=subject, task=task)
|
||||
out["BOLD"]["mask_item"] = "BOLD_mask"
|
||||
out["T1w"]["mask_item"] = "T1w_mask"
|
||||
return out
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ def test_aomic1000_datagrabber() -> None:
|
|||
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
|
||||
|
||||
|
|
@ -63,6 +66,9 @@ def test_aomic1000_datagrabber() -> None:
|
|||
assert out["T1w"]["path"].exists()
|
||||
assert out["T1w"]["path"].is_file()
|
||||
|
||||
# asserts T1w_mask
|
||||
assert out["T1w_mask"]["path"].exists()
|
||||
|
||||
# asserts type "probseg_CSF"
|
||||
assert "probseg_CSF" in out
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ def test_aomic_piop1_datagrabber() -> None:
|
|||
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
|
||||
|
||||
|
|
@ -78,6 +81,9 @@ def test_aomic_piop1_datagrabber() -> None:
|
|||
assert out["T1w"]["path"].exists()
|
||||
assert out["T1w"]["path"].is_file()
|
||||
|
||||
# asserts T1w_mask
|
||||
assert out["T1w_mask"]["path"].exists()
|
||||
|
||||
# asserts type "probseg_CSF"
|
||||
assert "probseg_CSF" in out
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ def test_aomic_piop2_datagrabber() -> None:
|
|||
|
||||
test_element = all_elements[0]
|
||||
sub, task = test_element
|
||||
|
||||
out = dg[test_element]
|
||||
|
||||
# asserts type "BOLD"
|
||||
|
|
@ -62,6 +61,9 @@ def test_aomic_piop2_datagrabber() -> None:
|
|||
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
|
||||
|
||||
|
|
@ -74,6 +76,9 @@ def test_aomic_piop2_datagrabber() -> None:
|
|||
assert out["T1w"]["path"].exists()
|
||||
assert out["T1w"]["path"].is_file()
|
||||
|
||||
# asserts T1w_mask
|
||||
assert out["T1w_mask"]["path"].exists()
|
||||
|
||||
# asserts type "probseg_CSF"
|
||||
assert "probseg_CSF" in out
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
"""Create a testing dataset for the DataladAOMICID1000 pattern datagrabber."""
|
||||
|
||||
# Authors: Federico Raimondo <f.raimondo@fz-juelich.de>
|
||||
# Vera Komeyer <v.komeyer@fz-juelich.de>
|
||||
# Xuan Li <xu.li@fz-juelich.de>
|
||||
|
|
@ -8,7 +10,7 @@ from pathlib import Path
|
|||
import datalad.api as dl
|
||||
|
||||
# repo has to be created on gin manually beforehand if not owner
|
||||
dst = 'git@gin.g-node.org:/juaml/datalad-example-aomic1000.git'
|
||||
dst = "git@gin.g-node.org:/juaml/datalad-example-aomic1000.git"
|
||||
|
||||
# Use this if you create repo directly when pushing (see below)
|
||||
# dst_api = 'git@gin.g-node.org'
|
||||
|
|
@ -19,57 +21,81 @@ with TemporaryDirectory() as tmpdir_name:
|
|||
tmpdir = Path(tmpdir_name)
|
||||
ds = dl.create(tmpdir) # type: ignore
|
||||
|
||||
base_dir = tmpdir / 'derivatives'
|
||||
base_dir = tmpdir / "derivatives"
|
||||
base_dir.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
for dtype in ['dwipreproc', 'fmriprep']:
|
||||
for dtype in ["dwipreproc", "fmriprep"]:
|
||||
dtype_dir = base_dir / dtype
|
||||
dtype_dir.mkdir()
|
||||
|
||||
for i_sub in range(1, 10):
|
||||
t_sub = f'sub-{i_sub:04d}'
|
||||
t_sub = f"sub-{i_sub:04d}"
|
||||
sub_dir = dtype_dir / t_sub
|
||||
sub_dir.mkdir()
|
||||
|
||||
if dtype == 'fmriprep':
|
||||
for dname in ['func', 'anat']:
|
||||
if dtype == "fmriprep":
|
||||
for dname in ["func", "anat"]:
|
||||
(sub_dir / dname).mkdir()
|
||||
|
||||
fnames = [
|
||||
(f'anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc'
|
||||
'_T1w.nii.gz'),
|
||||
(f'anat/{t_sub}_space-MNI152NLin2009cAsym_label-'
|
||||
'CSF_probseg.nii.gz'),
|
||||
(f'anat/{t_sub}_space-MNI152NLin2009cAsym_label-'
|
||||
'GM_probseg.nii.gz'),
|
||||
(f'anat/{t_sub}_space-MNI152NLin2009cAsym_label-'
|
||||
'WM_probseg.nii.gz'),
|
||||
(f'func/{t_sub}_task-moviewatching_space-'
|
||||
'MNI152NLin2009cAsym_desc-preproc_bold.nii.gz'),
|
||||
(f'func/{t_sub}_task-moviewatching_space-'
|
||||
'MNI152NLin2009cAsym_desc-preproc_bold.json'),
|
||||
(f'func/{t_sub}_task-moviewatching_desc-confounds'
|
||||
'_regressors.tsv'),
|
||||
(f'func/{t_sub}_task-moviewatching_desc-confounds'
|
||||
'_regressors.json'),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc"
|
||||
"_T1w.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-"
|
||||
"CSF_probseg.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-"
|
||||
"GM_probseg.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-"
|
||||
"WM_probseg.nii.gz"
|
||||
),
|
||||
(
|
||||
f"func/{t_sub}_task-moviewatching_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
||||
),
|
||||
(
|
||||
f"func/{t_sub}_task-moviewatching_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.json"
|
||||
),
|
||||
(
|
||||
f"func/{t_sub}_task-moviewatching_desc-confounds"
|
||||
"_regressors.tsv"
|
||||
),
|
||||
(
|
||||
f"func/{t_sub}_task-moviewatching_desc-confounds"
|
||||
"_regressors.json"
|
||||
),
|
||||
(
|
||||
f"func/{t_sub}_task-moviewatching_"
|
||||
"space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
]
|
||||
|
||||
elif dtype == 'dwipreproc':
|
||||
dname = 'dwi'
|
||||
elif dtype == "dwipreproc":
|
||||
dname = "dwi"
|
||||
(sub_dir / dname).mkdir()
|
||||
|
||||
fnames = [
|
||||
(f'{dname}/{t_sub}_desc-preproc_dwi.nii.gz'),
|
||||
(f"{dname}/{t_sub}_desc-preproc_dwi.nii.gz"),
|
||||
]
|
||||
|
||||
for fname in fnames:
|
||||
with open(sub_dir / fname, 'w') as f:
|
||||
f.write('placeholder')
|
||||
with open(sub_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(
|
||||
# (org_name/repo_basename).as_posix(), name='gin', existing='reconfigure',
|
||||
# api=dst_api, access_protocol='ssh')
|
||||
ds.siblings('add', name='gin', url=dst)
|
||||
ds.push(to='gin', force='all')
|
||||
ds.siblings("add", name="gin", url=dst)
|
||||
ds.push(to="gin", force="all")
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ with TemporaryDirectory() as tmpdir_name:
|
|||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc"
|
||||
"_T1w.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_"
|
||||
"desc-brain_mask.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-"
|
||||
"CSF_probseg.nii.gz"
|
||||
|
|
@ -62,28 +66,24 @@ with TemporaryDirectory() as tmpdir_name:
|
|||
]
|
||||
for t in tasks:
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.json"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.json"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.tsv"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.json"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.tsv"
|
||||
)
|
||||
fnames.append(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.json"
|
||||
)
|
||||
|
||||
elif dtype == "dwipreproc":
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ with TemporaryDirectory() as tmpdir_name:
|
|||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_desc-preproc"
|
||||
"_T1w.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym"
|
||||
"_desc-brain_mask.nii.gz"
|
||||
),
|
||||
(
|
||||
f"anat/{t_sub}_space-MNI152NLin2009cAsym_label-"
|
||||
"CSF_probseg.nii.gz"
|
||||
|
|
@ -60,28 +64,24 @@ with TemporaryDirectory() as tmpdir_name:
|
|||
]
|
||||
for t in tasks:
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.json"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-preproc_bold.json"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.tsv"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_space-"
|
||||
"MNI152NLin2009cAsym_desc-brain_mask.nii.gz"
|
||||
)
|
||||
fnames.append(
|
||||
(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.json"
|
||||
)
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.tsv"
|
||||
)
|
||||
fnames.append(
|
||||
f"func/{t_sub}_task-{t}_desc-confounds"
|
||||
"_regressors.json"
|
||||
)
|
||||
|
||||
elif dtype == "dwipreproc":
|
||||
|
|
|
|||
Loading…
Reference in a new issue
Just to follow the naming convention: Add fMRIPrep ...
.at the end.