emsweene / SuBLIME_package

3 stars 7 forks source link

How to run nopd_sublime_model #10

Open anleoor opened 6 years ago

anleoor commented 6 years ago

Hello everybody,

After going through the code a bit further I am a bit clear about how to run SuBLIME in R. If I am not mistaken, I am only need to use 'SuBLIME_prediction.R' and run the following command (once I have imported all my images and masks as nii objects):

outimg = SuBLIME_prediction(baseline_flair, follow_up_flair, baseline_pd, follow_up_pd, baseline_t2, follow_up_t2, baseline_t1, follow_up_t1, time_diff, baseline_nawm_mask, follow_up_nawm_mask, brain_mask, model = sublime::sublime_model, voxsel = TRUE, smooth.using = c("GaussSmoothArray", "none"), voxsel.sigma = diag(3,3), voxsel.ksize = 5, s.sigma = diag(3,3), s.ksize = 3, plot.imgs = FALSE, slice = 90, pdfname = "sublime.pdf", verbose = TRUE)

My problem is that I do not have PD images and I would like to use your non-PD package, where there is a model which has the coefficients without the PD imaging modality. I am unclear however, on how to properly use this new model:

Could somebody help me? Any ideas?

muschellij2 commented 6 years ago

First, you need to install the development version of sublime, (do not use the .R files):

devtools::install_github("muschellij2/sublime")

If you do not have PD data, then you should run:

outimg = SuBLIME_prediction(
  baseline_flair, follow_up_flair, 
  baseline_pd = NULL, follow_up_pd = NULL, 
  baseline_t2, follow_up_t2, 
  baseline_t1, follow_up_t1, time_diff, 
  baseline_nawm_mask, follow_up_nawm_mask, 
  brain_mask, model = sublime::nopd_sublime_model, 
  voxsel = TRUE, smooth.using = "GaussSmoothArray", 
  voxsel.sigma = diag(3,3), voxsel.ksize = 5, 
  s.sigma = diag(3,3), s.ksize = 3, plot.imgs = FALSE,
  slice = 90, pdfname = "sublime.pdf", verbose = TRUE)

or more simply (keeping defaults):

outimg = SuBLIME_prediction(
  baseline_flair, follow_up_flair, 
  baseline_pd = NULL, follow_up_pd = NULL, 
  baseline_t2, follow_up_t2, 
  baseline_t1, follow_up_t1, time_diff, 
  baseline_nawm_mask, follow_up_nawm_mask, 
  brain_mask, model = sublime::nopd_sublime_model)

But I would urge you to consider that this model may not work well for your sequences. As per the paper, you should likely create a training data set from your data and use that to retrain the model a bit.

Please read the help files for the documentation to see what each function does and the relevant sections of the paper that discusses the refitting procedure.

As per the sublime_prediction example, this should work to test against:

library(sublime)
download_data()
modes = c("FLAIR", "PD", "T2", "VolumetricT1")
modals = paste0(modes, "norm.nii.gz")
base_files = system.file("01", "Baseline", modals,
                         package = "sublime")
base_imgs = lapply(base_files, readNIfTI, reorient = FALSE)
f_files = system.file("01", "FollowUp", modals, package="sublime")
f_imgs = lapply(f_files, readNIfTI, reorient=FALSE)
names(base_imgs) = names(f_imgs) = modes
baseline_nawm_file =  system.file("01", "Baseline",
                                  "nawm.nii.gz", package="sublime")
baseline_nawm_mask =  readNIfTI(baseline_nawm_file, reorient=FALSE)
baseline_nawm_mask = drop(baseline_nawm_mask)

follow_up_nawm_file =  system.file("01", "FollowUp",
                                   "nawm.nii.gz", package="sublime")
follow_up_nawm_mask =  readNIfTI(follow_up_nawm_file, reorient=FALSE)
brain_file =  system.file("01", "duramask.nii.gz", package="sublime")
brain_mask =  readNIfTI(brain_file, reorient=FALSE)
brain_mask = drop(brain_mask)

smooth.using = "GaussSmoothArray"
verbose = TRUE
time_diff = 10
voxsel = TRUE
model = nopd_sublime_model

outimg = SuBLIME_prediction(
  baseline_flair = base_imgs[["FLAIR"]],
  follow_up_flair= f_imgs[["FLAIR"]],
  baseline_pd = NULL,
  follow_up_pd = NULL,
  baseline_t2 = base_imgs[["T2"]],
  follow_up_t2 = f_imgs[["T2"]],
  baseline_t1 = base_imgs[["VolumetricT1"]],
  follow_up_t1 = f_imgs[["VolumetricT1"]],
  time_diff = time_diff,
  baseline_nawm_mask = baseline_nawm_mask,
  brain_mask = brain_mask,
  voxsel = TRUE,
  model = model, plot.imgs= TRUE,
  pdfname = file.path(tempdir(), "pckg_diagnostc.pdf")
)
muschellij2 commented 6 years ago

I haven't heard anything about this - can this issue be closed @anleoor?