
Hi Muhamed, I suspect the reason your numpy correlation value does not agree with ChimeraX is because ChimeraX by default does not subtract the mean value when computing the correlation. Usually the cross-correlation is defined as (u-u_mean, v-v_mean) / norm(u-u_mean)*norm(v-v_mean). But ChimeraX uses the cryoEM convention that the mean is not subtracted which produces higher correlation values (u,v)/norm(u)*norm(v). This is described in the ChimeraX measure correlation documentation https://www.cgl.ucsf.edu/chimerax/docs/user/commands/measure.html#correlatio... <https://www.cgl.ucsf.edu/chimerax/docs/user/commands/measure.html#correlatio...> So I suspect that if you compare the ChimeraX "correlation about mean" value you will see the same value numpy gives. You can do this when fitting one map into another using the fitmap option "metric cam". https://www.cgl.ucsf.edu/chimerax/docs/user/commands/fitmap.html#options Tom
On Jul 23, 2025, at 4:42 AM, Amin, M.A.A. via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hello, I'm trying to get the correlation between 2 maps. I used the command: measure correlation #2 in_map #1 I also saved the resampled map. Then, I wrote a very simple python code that calculates the correlation coefficient as following: def compute_correlation(map1, map2): threshold = np.percentile(map1.flatten(), 99) # top 1% value mask = (map1 >= threshold) #& (map2 != 0) values1 = map1[mask] values2 = map2[mask] corr = np.corrcoef(values1, values2)[0, 1] return corr
Although it is considered masking as it is done in ChimeraX, I was never able to get the correlation value I got from ChimeraX. I got 0.1 from the python code and 0.68 in ChimeraX. Any suggestions? Thank you -- Muhamed Amin, Ph.D Assistant Professor of Physics University of Groningen, Groningen, Netherlands _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/