Skip to content

Commit

Permalink
Fix: pacify flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Marabotto authored and Julien Marabotto committed Jul 15, 2024
1 parent 30e1967 commit 6a1eb59
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 112 deletions.
36 changes: 19 additions & 17 deletions nitransforms/tests/test_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@


def test_read_path(data_path):
"""Check that filepaths are a supported method for loading and reading transforms with PlotDenseField"""
PlotDenseField(transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz")
"Check that filepaths are a supported method for loading "
"and reading transforms with PlotDenseField"
PlotDenseField(transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz")


def test_slice_values():
Expand All @@ -24,7 +25,7 @@ def test_slice_values():
zslice=-1,
)

"""Check that IndexError is issued if provided slices are beyond range of transform dimensions"""
"Check that IndexError is issued if provided slices are beyond range of transform dimensions"
with pytest.raises(IndexError):
xfm = DenseFieldTransform(
field=np.zeros((10, 10, 10, 3)),
Expand All @@ -34,46 +35,46 @@ def test_slice_values():
transform=xfm._field,
reference=xfm._reference,
).test_slices(
xslice=xfm._field.shape[0]+1,
yslice=xfm._field.shape[1]+1,
zslice=xfm._field.shape[2]+1,
xslice=xfm._field.shape[0] + 1,
yslice=xfm._field.shape[1] + 1,
zslice=xfm._field.shape[2] + 1,
)


def test_show_transform(data_path, output_path):
PlotDenseField(
transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
).show_transform(
xslice=50,
yslice=50,
zslice=50,
)
if output_path is not None:
plt.savefig(output_path / "show_transform.svg", bbox_inches="tight")
plt.savefig(output_path/"show_transform.svg", bbox_inches="tight")
else:
plt.show()


def test_plot_distortion(data_path, output_path):
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
PlotDenseField(
transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
).plot_distortion(
axes=axes,
xslice=50,
yslice=50,
zslice=50,
)
if output_path is not None:
plt.savefig(output_path / "plot_distortion.svg", bbox_inches="tight")
plt.savefig(output_path/"plot_distortion.svg", bbox_inches="tight")
else:
plt.show()


def test_plot_quiverdsm(data_path, output_path):
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
PlotDenseField(
transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
).plot_quiverdsm(
axes=axes,
xslice=50,
Expand All @@ -82,7 +83,7 @@ def test_plot_quiverdsm(data_path, output_path):
)

if output_path is not None:
plt.savefig(output_path / "plot_quiverdsm.svg", bbox_inches="tight")
plt.savefig(output_path/"plot_quiverdsm.svg", bbox_inches="tight")
else:
plt.show()

Expand All @@ -92,7 +93,7 @@ def test_3dquiver(data_path, output_path):
fig = plt.figure()
axes = fig.add_subplot(projection='3d')
PlotDenseField(
transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz",
transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz",
).plot_quiverdsm(
axes=axes,
xslice=None,
Expand All @@ -102,15 +103,15 @@ def test_3dquiver(data_path, output_path):
)

if output_path is not None:
plt.savefig(output_path / "plot_3dquiver.svg", bbox_inches="tight")
plt.savefig(output_path/"plot_3dquiver.svg", bbox_inches="tight")
else:
plt.show()


def test_plot_jacobian(data_path, output_path):
fig, axes = plt.subplots(1, 3, figsize=(12, 5))
PlotDenseField(
transform = data_path / "ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
transform = data_path/"ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz"
).plot_jacobian(
axes=axes,
xslice=50,
Expand All @@ -119,9 +120,10 @@ def test_plot_jacobian(data_path, output_path):
)

if output_path is not None:
plt.savefig(output_path / "plot_jacobian.svg", bbox_inches="tight")
plt.savefig(output_path/"plot_jacobian.svg", bbox_inches="tight")
else:
plt.show()


if __name__ == "__main__":
pytest.main([__file__])
Loading

0 comments on commit 6a1eb59

Please sign in to comment.