Skip to content

Commit 8ef90d7

Browse files
committed
v.0.3.11
1 parent 5c0523d commit 8ef90d7

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: TrackMateR
22
Type: Package
33
Title: Working with TrackMate outputs in R
4-
Version: 0.3.10
4+
Version: 0.3.11
55
Authors@R:
66
person(given = "Stephen J",
77
family = "Royle",
@@ -14,7 +14,7 @@ Description: TrackMate, a plugin for ImageJ/Fiji, is a popular single-particle t
1414
License: MIT + file LICENSE
1515
Encoding: UTF-8
1616
LazyData: true
17-
RoxygenNote: 7.3.1
17+
RoxygenNote: 7.3.2
1818
Depends: R (>= 2.10)
1919
Config/rcmdcheck/ignore-inconsequential-notes: true
2020
VignetteBuilder:

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# TrackMateR
22

3+
# TrackMateR 0.3.11
4+
5+
- Better handling of more than one channel in TrackMate XML files
6+
37
# TrackMateR 0.3.10
48

59
- Fixed an issue where sparse TrackMate XML files caused `compareDatasets()` to fail

R/readTrackMateXML.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ readTrackMateXML<- function(XMLpath){
4444
if(unitVec[1] == "pixel") {
4545
cat("Spatial units are in pixels - consider transforming to real units\n")
4646
}
47+
# which channel is being tracked?
48+
targetVec <- xpathSApply(e, "//DetectorSettings", xmlGetAttr, "TARGET_CHANNEL")
49+
calibrationDF[7,1] <- as.numeric(targetVec)
50+
calibrationDF[7,2] <- "channel"
4751

4852
# multicore processing
4953
numCores <- parallelly::availableCores()
@@ -78,7 +82,7 @@ readTrackMateXML<- function(XMLpath){
7882
# more R-like headers
7983
headerNames <- tolower(attrName)
8084
# remove _CH1 or whatever from headers
81-
headerNames <- gsub("\\wCH\\d$","",headerNames,ignore.case = T)
85+
# headerNames <- gsub("\\wCH\\d$","",headerNames,ignore.case = T)
8286
# change x y z t
8387
headerNames <- gsub("^position\\w","",headerNames,ignore.case = T)
8488
names(dtf) <- headerNames

R/tm_plots.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,38 @@ plot_tm_displacementHist <- function(input, summary = FALSE, xstr = NULL, ystr =
168168
#' @param auto boolean to switch between returning a ggplot and a list of ggplot and variable
169169
#' @return ggplot or list of ggplot and variable
170170
#' @export
171-
plot_tm_intensityHist <- function(input, summary = FALSE, xstr = NULL, ystr = NULL, auto = FALSE) {
171+
plot_tm_intensityHist <- function(input, summary = FALSE, xstr = "Intensity (AU)", ystr = "Frequency", auto = FALSE) {
172172
dataid <- trace <- mean_intensity <- intensity <- NULL
173173

174174
if(inherits(input, "list")) {
175175
df <- input[[1]]
176176
calibration <- input[[2]]
177177
units <- calibration$unit[1:2]
178-
xstr <- "Intensity (AU)"
179-
ystr <- "Frequency"
178+
# get the channel from calibration dataframe by using the value in column 1 where in column 2 it has the value "channel"
179+
ch <- calibration$value[calibration$unit == "channel"]
180180
} else {
181181
df <- input
182182
}
183183

184+
# the column containing mean_intensity may not be present in the data frame
185+
# if it is present we will use that column, if not we will use paste0("mean_intensity_ch",ch)
186+
# and if that doesn't exist we will use "mean_intensity_ch1"
187+
if("mean_intensity" %in% colnames(df)) {
188+
mean_intensity_col <- "mean_intensity"
189+
} else if(paste0("mean_intensity_ch", ch) %in% colnames(df)) {
190+
mean_intensity_col <- paste0("mean_intensity_ch", ch)
191+
} else {
192+
mean_intensity_col <- "mean_intensity_ch1"
193+
}
194+
184195
if(summary) {
185196
intDF <- df %>%
186197
group_by(dataid, trace) %>%
187-
summarise(intensity = max(mean_intensity))
198+
summarise(intensity = max(!!sym(mean_intensity_col), na.rm = TRUE))
188199
} else {
189200
intDF <- df %>%
190201
group_by(trace) %>%
191-
summarise(intensity = max(mean_intensity))
202+
summarise(intensity = max(!!sym(mean_intensity_col), na.rm = TRUE))
192203
}
193204

194205
median_int <- median(intDF$intensity, na.rm = TRUE)

man/plot_tm_intensityHist.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/readTrackMateXML.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)