[MAINT]: Bump junifer-data version to v7 #486
9 changed files with 236 additions and 13 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -54,8 +54,8 @@ jobs:
|
|||
jq
|
||||
- name: Copy junifer-data directory
|
||||
run: |
|
||||
mkdir -p $HOME/junifer_data/v4
|
||||
cp -ar /root/junifer_data/v4/. $HOME/junifer_data/v4/
|
||||
mkdir -p $HOME/junifer_data/v7
|
||||
cp -ar /root/junifer_data/v7/. $HOME/junifer_data/v7/
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
|
|
|
|||
4
.github/workflows/docs-preview.yml
vendored
4
.github/workflows/docs-preview.yml
vendored
|
|
@ -40,8 +40,8 @@ jobs:
|
|||
jq
|
||||
- name: Copy junifer-data directory
|
||||
run: |
|
||||
mkdir -p $HOME/junifer_data/v4
|
||||
cp -ar /root/junifer_data/v4/. $HOME/junifer_data/v4/
|
||||
mkdir -p $HOME/junifer_data/v7
|
||||
cp -ar /root/junifer_data/v7/. $HOME/junifer_data/v7/
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
|
|
|
|||
4
.github/workflows/docs.yml
vendored
4
.github/workflows/docs.yml
vendored
|
|
@ -31,8 +31,8 @@ jobs:
|
|||
jq
|
||||
- name: Copy junifer-data directory
|
||||
run: |
|
||||
mkdir -p $HOME/junifer_data/v4
|
||||
cp -ar /root/junifer_data/v4/. $HOME/junifer_data/v4/
|
||||
mkdir -p $HOME/junifer_data/v7
|
||||
cp -ar /root/junifer_data/v7/. $HOME/junifer_data/v7/
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -463,6 +463,24 @@ Available
|
|||
| structures in the human brain.
|
||||
| Neuron., Volume 33(3), Pages 341-355 (2002).
|
||||
| https://doi:10.1016/s0896-6273(02)00569-x
|
||||
* - Glasser
|
||||
- None
|
||||
- ``Glasser``
|
||||
- ``MNI152NLin2009cAsym``
|
||||
- 0.0.7
|
||||
- | Glasser, M.F., Coalson, T.S., Robinson, E.C. et al.
|
||||
| A multi-modal parcellation of human cerebral cortex.
|
||||
| Nature (2016).
|
||||
| http://doi.org/10.1038/nature18933
|
||||
* - Julich-Brain
|
||||
- ``version``
|
||||
- ``Julich-Brain_V1_18``, ``Julich-Brain_V2_9``, ``Julich-Brain_V3_0_3``, ``Julich-Brain_V3_1``
|
||||
- ``MNI152NLin2009cAsym``
|
||||
- 0.0.7
|
||||
- | Amunts, K. et al.
|
||||
| Julich-Brain: A 3D probabilistic atlas of the human brain’s cytoarchitecture.
|
||||
| Science, 369, 988-992 (2020)
|
||||
| https://doi.org/10.1126/science.abb4588
|
||||
|
||||
|
||||
Planned
|
||||
|
|
@ -480,11 +498,6 @@ Planned
|
|||
| on MRI scans into gyral based regions of interest.
|
||||
| NeuroImage, Volume 31(3), Pages 968-980 (2006).
|
||||
| http://doi.org/10.1016/j.neuroimage.2006.01.021
|
||||
* - Glasser
|
||||
- | Glasser, M.F., Coalson, T.S., Robinson, E.C. et al.
|
||||
| A multi-modal parcellation of human cerebral cortex.
|
||||
| Nature (2016).
|
||||
| http://doi.org/10.1038/nature18933
|
||||
* - AAL
|
||||
- | Rolls, E.T., Huang, C.C., Lin, C.P., et al.
|
||||
| Automated anatomical labelling atlas 3.
|
||||
|
|
|
|||
1
docs/changes/newsfragments/486.enh
Normal file
1
docs/changes/newsfragments/486.enh
Normal file
|
|
@ -0,0 +1 @@
|
|||
Add Glasser and Julich-Brain parcellations to :class:`.ParcellationRegistry` by `Synchon Mandal`_
|
||||
1
docs/changes/newsfragments/486.misc
Normal file
1
docs/changes/newsfragments/486.misc
Normal file
|
|
@ -0,0 +1 @@
|
|||
Bump ``junifer-data`` to ``v7`` by `Synchon Mandal`_
|
||||
|
|
@ -199,6 +199,26 @@ class ParcellationRegistry(BasePipelineDataRegistry):
|
|||
}
|
||||
}
|
||||
)
|
||||
# Add Glasser
|
||||
self._builtin.update(
|
||||
{
|
||||
"Glasser": {
|
||||
"family": "Glasser",
|
||||
"space": "MNI152NLin2009cAsym",
|
||||
}
|
||||
}
|
||||
)
|
||||
# Add Julich-Brain
|
||||
for v in ["V1_18", "V2_9", "V3_0_3", "V3_1"]:
|
||||
self._builtin.update(
|
||||
{
|
||||
f"Julich-Brain_{v}": {
|
||||
"family": "Julich-Brain",
|
||||
"version": v,
|
||||
"space": "MNI152NLin2009cAsym",
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
# Update registry with built-in ones
|
||||
self._registry.update(self._builtin)
|
||||
|
|
@ -365,6 +385,8 @@ class ParcellationRegistry(BasePipelineDataRegistry):
|
|||
"Yan2023",
|
||||
"Brainnetome",
|
||||
"FreeSurfer",
|
||||
"Glasser",
|
||||
"Julich-Brain",
|
||||
]:
|
||||
# Load parcellation and labels
|
||||
if t_family == "Schaefer2018":
|
||||
|
|
@ -408,6 +430,17 @@ class ParcellationRegistry(BasePipelineDataRegistry):
|
|||
parcellation_fname, parcellation_labels = _retrieve_aseg(
|
||||
resolution=resolution,
|
||||
)
|
||||
elif t_family == "Glasser":
|
||||
parcellation_fname, parcellation_labels = _retrieve_glasser(
|
||||
resolution=resolution,
|
||||
)
|
||||
elif t_family == "Julich-Brain":
|
||||
parcellation_fname, parcellation_labels = (
|
||||
_retrieve_julich_brain(
|
||||
resolution=resolution,
|
||||
**parcellation_definition,
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise_error(f"Unknown parcellation family: {t_family}")
|
||||
|
||||
|
|
@ -1421,6 +1454,111 @@ def _retrieve_aseg(
|
|||
return parcellation_img_path, labels
|
||||
|
||||
|
||||
def _retrieve_glasser(
|
||||
resolution: Optional[float] = None,
|
||||
) -> tuple[Path, list[str]]:
|
||||
"""Retrieve Glasser v1.0 .
|
||||
|
||||
Parameters
|
||||
----------
|
||||
resolution : 1.0, optional
|
||||
The desired resolution of the parcellation to load. If it is not
|
||||
available, the closest resolution will be loaded. Preferably, use a
|
||||
resolution higher than the desired one. By default, will load the
|
||||
highest one (default None). Available resolution for this
|
||||
parcellation is 1mm.
|
||||
|
||||
Returns
|
||||
-------
|
||||
pathlib.Path
|
||||
File path to the parcellation image.
|
||||
list of str
|
||||
Parcellation labels.
|
||||
|
||||
"""
|
||||
logger.info("Parcellation parameters:")
|
||||
logger.info(f"\tresolution: {resolution}")
|
||||
|
||||
_valid_resolutions = [1.0]
|
||||
_ = closest_resolution(resolution, _valid_resolutions)
|
||||
|
||||
path_prefix = Path("parcellations/Glasser/2021")
|
||||
parcellation_img_path = get(
|
||||
file_path=path_prefix / "MNI_Glasser_HCP_v1.0.nii.gz",
|
||||
dataset_path=get_dataset_path(),
|
||||
**JUNIFER_DATA_PARAMS,
|
||||
)
|
||||
parcellation_label_path = get(
|
||||
file_path=path_prefix / "labels.csv",
|
||||
dataset_path=get_dataset_path(),
|
||||
**JUNIFER_DATA_PARAMS,
|
||||
)
|
||||
labels = pd.read_csv(parcellation_label_path, sep=",")["label"].to_list()
|
||||
|
||||
return parcellation_img_path, labels
|
||||
|
||||
|
||||
def _retrieve_julich_brain(
|
||||
resolution: Optional[float] = None,
|
||||
version: str = "v3_1",
|
||||
) -> tuple[Path, list[str]]:
|
||||
"""Retrieve Julich-Brain labelled parcellations.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
resolution : 1.0, optional
|
||||
The desired resolution of the parcellation to load. If it is not
|
||||
available, the closest resolution will be loaded. Preferably, use a
|
||||
resolution higher than the desired one. By default, will load the
|
||||
highest one (default None). Available resolution for this
|
||||
parcellation is 1mm.
|
||||
version : {"V1_18", "V2_9", "V3_0_3", "V3_1"}, optional
|
||||
The version of the parcellation to use (default "V3_1").
|
||||
|
||||
Returns
|
||||
-------
|
||||
pathlib.Path
|
||||
File path to the parcellation image.
|
||||
list of str
|
||||
Parcellation labels.
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If invalid value is provided for ``version``.
|
||||
|
||||
"""
|
||||
logger.info("Parcellation parameters:")
|
||||
logger.info(f"\tresolution: {resolution}")
|
||||
logger.info(f"\tversion: {version}")
|
||||
|
||||
# Check version
|
||||
_valid_version = ["V1_18", "V2_9", "V3_0_3", "V3_1"]
|
||||
if version not in _valid_version:
|
||||
raise_error(
|
||||
f"The parameter `version` ({version}) needs to be one of the "
|
||||
f"following: {_valid_version}"
|
||||
)
|
||||
|
||||
_valid_resolutions = [1.0]
|
||||
_ = closest_resolution(resolution, _valid_resolutions)
|
||||
|
||||
path_prefix = Path(f"parcellations/Julich-Brain/{version}")
|
||||
parcellation_img_path = get(
|
||||
file_path=path_prefix / "labelled.nii.gz",
|
||||
dataset_path=get_dataset_path(),
|
||||
**JUNIFER_DATA_PARAMS,
|
||||
)
|
||||
parcellation_label_path = get(
|
||||
file_path=path_prefix / "labels.csv",
|
||||
dataset_path=get_dataset_path(),
|
||||
**JUNIFER_DATA_PARAMS,
|
||||
)
|
||||
labels = pd.read_csv(parcellation_label_path, sep=",")["label"].to_list()
|
||||
|
||||
return parcellation_img_path, labels
|
||||
|
||||
|
||||
def merge_parcellations(
|
||||
parcellations_list: list["Nifti1Image"],
|
||||
parcellations_names: list[str],
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ from junifer.data.parcellations import merge_parcellations
|
|||
from junifer.data.parcellations._parcellations import (
|
||||
_retrieve_aicha,
|
||||
_retrieve_brainnetome,
|
||||
_retrieve_julich_brain,
|
||||
_retrieve_schaefer,
|
||||
_retrieve_shen,
|
||||
_retrieve_suit,
|
||||
|
|
@ -962,6 +963,75 @@ def test_aseg() -> None:
|
|||
)
|
||||
|
||||
|
||||
def test_glasser() -> None:
|
||||
"""Test Glasser parcellation."""
|
||||
parcellations = list_data(kind="parcellation")
|
||||
assert "Glasser" in parcellations
|
||||
|
||||
# Load parcellation
|
||||
img, label, img_path, space = load_data(
|
||||
kind="parcellation",
|
||||
name="Glasser",
|
||||
target_space="MNI152NLin2009cAsym",
|
||||
)
|
||||
assert img is not None
|
||||
assert img_path.name == "MNI_Glasser_HCP_v1.0.nii.gz"
|
||||
assert space == "MNI152NLin2009cAsym"
|
||||
assert len(label) == 360
|
||||
assert_array_equal(
|
||||
img.header["pixdim"][1:4],
|
||||
3 * [1],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"version, rois",
|
||||
[
|
||||
("V1_18", 202),
|
||||
("V2_9", 294),
|
||||
("V3_0_3", 314),
|
||||
("V3_1", 414),
|
||||
],
|
||||
)
|
||||
def test_julich_brain(version: str, rois: int) -> None:
|
||||
"""Test Julich-Brain parcellation.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
version : str
|
||||
The parametrized version.
|
||||
rois : int
|
||||
The parametrized # of ROIs.
|
||||
|
||||
"""
|
||||
parcellations = list_data(kind="parcellation")
|
||||
n = f"Julich-Brain_{version}"
|
||||
assert n in parcellations
|
||||
|
||||
# Load parcellation
|
||||
img, label, img_path, space = load_data(
|
||||
kind="parcellation",
|
||||
name=n,
|
||||
target_space="MNI152NLin2009cAsym",
|
||||
)
|
||||
assert img is not None
|
||||
assert img_path.name == "labelled.nii.gz"
|
||||
assert space == "MNI152NLin2009cAsym"
|
||||
assert len(label) == rois
|
||||
assert_array_equal(
|
||||
img.header["pixdim"][1:4],
|
||||
3 * [1],
|
||||
)
|
||||
|
||||
|
||||
def test_retrieve_julich_brain_incorrect_version() -> None:
|
||||
"""Test retrieve Julich-Brain with incorrect version."""
|
||||
with pytest.raises(ValueError, match=r"The parameter `version`"):
|
||||
_retrieve_julich_brain(
|
||||
version="v0",
|
||||
)
|
||||
|
||||
|
||||
def test_merge_parcellations() -> None:
|
||||
"""Test merging parcellations."""
|
||||
# load some parcellations for testing
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ __all__ = [
|
|||
|
||||
|
||||
# junifer-data version constant
|
||||
JUNIFER_DATA_VERSION = "5"
|
||||
JUNIFER_DATA_VERSION = "7"
|
||||
|
||||
# junifer-data hexsha constant
|
||||
JUNIFER_DATA_HEXSHA = "62a0e3d187259a3c3ba7be638ee39cfb40df0a61"
|
||||
JUNIFER_DATA_HEXSHA = "f5144e6fef7d6f4f26508c3653d94a622f10207c"
|
||||
|
||||
JUNIFER_DATA_PARAMS = {
|
||||
"tag": JUNIFER_DATA_VERSION,
|
||||
|
|
|
|||
Loading…
Reference in a new issue