Mouse-Imaging-Centre / RMINC

Statistics for MINC volumes: A library to integrate voxel-based statistics for MINC volumes into the R environment. Supports getting and writing of MINC volumes, running voxel-wise linear models, correlations, etc.; correcting for multiple comparisons using the False Discovery Rate, and more. With contributions from Jason Lerch, Chris Hammill, Jim Nikelski and Matthijs van Eede. Some additional information can be found here:
https://mouse-imaging-centre.github.io/RMINC
Other
22 stars 17 forks source link

obj_montage: guidance on resizing view? #231

Closed gdevenyi closed 5 years ago

gdevenyi commented 5 years ago

I've tried to use obj_montage to work with our morpho objects and it resulted in a lot of unused space. I presume this has something to do with being developed/tested with CIVET surfaces. I couldn't grok adjusting things from the docs, some more guidance could be helpful here.

cfhammill commented 5 years ago

Right now there is a zoom argument, smaller is larger (don't ask me why rgl has that convention). I usually use a .7-.8 for CIVET surfaces anyway.

Ideally I want to give these the MRIcrotome treatment, have composable views with lots of customizations. MRIcrotome and the haskell chart library https://github.com/timbod7/haskell-chart have a lot of inspiration for the taking.

Still not fully sold on whether to stick with rgl or use webgl via my rbrainbrowser package.

In the meantime I could perhaps add a pars option that takes a list of arguments as they would be passed to rgl::par3d, one for each plot, that can be used to tweak

gdevenyi commented 5 years ago

That's kinda already done, but I couldn't figure out how it works:

  rgl::open3d(windowRect = plot_corners)
  #This isn't my fault I swear, see the ?bgplot3d examples, weird bugs happen
  #without waiting, e.g. brains will only draw when there is an inactive rgl device
  Sys.sleep(.25)
  rgl::par3d(viewport = c(0,0,plot_corners[3] - plot_corners[1], plot_corners[4] - plot_corners[2]))
cfhammill commented 5 years ago

I mean individual config for each panel, e.g. zoom .7 only for the top left, specific rotation matrix bottom right etc etc.

The plot corners are to expand the window, probably not what you are looking for.

cfhammill commented 5 years ago

I added a new feature for this release, you can pass in an rgl layout to get different orientations, and can get a horizontal colour bar. It's quite tedious to get right, but it is reproducible at least. Here's a quick example:

obj_montage(surface_left, surface_right
          , left_data_sim, right_data_sim
          , colour_title = "Normalized squared deviation"
          , zoom = .8
          , layout = function() rgl::layout3d(matrix(1:6, nrow = 1))
          , colour_range = c(.91, 11.47)
          , plot_corners = c(1,1, 1600,640)
          , par =
                list(cex = 2, lpos = .1, rpos = .8, tpos = .20, bpos = .24
                   , srt = 0
                   , nudge_title_y = .3
                   , nudge_title_x = -.5
                   , offset = 1.5
                   , pos = 1
                     )
          , vertical = FALSE
            )

makes

2019-01-08_similarity-montage

after a little post processing where I hack in some translations / scaling to make it look a bit better (appended below for interest).

rgl::useSubscene3d(rgl::subsceneList()[2])
rgl::par3d("userMatrix" = set(rgl::par3d("userMatrix"), slab_l(1,4), 10))

rgl::useSubscene3d(rgl::subsceneList()[3])
rgl::par3d("userMatrix" = set(rgl::par3d("userMatrix"), slab_l(1,4), 20))
rgl::par3d(zoom = .75)

rgl::useSubscene3d(rgl::subsceneList()[4])
rgl::par3d("userMatrix" = set(rgl::par3d("userMatrix"), slab_l(1,4), -20))
rgl::par3d(zoom = .75)

rgl::useSubscene3d(rgl::subsceneList()[5])
rgl::par3d("userMatrix" = set(rgl::par3d("userMatrix"), slab_l(1,4), -15))
rgl::par3d(zoom = .75)

rgl::useSubscene3d(rgl::subsceneList()[6])
rgl::par3d(zoom = .75)
gdevenyi commented 5 years ago

wonderful, thanks. It'll be nice to automate figure generation all inside R.

cfhammill commented 5 years ago

Also addressed in rbrainbrowser