Add plotting layer to surface(s) Parameters ---------- data : str or os.PathLike, numpy.ndarray, dict, nibabel.gifti.gifti.GiftiImage, or nibabel.cifti2.cifti2.Cifti2Image Vertex data to plot on surfaces. Must be a valid file path of a GIFTI or CIFTI
(self, data, cmap='viridis', alpha=1, color_range=None,
as_outline=False, zero_transparent=True, cbar=True,
cbar_label=None)
| 253 | self.add_layer(backdrop, 'Greys_r', color_range=(0, 1), cbar=False) |
| 254 | |
| 255 | def add_layer(self, data, cmap='viridis', alpha=1, color_range=None, |
| 256 | as_outline=False, zero_transparent=True, cbar=True, |
| 257 | cbar_label=None): |
| 258 | """Add plotting layer to surface(s) |
| 259 | |
| 260 | Parameters |
| 261 | ---------- |
| 262 | data : str or os.PathLike, numpy.ndarray, dict, nibabel.gifti.gifti.GiftiImage, or nibabel.cifti2.cifti2.Cifti2Image |
| 263 | Vertex data to plot on surfaces. Must be a valid file path of a |
| 264 | GIFTI or CIFTI image, a loaded GIFTI or CIFTI image, a numpy array |
| 265 | with length equal to the total number of vertices in the provided |
| 266 | surfaces (e.g., 32k in left surface + 32k in right surface = 64k |
| 267 | total), or a dictionary with 'left' and/or 'right keys. |
| 268 | If a numpy array, vertices are assumed to be in order of |
| 269 | left-to-right, if applicable. If a dictionary, then values can be |
| 270 | any of the possible types mentioned above, assuming that the |
| 271 | vertices match the vertices of their respective surface. |
| 272 | cmap : matplotlib colormap name or object, optional |
| 273 | Colormap to use for data, default: 'viridis' |
| 274 | alpha : float, optional |
| 275 | Colormap opacity (0 to 1). Default: 1 |
| 276 | color_range : tuple[float, float], optional |
| 277 | Minimum and maximum value for color map. If None, then the minimum |
| 278 | and maximum values in `data` are used. Default: None |
| 279 | as_outline : bool, optional |
| 280 | Plot only an outline of contiguous vertices with the same value. |
| 281 | Useful if plotting regions of interests, atlases, or discretized |
| 282 | data. Not recommended for continous data. Default: False |
| 283 | zero_transparent : bool, optional |
| 284 | Set vertices with value of 0 to NaN, which will turn them |
| 285 | transparent on the surface. Useful when value of 0 has no |
| 286 | importance (e.g., thresholded data, an atlas). Default: True |
| 287 | cbar : bool, optional |
| 288 | Show colorbar for layer, default: True |
| 289 | cbar_label : str, optional |
| 290 | Label to include with colorbar if shown. Note that this is not |
| 291 | required for the colorbar to be drawn. Default: None |
| 292 | |
| 293 | Raises |
| 294 | ------ |
| 295 | ValueError |
| 296 | `data` keys must be 'left' and/or 'right' |
| 297 | TypeError |
| 298 | `data` is neither an instance of str or os.PathLike, numpy.ndarray, |
| 299 | dict, nibabel.gifti.gifti.GiftiImage, or |
| 300 | nibabel.cifti2.cifti2.Cifti2Image |
| 301 | """ |
| 302 | # let the name just be the layer number |
| 303 | name = str(len(self.layers)) |
| 304 | |
| 305 | valid_types = (np.ndarray, str, pathlib.PosixPath, nib.GiftiImage, |
| 306 | nib.Cifti2Image) |
| 307 | if isinstance(data, valid_types): |
| 308 | data = _check_data(data) |
| 309 | |
| 310 | vertices = {} |
| 311 | if len(self.surfaces.keys()) == 2: |
| 312 | lh_points = self.surfaces['left'].n_points |
no test coverage detected