|
20 | 20 |
|
21 | 21 | from nipype.utils import filemanip |
22 | 22 | from .. import NIWORKFLOWS_LOG |
| 23 | +from ..utils.images import rotation2canonical, rotate_affine |
23 | 24 |
|
24 | 25 |
|
25 | 26 | SVGNS = "http://www.w3.org/2000/svg" |
@@ -216,19 +217,29 @@ def plot_segs( |
216 | 217 | compress="auto", |
217 | 218 | **plot_params |
218 | 219 | ): |
219 | | - """ plot segmentation as contours over the image (e.g. anatomical). |
| 220 | + """ |
| 221 | + Generate a static mosaic with ROIs represented by their delimiting contour. |
| 222 | +
|
| 223 | + Plot segmentation as contours over the image (e.g. anatomical). |
220 | 224 | seg_niis should be a list of files. mask_nii helps determine the cut |
221 | 225 | coordinates. plot_params will be passed on to nilearn plot_* functions. If |
222 | 226 | seg_niis is a list of size one, it behaves as if it was plotting the mask. |
223 | 227 | """ |
224 | 228 | plot_params = {} if plot_params is None else plot_params |
225 | 229 |
|
226 | 230 | image_nii = _3d_in_file(image_nii) |
| 231 | + canonical_r = rotation2canonical(image_nii) |
| 232 | + image_nii = rotate_affine(image_nii, rot=canonical_r) |
| 233 | + seg_niis = [rotate_affine(_3d_in_file(f), rot=canonical_r) for f in seg_niis] |
227 | 234 | data = image_nii.get_fdata() |
228 | 235 |
|
229 | 236 | plot_params = robust_set_limits(data, plot_params) |
230 | 237 |
|
231 | | - bbox_nii = nb.load(image_nii if bbox_nii is None else bbox_nii) |
| 238 | + bbox_nii = ( |
| 239 | + image_nii if bbox_nii is None |
| 240 | + else rotate_affine(_3d_in_file(bbox_nii), rot=canonical_r) |
| 241 | + ) |
| 242 | + |
232 | 243 | if masked: |
233 | 244 | bbox_nii = nlimage.threshold_img(bbox_nii, 1e-3) |
234 | 245 |
|
|
0 commit comments