Linescan data

  collapse = TRUE,
  comment = "#>"

detrendr expects the time dimension to be the fourth dimension of the image (y, x, channel, time). Some people's data is linescan, meaning there is only one spatial dimension (x) and time is placed along the y axis of the image. We have an example in this package. It's 1,000 time points of a line of 64 pixels; it has 2 channels.

linescan_img <- ijtiff::read_tif(system.file("extdata", "linescan.tif",
                                             package = "detrendr"))

As you can see, the image has 1,000 rows and 64 columns in its two channels, so time is indeed along the y axis. This won't work with detrendr, so before detrending it, we need to put time on the fourth dimension. Fortunately, ijtiff provides a function for this.

converted_img <- ijtiff::linescan_to_stack(linescan_img)

Now as you can see, time is on the fourth dimension, so we can proceed as normal.

detrended_converted_img <- img_detrend_rh(converted_img)

This image is still in stack format. You could now convert it back to linescan format if you like.

linescan_detrended_img <- ijtiff::stack_to_linescan(detrended_converted_img)

You can then do as you please with these results, such as save them with ijtiff::write_tif().

Try the detrendr package in your browser

Any scripts or data that you put into this service are public.

detrendr documentation built on May 16, 2021, 9:07 a.m.