Skip to content

Commit f413e89

Browse files
authored
Merge pull request #175 from 36000/python313
Python 3.13
2 parents 0a78e2c + b64526d commit f413e89

19 files changed

Lines changed: 391 additions & 613 deletions

.github/workflows/docbuild.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ["3.12"]
17+
python-version: ["3.13"]
1818

1919
steps:
2020
- name: Checkout repo
@@ -33,13 +33,16 @@ jobs:
3333
run: |
3434
python -m pip install --upgrade pip
3535
pip install .[all]
36-
sudo apt-get install -y xvfb
36+
sudo apt-get install -y \
37+
libgl1 \
38+
libglx-mesa0 \
39+
libegl1 \
40+
libgl1-mesa-dri \
41+
libvulkan1 \
42+
mesa-vulkan-drivers \
43+
vulkan-tools
3744
- name: Build docs
38-
env:
39-
XVFB: 1
40-
DISPLAY: :99
4145
run: |
42-
Xvfb :99 -screen 0 1280x1024x24 &
4346
cd docs
4447
make html
4548
- name: Upload docs

.github/workflows/nightly_anisotropic_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo

.github/workflows/nightly_basic_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo

.github/workflows/nightly_custom_test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo
@@ -28,10 +28,17 @@ jobs:
2828
run: |
2929
python -m pip install --upgrade pip
3030
pip install .[dev,fury,afqbrowser,nn]
31+
sudo apt-get install -y \
32+
libgl1 \
33+
libglx-mesa0 \
34+
libegl1 \
35+
libgl1-mesa-dri \
36+
libvulkan1 \
37+
mesa-vulkan-drivers \
38+
vulkan-tools
3139
- name: Lint
3240
run: |
3341
flake8 --ignore N802,N806,W503 --select W504 `find . -name \*.py | grep -v setup.py | grep -v version.py | grep -v __init__.py | grep -v /docs/`
3442
- name: Test
3543
run: |
36-
export TEST_WITH_XVFB=true
3744
cd && mkdir for_test && cd for_test && pytest --pyargs AFQ --cov-report term-missing --cov=AFQ -m "nightly_custom" --durations=0

.github/workflows/nightly_reco80_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo

.github/workflows/nightly_reco_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo

.github/workflows/nightly_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ["3.12"]
14+
python-version: ["3.13"]
1515

1616
steps:
1717
- name: Checkout repo

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
max-parallel: 4
1515
matrix:
16-
python-version: ["3.10", "3.11", "3.12"]
16+
python-version: ["3.11", "3.12", "3.13"]
1717
nibabel-pre: [true, false]
1818

1919
steps:

AFQ/_fixes.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import logging
22
import math
3+
import tempfile
4+
from math import radians
35

46
import numpy as np
57
from dipy.data import default_sphere
68
from dipy.reconst.gqi import squared_radial_component
79
from dipy.tracking.streamline import set_number_of_points
10+
from PIL import Image
811
from scipy.linalg import blas, pinvh
912
from scipy.special import gammaln, lpmv
1013
from tqdm import tqdm
@@ -238,3 +241,44 @@ def gaussian_weights(bundle, n_points=100, return_mahalnobis=False, stat=np.mean
238241
weights = 1 / weights
239242
# Normalize before returning, so that the weights in each node sum to 1:
240243
return weights / np.sum(weights, 0)
244+
245+
246+
def make_gif(show_m, out_path, n_frames=36, az_ang=-10):
247+
"""
248+
Make a video from a Fury Show Manager.
249+
250+
Parameters
251+
----------
252+
show_m : Fury Show Manager
253+
The Fury Show Manager to use for rendering.
254+
255+
out_path : str
256+
The name of the output file.
257+
258+
n_frames : int
259+
The number of frames to render.
260+
Default: 36
261+
262+
az_ang : float
263+
The angle to rotate the camera around the
264+
z-axis for each frame, in degrees.
265+
Default: -10
266+
"""
267+
video = []
268+
269+
show_m.render()
270+
show_m.window.draw()
271+
272+
with tempfile.TemporaryDirectory() as tmp_dir:
273+
for ii in tqdm(range(n_frames), desc="Generating GIF"):
274+
frame_fname = f"{tmp_dir}/{ii}.png"
275+
show_m.screens[0].controller.rotate((radians(az_ang), 0), None)
276+
show_m.render()
277+
show_m.window.draw()
278+
show_m.snapshot(frame_fname)
279+
video.append(frame_fname)
280+
281+
video = [Image.open(frame) for frame in video]
282+
video[0].save(
283+
out_path, save_all=True, append_images=video[1:], duration=300, loop=1
284+
)

AFQ/api/group.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ def group_montage(self, bundle_name, size, view, direc, slice_pos=None):
836836

837837
t1_dict = self.export("t1_masked", collapse=False)
838838
viz_backend_dict = self.export("viz_backend", collapse=False)
839-
b0_backend_dict = self.export("b0", collapse=False)
840839
dwi_affine_dict = self.export("dwi_affine", collapse=False)
841840
bundles_dict = self.export("bundles", collapse=False)
842841
best_scalar_dict = self.export(best_scalar, collapse=False)
@@ -847,7 +846,6 @@ def group_montage(self, bundle_name, size, view, direc, slice_pos=None):
847846
this_sub = self.valid_sub_list[ii]
848847
this_ses = self.valid_ses_list[ii]
849848
viz_backend = viz_backend_dict[this_sub][this_ses]
850-
b0 = b0_backend_dict[this_sub][this_ses]
851849
t1 = nib.load(t1_dict[this_sub][this_ses])
852850
dwi_affine = dwi_affine_dict[this_sub][this_ses]
853851
bundles = bundles_dict[this_sub][this_ses]
@@ -913,17 +911,15 @@ def group_montage(self, bundle_name, size, view, direc, slice_pos=None):
913911

914912
pio.kaleido.scope._shutdown_kaleido()
915913
else:
916-
from dipy.viz import window
917-
918-
direc = np.fromiter(eye.values(), dtype=int)
919-
data_shape = np.asarray(nib.load(b0).get_fdata().shape)
920-
figure.set_camera(
921-
position=direc * data_shape,
922-
focal_point=data_shape // 2,
923-
view_up=(0, 0, 1),
914+
from fury import window
915+
916+
from AFQ.viz.fury_backend import scene_rotate_forward
917+
918+
show_m = window.ShowManager(
919+
scene=figure, window_type="offscreen", size=(600, 600)
924920
)
925-
figure.zoom(0.5)
926-
window.snapshot(figure, fname=this_fname, size=(600, 600))
921+
scene_rotate_forward(show_m, figure)
922+
show_m.snapshot(this_fname)
927923

928924
def _save_file(curr_img, curr_file_num):
929925
save_path = op.abspath(

0 commit comments

Comments
 (0)