Skip to content

Commit 1718d8c

Browse files
authored
[MAINT] Update poetry lock (aramis-lab#1531)
* Update poetry lock * Nilearn:from Mesh to InMemoryMesh * Restrict pydra temporarily * Add antspy tests for instantiation and regression * Fix client test * Actually fix test client * Fix anat linear with antspynet * Fix client merge_tsv
1 parent 5dc7b3b commit 1718d8c

File tree

10 files changed

+2742
-1991
lines changed

10 files changed

+2742
-1991
lines changed

clinica/iotools/merge_tsv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ def merge_tsv(
5757
5858
ignore_session_scan_files : bool, optional
5959
"""
60-
from clinica.utils.inputs import check_bids_folder
60+
from clinica.dataset import check_bids_dataset
6161

6262
from .data_handling import create_merge_file
6363

64-
check_bids_folder(bids_directory)
64+
check_bids_dataset(bids_directory)
6565

6666
atlas_selection = []
6767
if volume_atlas_selection is not None:

clinica/pipelines/statistics_surface/surfstat/_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import numpy as np
99
import pandas as pd
10-
from nilearn.surface import Mesh
10+
from nilearn.surface import InMemoryMesh
1111

1212
TSV_FIRST_COLUMN = "participant_id"
1313
TSV_SECOND_COLUMN = "session_id"
@@ -116,15 +116,15 @@ def build_thickness_array(
116116
return thickness
117117

118118

119-
def get_average_surface(fsaverage_path: Path) -> Tuple[Dict, Mesh]:
119+
def get_average_surface(fsaverage_path: Path) -> Tuple[Dict, InMemoryMesh]:
120120
"""This function extracts the average surface and the average mesh
121121
from the path to the fsaverage templates.
122122
123123
.. note::
124124
125125
Note that the average surface is returned as a dictionary
126126
with 'coord' and 'tri' as keys, while the average mesh is
127-
returned as a Nilearn Mesh object (basically a NamedTuple
127+
returned as a Nilearn SurfaceMesh object (basically a NamedTuple
128128
with 'coordinates' and 'faces' attributes). The surface
129129
isn't returned as a Nilearn Surface object for compatibility
130130
with BrainStats.
@@ -145,12 +145,12 @@ def get_average_surface(fsaverage_path: Path) -> Tuple[Dict, Mesh]:
145145
average_surface : dict
146146
Average surface as a dictionary for BrainStat compatibility.
147147
148-
average_mesh : nilearn.surface.Mesh
149-
Average mesh as a Nilearn Mesh object.
148+
average_mesh : nilearn.surface.SurfaceMesh
149+
Average mesh as a Nilearn SurfaceMesh object.
150150
"""
151151
import copy
152152

153-
from nilearn.surface import Mesh, load_surf_mesh
153+
from nilearn.surface import InMemoryMesh, load_surf_mesh
154154

155155
meshes = [
156156
load_surf_mesh(str(fsaverage_path / f"{hemi}.pial")) for hemi in ("lh", "rh")
@@ -159,7 +159,7 @@ def get_average_surface(fsaverage_path: Path) -> Tuple[Dict, Mesh]:
159159
faces = np.vstack(
160160
[meshes[0].faces, meshes[1].faces + meshes[0].coordinates.shape[0]]
161161
)
162-
average_mesh = Mesh(
162+
average_mesh = InMemoryMesh(
163163
coordinates=coordinates,
164164
faces=copy.deepcopy(faces),
165165
)

clinica/pipelines/statistics_surface/surfstat/models/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pandas as pd
77
from brainstat.stats.SLM import SLM
88
from brainstat.stats.terms import FixedEffect
9-
from nilearn.surface import Mesh
9+
from nilearn.surface import InMemoryMesh
1010

1111
from clinica.utils.stream import cprint
1212

@@ -205,7 +205,7 @@ def plot_results(
205205
self,
206206
output_dir: Path,
207207
method: Union[str, List[str]],
208-
mesh: Mesh,
208+
mesh: InMemoryMesh,
209209
) -> None:
210210
"""Plot results to the provided directory.
211211
@@ -217,7 +217,7 @@ def plot_results(
217217
method : str or List[str]
218218
The method(s) to make the plots.
219219
220-
mesh : nilearn.surface.Mesh
220+
mesh : nilearn.surface.SurfaceMesh
221221
The mesh on which to plot the result data.
222222
"""
223223
if not self._is_fitted():

clinica/pipelines/statistics_surface/surfstat/models/results/_plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22
from typing import Callable
33

4-
from nilearn.surface import Mesh
4+
from nilearn.surface import InMemoryMesh
55

66
from ._statistics import StatisticsResults
77

@@ -16,11 +16,11 @@ class StatisticsResultsPlotter:
1616
output_file : PathLike
1717
Path to the output file.
1818
19-
mesh : nilearn.surface.Mesh
19+
mesh : nilearn.surface.SurfaceMesh
2020
The mesh to be used for plotting results.
2121
"""
2222

23-
def __init__(self, output_file: Path, mesh: Mesh):
23+
def __init__(self, output_file: Path, mesh: InMemoryMesh):
2424
self.output_file = output_file
2525
self.mesh = mesh
2626
self.plotting_extension = ".png"

clinica/pipelines/t1_linear/anat_linear_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _call_n4_bias_field_correction(
153153
verbose: bool = False,
154154
) -> Path:
155155
import ants
156-
from ants.utils.bias_correction import n4_bias_field_correction
156+
from ants.ops.bias_correction import n4_bias_field_correction
157157

158158
return n4_bias_field_correction(
159159
ants.image_read(str(input_image)),

poetry.lock

Lines changed: 2698 additions & 1968 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies = [
5454
"openpyxl",
5555
"fsspec",
5656
"pydra-nipype1",
57-
"pydra (>=0.22,<1.0)",
57+
"pydra (>=0.22,<0.23)",
5858
"pybids (>=0.16,<1.0)",
5959
"joblib (>=1.2.0,<2.0)",
6060
"attrs (>=20.1.0)",

test/instantiation/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_first_lv(generate_cli_first_lv):
2424
runner = CliRunner()
2525
cli_input = generate_cli_first_lv
2626
print(f"Testing input cli {cli_input}")
27-
result = runner.invoke(cli, cli_input)
27+
result = runner.invoke(cli, cli_input + " -h")
2828
assert result.exit_code == 0
2929

3030

test/instantiation/test_instantiate_all_pipelines.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def test_instantiate_t1_freesurfer_longitudinal_correction(cmdopt, tmp_path):
468468
).build()
469469

470470

471-
def test_instantiate_t1_linear(cmdopt, tmp_path):
471+
def test_instantiate_t1_linear_ants(cmdopt, tmp_path):
472472
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear
473473

474474
base_dir = Path(cmdopt["input"])
@@ -484,6 +484,22 @@ def test_instantiate_t1_linear(cmdopt, tmp_path):
484484
).build()
485485

486486

487+
def test_instantiate_t1_linear_antspy(cmdopt, tmp_path):
488+
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear
489+
490+
base_dir = Path(cmdopt["input"])
491+
working_dir = Path(cmdopt["wd"])
492+
input_dir, tmp_dir, ref_dir = configure_paths(base_dir, tmp_path, "T1Linear")
493+
AnatLinear(
494+
bids_directory=fspath(input_dir / "bids"),
495+
caps_directory=fspath(tmp_dir / "caps"),
496+
tsv_file=fspath(input_dir / "subjects.tsv"),
497+
base_dir=fspath(working_dir),
498+
name="t1-linear",
499+
parameters={"uncropped_image": False, "use_antspy": True},
500+
).build()
501+
502+
487503
def test_instantiate_statistics_volume(cmdopt, tmp_path):
488504
from clinica.pipelines.statistics_volume.statistics_volume_pipeline import (
489505
StatisticsVolume,

test/nonregression/pipelines/anat/test_t1_linear.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111

1212
@pytest.mark.fast
13-
def test_t1_linear(cmdopt, tmp_path):
13+
@pytest.mark.parametrize("antspy", (False, True))
14+
def test_t1_linear(cmdopt, tmp_path, antspy):
1415
base_dir = Path(cmdopt["input"])
1516
working_dir = Path(cmdopt["wd"])
1617
input_dir, tmp_dir, ref_dir = configure_paths(base_dir, tmp_path, "T1Linear")
17-
run_t1_linear(input_dir, tmp_dir, ref_dir, working_dir)
18+
run_t1_linear(input_dir, tmp_dir, ref_dir, working_dir, antspy)
1819

1920

2021
@pytest.mark.fast
@@ -26,7 +27,11 @@ def test_flair_linear(cmdopt, tmp_path):
2627

2728

2829
def run_t1_linear(
29-
input_dir: Path, output_dir: Path, ref_dir: Path, working_dir: Path
30+
input_dir: Path,
31+
output_dir: Path,
32+
ref_dir: Path,
33+
working_dir: Path,
34+
antspy: bool = False,
3035
) -> None:
3136
from clinica.pipelines.t1_linear.anat_linear_pipeline import AnatLinear
3237

@@ -38,7 +43,7 @@ def run_t1_linear(
3843
caps_directory=fspath(out_caps),
3944
tsv_file=fspath(input_dir / "subjects.tsv"),
4045
base_dir=fspath(working_dir),
41-
parameters={"uncropped_image": False},
46+
parameters={"uncropped_image": False, "use_antspy": antspy},
4247
name="t1-linear",
4348
)
4449
pipeline.run(plugin="MultiProc", plugin_args={"n_procs": 4}, bypass_check=True)

0 commit comments

Comments
 (0)