-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimal transport R matrix rows don't sum to 1 #72
Comments
Hi @jaysonjeg, Thanks for reporting ! Could you confirm which version of fmralign you're using ? Reproducing your example from the current main branch, I get:
Since the We haven't had a release in a long time, but that will happen soon ! I'd just like to merge #70 first. Hopefully that will help to clarify these concerns ! |
Hi Elizabeth, you are right. I was using a previous version of fmralign. You have fixed this issue already. |
Thanks for confirming ! I'll close this, but please open a new issue if you encounter any problems with the newest code. |
Hi all! |
But, if the rows/columns sum to 1/nsamples, then when OT is calculated,
then the R matrix for large parcels will have smaller coefficients.
If the R matrices for each parcel are then applied to transform a brain map
(like task fMRI), the mean value in each parcel will be scaled by
1/nsamples. That is, the brain map will become dimmer in large parcels. Do
we want this to happen?
…On Wed, 25 Oct 2023, 5:51 am Elizabeth DuPre, ***@***.***> wrote:
Reopened #72 <#72>.
—
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJ73VAWXEVNFSED5FGZBGDYBAE4HAVCNFSM6AAAAAA5X6LARGVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQG42TQMBXHE3DMNY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
In larger parcels, the coefficients are indeed smaller, but this should be compensated by the fact that there are more coefficients. Is this an effect you have observed (cancellations effects may indeed be present, but more so in the noise case where the signal sign varies a lot) ? |
So if I continue the reproducing example in the first post in this thread. The sum (or mean) of z_transformed is 1/50th the sum (or mean) of z. This is with the older version of fmralign. With the latest version, the rows/cols of R sum to 1, so this no longer happens. |
If I understand correctly what you are looking for, one indeed needs to normalize the |
In the above thread, I think you meant to say (1/nfeatures), not (1/nsamples)? I don't fully understand the rationale for rows/columns summing to (1/nfeatures) rather than to 1. But I agree that if the normalization is desired, it can be done retrospectively. |
Sorry if it was not clear: indeed, the transport plan is of size |
alignment_methods.OptimalTransportAlignment() results in transformation matrix R whose rows and columns sum to 1/nfeatures. This does not seem ideal. On the other hand, alignment_methods.POTAlignment()'s R matrix has rows and columns that sum to 1, which seems better.
If the columns of R sum to 1/nfeatures, then if you transform a functional brain map, the transformation is "shrinking" each parcel's mean value depending on the size of each parcel.
Minimal reproducing example:
from fmralign import alignment_methods as am
import numpy as np
x = np.random.random((20,50)) #20 nsamples, 50 nfeatures
y = np.random.random((20,50))
ot = am.OptimalTransportAlignment()
pot = am.POTAlignment()
ot.fit(x,y)
pot.fit(x,y)
print(ot.R.sum(axis=0)[0:3])
print(pot.R.sum(axis=0)[0:3])
Solution:
At the end of alignment_methods.OptimalTransportAlignment().fit(), add a line: self.R = self.R * self.R.shape[0]
The text was updated successfully, but these errors were encountered: