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 5d888c3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ jobs:
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: Install system dependencies
- name: Install Linux system dependencies
if: runner.os == 'Linux'
run: sudo apt-get install -y libwebp-dev libzstd-dev

- name: Install MacOS system dependencies
if: runner.os == 'macOS'
run: brew install --cask xquartz

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
Expand Down
5 changes: 3 additions & 2 deletions 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 All @@ -70,5 +71,5 @@ Config/testthat/parallel: true
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
SystemRequirements: GNU make
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
3 changes: 1 addition & 2 deletions R/detrendr.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ if (getRversion() >= "2.15.1") {
#' for preprocessing in fluorescence fluctuation and correlation spectroscopy
#' (FFS and FCS).
#'
#' @docType package
#' @name detrendr
#' @aliases detrendr-package
#' @references Rory Nolan, Luis A. J. Alvarez, Jonathan Elegheert, Maro
#' Iliopoulou, G. Maria Jakobsdottir, Marina Rodriguez-Muñoz, A. Radu
#' Aricescu, Sergi Padilla-Parra; nandb—number and brightness in R with a
#' novel automatic detrending algorithm, Bioinformatics,
#' https://doi.org/10.1093/bioinformatics/btx434.
NULL
"_PACKAGE"
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": "10268.038KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
1 change: 1 addition & 0 deletions detrendr.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: a7e7ab1f-4608-47c2-861d-78fd6e12dbe3

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
19 changes: 19 additions & 0 deletions man/detrendr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 5d888c3

Please sign in to comment.