allenBrain icon indicating copy to clipboard operation
allenBrain copied to clipboard

Add scalebar to the graph

Open Greerlab opened this issue 1 year ago • 4 comments

Hi, thank you for providing the opportunity to explore the mouse brain ISH atlas with coding!

I am wondering whether there is a way to add the scale bar into the graph?

Thanks!

Greerlab avatar Mar 18 '24 20:03 Greerlab

Just added a rudimentary function to add a scale bar. The information you need is available through getSectionImage and getAtlasImage which include the resolution information in pixels for the images. This can then be fed to add_scale to add a scale bar

downsample = 2

image_res = getSectionImage(69177654)$resolution

downloadImage(imageID = 69177654, 
             view = 'projection',
             downsample = downsample) %>% 
    add_scale(image_res,downsample)

Also works for cropped images

downloadImage(imageID = 69177654, 
             view = 'projection',
             downsample = downsample)  %>% 
    centerImage(x = 6382,
            y= 2744,
            xProportions = c(.1,.1),
            yProportions =c(.1,.1),
            downsample = downsample) %>% 
    add_scale(image_res,downsample)

oganm avatar Mar 19 '24 02:03 oganm

Thank you for the quick response, somehow I got an error from add_scale

Error in magick::image_read(system.file("black.png", package = "allenBrain")) : path must be URL, filename or raw vector

Greerlab avatar Mar 20 '24 20:03 Greerlab

Just forgot to push the all important black pixel. Should be fine now

oganm avatar Mar 20 '24 21:03 oganm

  • [ ] a parameter to draw a scalebar for x microns
  • Gravity options shouldn't be essential since all margins are in ratios instead of pixels.
  • [ ] Transparency to the scalebar background
  • [ ] End and breaklines for the bar

oganm avatar Mar 20 '24 22:03 oganm