Open cooperr11 opened 1 year ago
Hi Bec,
Thanks for your interest in CLEAN-R. Let me clarify your questions.
Xnames=c("X_subj1.mgh", "X_subj2.mgh", ..., "X_subj20.mgh")
Ynames=c("Y_subj1.mgh", "Y_subj2.mgh", ..., "Y_subj20.mgh")
Then, you may use the following to obtain the data in the format for CLEAN-R.
library(freesurferformats)
Xmat=do.call("cbind", lapply(Xnames, read.fs.mgh))
Ymat=do.call("cbind", lapply(Ynames, read.fs.mgh))
Computing Geodesic distances is an important step that I believe is not supported well by R software.
Lastly, if you have subject-level covariates including age or sex, these can be adjusted in CLEAN and CLEAN-R.
We comment that the spin test and CLEAN-R are slightly different from their hypotheses. Therefore, we recommend running CLEAN-R to test and localize coupling regions at the same time.
Thanks again for your interest and please let us know anytime if you have any follow-up issues!
Jun
Hi Jun, Thank you so much for your reply! This is extremely helpful. I'm familiar with the freesurferformats package so that's really easy. Thank you also for adding the code. I truly appreciate your helpful and comprehensive answer!
Best, Bec
Hi Bec,
Glad to hear that! Please let me know if any issues come up with the implementation!
Jun
Hi @junjypark,
I apologise, I have more questions! I notice that the Pygeodesic code shows you how to calculate distances between source and target vertices in a single mesh - but I understand we want to create a pairwise distance matrix. How would I do this using the Pygeodesic package?
With thanks, Bec
Hello, In Python you may manually generate a V times V matrix and fill in each row. I am also sharing Python codes that might help.
num_vts = len(vts)
dismat = np.zeros((num_vts, num_vts))
target_indices = np.array(range(num_vts))
for i in range(num_vts):
dists, best_source = geoalg.geodesicDistances(np.array([i]), None)
dismat[i, :] = dists
Hi @junjypark,
Thanks so much! This helps a lot. Sorry to continually ask more questions! If I may ask one last question: How did you extract the faces and vertices from your surface files? Stackoverflow is not particularly helpful here.
Thank you kindly for your time.
Warm regards, Bec
Hi Bec,
No worries, this information is directly available from your FS surface (e.g. lh.pial). For example,
library(freesurferformats)
surf = read.fs.surface("Downloads/lh.pial")
surf$vertices
surf$faces
Please note that, when you use the code above, indices for faces in R begin with 1, ..., V (not from 0, if it matters).
Choice of surfaces can be critical, as you already noticed, because a misspecified surface would give you a distorted geodesic distance. I used pial surface because I thought it would be most representative. Please see the paper below that points out a related issue.
Spencer, D., Yue, Y. R., Bolin, D., Ryan, S., & Mejia, A. F. (2022). Spatial Bayesian GLM on the cortical surface produces reliable task activations in individuals and groups. NeuroImage, 249, 118908.
Hi there, I'm very new to neuroimaging analysis - I apologize for the silly questions. I've conducted a spin test (i.e. Alexander-Bloch and colleagues) on surface-based neuroimaging data. I'm looking to localize the regions where there is the highest correspondence across the brain maps, which is where CLEAN-R looks super useful. I'm not sure how to: a) read in my data (these are in surface-based format, .mgh - does it need to be read in as xifti format using ciftitools?) b) organize the data matrix (what should this look like?) b) calculate geodesic distances (between which points?).
Thank you kindly for your help. Best, Bec