mandymejia / BayesfMRI

BayesfMRI R package
GNU General Public License v3.0
23 stars 7 forks source link

Group Analysis Error: Incorrect Mesh Format #29

Open smeisler opened 1 year ago

smeisler commented 1 year ago

Hello,

I am attempting to run a group GLM of subject level results. For each subject (M=68), I have the _left.rds, _right.rds and combined .rds file saved out from the subject-level run. Each subject has one task with two conditions, and two runs of each task that are combined in the session_average on the subject level. Subject-level outputs were completed without errors. Original data were preprocessed with fMRIPrep 22.1.1 with 91k resolution CIFTI outputs.

All code was run on the most recent CiftiTools 11.0 and BayesfMRI 0.2.0 branches (all other CRAN packages and INLA were also updated just prior to running).

subject level BayesGLM invocation

results <- BayesGLM_cifti(
    cifti_fname = fnames_ts,
    surfL_fname = fname_gifti_left,
    surfR_fname = fname_gifti_right,
    brainstructures = c("left", "right"),
    session_names = c('run-1','run-2'),
    TR = TR,
    onsets = events_all,
    nuisance = confounds_all,
    dHRF = 0, # might add a temporal derivative later
    DCT= 0, # fMRIPrep already returns cosine regressors
    resamp_res = 10000,
    Bayes = TRUE,
    EM = TRUE, # INLA execution throws an error
    num.threads =  8,
    verbose = TRUE,
    outfile = outfile
)

group level BayesGLM invocation

M <- 68 # number of subjects
K <- 2 # number of task conditions
num_sessions <- 1 # Only analyzing the session average
task <- "lang" # Analyzing language task 
task_subject_results <- Sys.glob(file.path(bayesfmri_dir,'*',paste0('BayesGLM_',task,'.rds'))) # Collect all combined .rds files

results <- BayesGLM_group(
    results = task_subject_results,
    contrasts = rep(rep(c(1/(M*num_sessions),-1/(M*num_sessions),rep(0, K-2)), num_sessions),M), # Find condition difference averaged across subjects
    no_cores = 24,
    verbose = TRUE)

group level BayesGLM error

cortexL  ~~~~~~~~~~~
Error in BayesGLM2(results = results, contrasts = contrasts, quantiles = quantiles, : Your results version does not have the correct mesh format please re-run subject-level models using the current package version.
Traceback:

1. BayesGLM_group(results = task_subject_results, contrasts = rep(rep(c(1/(M * 
 .     num_sessions), -1/(M * num_sessions), rep(0, K - 2)), num_sessions), 
 .     M), no_cores = 24, verbose = TRUE)
2. BayesGLM2(results = results, contrasts = contrasts, quantiles = quantiles, 
 .     excursion_type = excursion_type, gamma = gamma, alpha = alpha, 
 .     nsamp_theta = nsamp_theta, nsamp_beta = nsamp_beta, no_cores = no_cores, 
 .     verbose = verbose)
3. stop("Your results version does not have the correct mesh format please re-run subject-level models using the current package version.")

What would be the best way to proceed here?

Best, Steven

mandymejia commented 1 year ago

Hi Steven,

Thank you for bringing this to our attention. We are in a period of transition with Dan taking a full-time job and Damon starting to take over the maintenance of the package. He is looking into it but will probably need a week or so to identify and resolve the issue.

Best, Mandy

Mandy Mejia, PhD Assistant Professor Department of Statistics Indiana University https://www.statmindlab.com/

On Mon, Jan 23, 2023 at 8:17 PM Steven Meisler @.***> wrote:

Hello,

I am attempting to run a group GLM of subject level results. For each subject (M=68), I have the _left.rds, _right.rds and combined .rds file saved out from the subject-level run. Each subject has one task with two conditions, and two runs of each task that are combined in the session_average on the subject level. Subject-level outputs were completed without errors. Original data were preprocessed with fMRIPrep 22.1.1 with 91k resolution CIFTI outputs.

All code was run on the most recent CiftiTools 11.0 and BayesfMRI 0.2.0 branches. subject level BayesGLM invocation

results <- BayesGLM_cifti( cifti_fname = fnames_ts, surfL_fname = fname_gifti_left, surfR_fname = fname_gifti_right, brainstructures = c("left", "right"), session_names = c('run-1','run-2'), TR = TR, onsets = events_all, nuisance = confounds_all, dHRF = 0, DCT= 0, resamp_res = 10000, Bayes = TRUE, EM = TRUE, num.threads = 8, verbose = TRUE, outfile = outfile )

group level BayesGLM invocation

M <- 68 # number of subjects K <- 2 # number of task conditions num_sessions <- 1 # Only analyzing the session average task <- "lang" # Analyzing language task task_subject_results <- Sys.glob(file.path(bayesfmridir,'*',paste0('BayesGLM',task,'.rds'))) # Collect all combined .rds files

results <- BayesGLM_group( results = task_subject_results, contrasts = rep(rep(c(1/(Mnum_sessions),-1/(Mnum_sessions),rep(0, K-2)), num_sessions),M), # Find condition difference averaged across subjects no_cores = 24, verbose = TRUE)

group level BayesGLM error

cortexL ~~~ Error in BayesGLM2(results = results, contrasts = contrasts, quantiles = quantiles, : Your results version does not have the correct mesh format please re-run subject-level models using the current package version. Traceback:

  1. BayesGLM_group(results = task_subject_results, contrasts = rep(rep(c(1/(M . num_sessions), -1/(M num_sessions), rep(0, K - 2)), num_sessions), . M), no_cores = 24, verbose = TRUE)
  2. BayesGLM2(results = results, contrasts = contrasts, quantiles = quantiles, . excursion_type = excursion_type, gamma = gamma, alpha = alpha, . nsamp_theta = nsamp_theta, nsamp_beta = nsamp_beta, no_cores = no_cores, . verbose = verbose)
  3. stop("Your results version does not have the correct mesh format please re-run subject-level models using the current package version.")

What would be the best way to proceed here?

Best, Steven

— Reply to this email directly, view it on GitHub https://github.com/mandymejia/BayesfMRI/issues/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHVKUW75COZB3KRCXPIKFTWT4UTPANCNFSM6AAAAAAUEQDV5E . You are receiving this because you are subscribed to this thread.Message ID: @.***>

damondpham commented 1 year ago

@smeisler could you send me, say, three of your subjects' results?

smeisler commented 1 year ago

Sure, the files will be finished uploading here in about 20 minutes https://drive.google.com/drive/folders/17xR_z-Dj7kaIqGdKTsExZxOlRP9u7tUK?usp=share_link

edit to add that the files are finished uploading

damondpham commented 1 year ago

Thanks Steven! It looks like the solution is not a simple fix, and I'm in the middle of a revision right now, so this might take me a couple weeks. Is this analysis time sensitive?

smeisler commented 1 year ago

All good! It is not time sensitive.

damondpham commented 1 year ago

Hi Steven!

Well, I beat the half year mark :) BayesfMRI is now on CRAN and it should be in a lot better shape! You should re-run your analysis with the new version when you get a chance. But you'll have to re-run the subject-level analysis too, and then use that for the group-level analysis.

smeisler commented 1 year ago

Perfect, thanks! Will give it a shot.

smeisler commented 1 year ago

I presume I should be using branch 3.0?

damondpham commented 1 year ago

I just merged 3.0 to master so now either is the same as what's on CRAN. But with your latest change, let's use 4.0. And further changes will also be made to 4.0 for the time being :)