Skip to content

Commit

Permalink
Prep for new ijtiff::display().
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory Nolan committed Jan 27, 2025
1 parent c70e9de commit 5d29708
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: detrendr
Title: Detrend Images
Version: 0.6.16
Version: 0.6.17
Authors@R: c(
person("Rory", "Nolan", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5239-4043")),
Expand Down Expand Up @@ -52,6 +52,7 @@ Suggests:
knitr,
lattice,
MASS,
magick,
matrixStats,
mgcv,
pacman,
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# `detrendr` 0.6.17

## BUG FIXES
* Prep for new `ijtiff::display()`.


# `detrendr` 0.6.16

## BUG FIXES
Expand Down
16 changes: 14 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/rorynolan/detrendr",
"issueTracker": "https://github.com/rorynolan/detrendr/issues",
"license": "https://spdx.org/licenses/BSD-3-Clause",
"version": "0.6.16",
"version": "0.6.17",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -181,6 +181,18 @@
},
"sameAs": "https://CRAN.R-project.org/package=MASS"
},
{
"@type": "SoftwareApplication",
"identifier": "magick",
"name": "magick",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=magick"
},
{
"@type": "SoftwareApplication",
"identifier": "matrixStats",
Expand Down Expand Up @@ -513,7 +525,7 @@
},
"SystemRequirements": "GNU make"
},
"fileSize": "813.008KB",
"fileSize": "18643.553KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
10 changes: 6 additions & 4 deletions vignettes/single-images.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ In this vignette, we will look at detrending single images interactively in an R
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE, comment = "#>",
fig.width = 7, fig.height = 6
fig.width = 7, fig.height = 6,
crop = TRUE
)
knitr::knit_hooks$set(crop = knitr::hook_pdfcrop)
pacman::p_load(dplyr, tidyr, MASS, mgcv, ggplot2, gridExtra)
set.seed(1)
```
Expand Down Expand Up @@ -46,7 +48,7 @@ dim(my_img)

Plotting the mean intensities of the frames in the two channels, we can see that the second channel has more obvious bleaching.

```{r plot-mean-profile, echo=FALSE, fig.height=3, message=FALSE}
```{r plot-mean-profile, echo=FALSE, out.width='100%', message=FALSE}
plot_tbl <- tibble(
frame = seq_len(dim(my_img)[4]),
channel1 = apply(autothresholdr::mean_stack_thresh(my_img[, , 1, ], "h"), 4,
Expand Down Expand Up @@ -92,7 +94,7 @@ display(mean_pillars(my_img[, , 2, ]))

You can see here that this is an image of part of a cell, with the edge of the cell across the top left and hence the top left corner of the image is not cell, just background. It's important to _threshold_ away this background part: the detrending routine assumes that all parts of the image are part of the region of interest (the cell), so we need to set the background parts to `NA` beforehand to tell the detrending routine that this area should be excluded. `detrendr` has all of the thresholding functionality of the _ImageJ Auto Threshold_ plugin. You can read more about this at https://imagej.net/plugins/auto-threshold. My favourite method is _Huang_. Let's look at both of these channels with _Huang_ thresholding.

```{r display-thresholded-mean, echo=FALSE, fig.height=4}
```{r display-thresholded-mean, echo=FALSE, out.width='100%'}
graphics::par(mfrow = c(1, 2))
display(mean_pillars(autothresholdr::mean_stack_thresh(my_img[, , 1, ], "h")))
display(mean_pillars(autothresholdr::mean_stack_thresh(my_img[, , 2, ], "h")))
Expand Down Expand Up @@ -120,7 +122,7 @@ my_detrended_img <- img_detrend_robinhood(my_img_threshed)

Let's check out the mean intensity profiles of this detrended image.

```{r plot-detrended-mean-profile, echo=FALSE, fig.height=3, message=FALSE}
```{r plot-detrended-mean-profile, echo=FALSE, out.width='100%', message=FALSE}
plot_tbl <- tibble(
frame = seq_len(dim(my_detrended_img)[4]),
channel1 = apply(my_detrended_img[, , 1, ], 3, mean, na.rm = TRUE),
Expand Down

0 comments on commit 5d29708

Please sign in to comment.