Thresholding a z-map with a p-map

Hi!

I’ve obtained p-values with non_parametric_inference function from nilearn. I want to display a z-map only in the location where p-values are significant. Any suggestions on how I can intersect these 2 images with thresholding?

Best,
Anastasia

If you load your data with nilearn and get the data values as an array, you can start by making a binary thresholded p-map by doing something like p_map_thresh = (p_map_data < THRESH). This should return a boolean array which you can then use to index your z-map. So you would do something like z_map_thresh = z_map_data[p_map_thresh].

You can find handy functions to do this in nilearn:

HTH,
Bertrand