Skip to content

Commit

Permalink
Merge pull request #158 from jhlegarreta/FixNilearnNiftiWarning
Browse files Browse the repository at this point in the history
ENH: Copy NIfTI image header when creating from image
  • Loading branch information
effigies authored Jan 9, 2025
2 parents 8255be0 + 7447d39 commit a6bcd48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nireports/assembler/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def __init__(
}
meta_repl.update({kk: vv for kk, vv in metadata.items() if isinstance(vv, str)})
meta_repl.update(bids_filters)
expr = re.compile(f'{{({"|".join(meta_repl.keys())})}}')
expr = re.compile(f"{{({'|'.join(meta_repl.keys())})}}")

for line in bootstrap_file.read_text().splitlines(keepends=False):
if expr.search(line):
Expand Down
2 changes: 1 addition & 1 deletion nireports/reportlets/modality/dwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def plot_dwi(dataobj, affine, gradient=None, **kwargs):
if gradient is None
else f"""\
$b$={gradient[3].astype(int)}, \
$\\vec{{b}}$ = ({', '.join(str(v) for v in gradient[:3])})"""
$\\vec{{b}}$ = ({", ".join(str(v) for v in gradient[:3])})"""
),
**kwargs,
)
Expand Down
7 changes: 6 additions & 1 deletion nireports/reportlets/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
import nibabel as nb
import nilearn
import numpy as np
import numpy.typing as npt
from matplotlib.gridspec import GridSpec
from nibabel.spatialimages import SpatialImage
from nilearn import image as nlimage
from nilearn.plotting import plot_anat
from packaging.version import Version
from svgutils.transform import SVGFigure, fromstring

from nireports.reportlets.utils import (
Expand Down Expand Up @@ -89,7 +91,10 @@ def plot_segs(
)

if masked:
bbox_nii: SpatialImage = nlimage.threshold_img(bbox_nii, 1e-3) # type: ignore[no-redef]
if Version(nilearn.__version__) >= Version("0.11"):
bbox_nii: SpatialImage = nlimage.threshold_img(bbox_nii, 1e-3, copy_header=True) # type: ignore[no-redef]
else:
bbox_nii: SpatialImage = nlimage.threshold_img(bbox_nii, 1e-3) # type: ignore[no-redef]

cuts = cuts_from_bbox(bbox_nii, cuts=7)
out_files = []
Expand Down

0 comments on commit a6bcd48

Please sign in to comment.