Mouse-Imaging-Centre / MRIcrotome

R package for MRI data visualization
3 stars 1 forks source link

"Large" image results in blurry mricrotome view #12

Closed gdevenyi closed 4 years ago

gdevenyi commented 4 years ago

Working with microtome and high res embryo whole-body scans, the resulting images seem to be low resolution "blocky" compared to using Display to do the same thing. Rplot.pdf

cfhammill commented 4 years ago

Have you tried generating a larger figure and seeing if this persists? I bet it's an interaction between the effective size of the figure and the output dimensions/dpi. The bigger the volume the bigger the figure, for a fixed output dimension/dpi, the worse quality.

gdevenyi commented 4 years ago

What do you suggest I try here, I'm not exactly sure what you mean.

cfhammill commented 4 years ago

try experimenting with:

pdf("test.pdf", height = 12, width = 12)
figure %>% draw
dev.off()

With different values for height and width. My guess is it will look smoother at larger sizes.

gdevenyi commented 4 years ago

Ah I see. So how do I successfully produce a PDF of a correct real-world size (1 column, ~7.5" in a journal for example), but of good quality? I would expect I should be able to control the DPI somehow so that I get proper resolution and control real-world dimensions so fonts are sane.

cfhammill commented 4 years ago

PDF is a vector format, so as far as I know the heights and widths are relative and control the font-size and the apparent size of the embedded raster images. You could make high res raster images using png or tiff. Or to deal with fonts becoming small at larger image sizes, I've added an argument to grobify that lets you set font sizes for titles and axes. I think the pointsize argument to pdf might work as well.

cfhammill commented 4 years ago

Did any of these approaches help solve your problem @gdevenyi?

gdevenyi commented 4 years ago

No that didn't really address the issue.

Our (preferred) workflow for making a poster is to generate vectorized images from R using ggsave, or the rstudio export figure to PDF or SVG (this allows for additional annotations in inkscape easily). When we do so, we specify a real-world dimension so that the font sizing and everything is the real world font size and things are consistent across figures. When we did so with MRIcrotome, the raster components images are low quality, so something about the raster scaling seems wrong. The attached image was also of a very high resolution whole-body MRI from your multi-coil setup, so maybe this is an interaction with voxel-size as well.

Hopefully that's a clearer description of what we're seeing now.

cfhammill commented 4 years ago

I'm not convinced this can't be done, it's just not simple or elegant like with a truly vector image. The embedded raster resolution isn't fixed, it's a function of the plot device parameters. If you wanted to send over an example image I can play around with it and see if I can't figure out how to get the scaling you want.

gdevenyi commented 4 years ago

Obviously this is all a bit stale, I'll dig up the old data.

gdevenyi commented 4 years ago

The old producer is gone and testing now the pdf + dev.off gives me a good quality PDF and SVG with properly sized figures and fonts.

Thanks for your help.