nltools icon indicating copy to clipboard operation
nltools copied to clipboard

add vmin, vmax, cmap options to plotting functions

Open jcheong0428 opened this issue 3 years ago • 0 comments

Current plot uses a cmap where the extreme values are white. For example: image

Fix would be to allow passing a vmin, vmax, or cmap to _viewer brain or plot brain, so that it plots like this using cmap="RdBu_r":
image

For example, change the cmap to RdBu_r in _viewer https://github.com/cosanlab/nltools/blob/91822a45778415ee2cdded7134e60bcde2bb7814/nltools/plotting.py#L115

at https://github.com/cosanlab/nltools/blob/91822a45778415ee2cdded7134e60bcde2bb7814/nltools/plotting.py#L135

like so.

    if thresh == 0:
        thresh = 1e-6
    else:
        if percentile_threshold:
            thresh = str(thresh) + "%"
    if isinstance(idx, int):
        b = brain[idx].to_nifti()
    else:
        b = brain.to_nifti()
    if anatomical:
        bg_img = anatomical
    else:
        bg_img = "MNI152"
    cut_coords = kwargs.get("cut_coords", [0, 0, 0])

    if surface:
        return view_img_on_surf(b, threshold=thresh, **kwargs)
    else:
        return view_img(
            b, bg_img=bg_img, threshold=thresh, cut_coords=cut_coords, cmap='RdBu_r', **kwargs
        )```

jcheong0428 avatar Mar 16 '21 21:03 jcheong0428