maskOutline: min = max = maskColor
Hi there Steven,
Thanks so much for Patternize. I appreciate the software.
Steven, I've been having minor issues - mostly probably due to my images - here and there with Patternize. The images I have are of lizards with extended throatfans. Here's how the pictures usually look like: To extend throatfans we need to hold the lizards and use forceps to extent the dewlaps (throatfans); as a consequence for every picture in addition in addition to the animal and the ColorChecker passport, there are two human hands and a forceps. Furthermore, as these pictures were taken by different people, there's not much consistency regarding where in the photo the animal is.
My idea was to originally use patRegK to try to obtain some patterning information on the dewlaps. patRegK tends to fail, and I am guessing this is because of the many other things, the fact that the animals are not in the same place, and the fact that other things (i.e. human hands and forceps) are also in the picture.
That said, I figured that maybe using landmarks could work, so I moved on to using patLatK. This function ran well when I used "transformRef = 'meanshape'"
rasterList_lan <- patLanK(imageList, landmarkList, k = 6, resampleFactor = 3, transformRef = 'meanshape', transformType = 'tps', adjustCoords = TRUE, crop = TRUE, plot = TRUE)
However, when I tried following more closely your examples and used "transformRef = 'target'":
rasterList_lan <- patLanK(imageList, landmarkList, k = 6, resampleFactor = 3, transformRef = '7885_e', transformType = 'tps', adjustCoords = TRUE, crop = TRUE, plot = TRUE)
I got the following error message:
Error in rowSums(x) : 'x' must be an array of at least two dimensions
As I moved forward using the results from patLanK with "transformRef = 'meanshape'" things went well up to the point where I needed to crop images with a mask.
I summed the rasters:
summedRaster_lan<-sumRaster(rasterList_lan, IDlist, type = 'k')
I was able to plot heatmaps for all k-values, as well as for single k-values (figures were upside down, but my understanding is that you account for that when using the function 'flipOutline' down the stretch).
colfunc <- inferno(100) plotHeat(summedRaster[[1]], IDlist, colpalette = colfunc)
Here is how the first element of the summedRaster list looked like:
class : RasterLayer dimensions : 300, 300, 90000 (nrow, ncol, ncell) resolution : 0.003087886, 0.001440682 (x, y) extent : -0.4419477, 0.484418, -0.259982, 0.1722226 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs source : memory names : layer values : 0, 6 (min, max)
maskOutline ran without any major problems
summedRaster_outline <- maskOutline(summedRaster[[1]], outline=outline_7885, refShape = 'mean', landList = landmarkList, adjustCoords = TRUE, cartoonID = "7885_e", IDlist = IDlist, flipOutline = 'y', imageList = imageList, maskColor = 0)
However, plotHeat would produce an output that was entirely black. Here's how I tried running it:
plotHeat(summedRaster_outline, IDlist = IDlist, colpalette = colfunc)
And, if I tried running a 'fancier' version of the plot, I would get an error message:
plotHeat(summedRaster_outline, IDlist = IDlist, colpalette = colfunc, plotCartoon = TRUE, cartoonID = '7885_e', refShape = 'mean', outline = outline_7885, adjustCoords = TRUE, landList = landmarkList, flipOutline = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black')
Error in lanArray[, , indx] : object of type 'closure' is not subsettable
Because of that, I thought something could be off with the way I ran maskOutline. By going back to the maskOutline raster, I noticed that the min and max value were the same, and they were equal to zero.
class : RasterLayer dimensions : 300, 300, 90000 (nrow, ncol, ncell) resolution : 0.003087886, 0.001440682 (x, y) extent : -0.4419477, 0.484418, -0.259982, 0.1722226 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs source : memory names : layer values : 0, 0 (min, max)
Could you help me understand why this is so? I'm happy to share some of the data with you. I drew the outlines in Fiji, as you usually do.
Just so that you have a feel, here are how some of the files looked like:
landmarkList$"7885_e"
[,1] [,2][1,] 1370.167 2047.167 [2,] 1639.833 1993.500 [3,] 1710.833 1904.167 [4,] 2169.000 2058.500 [5,] 2105.000 2219.000 [6,] 1943.500 2290.500 [7,] 1791.167 2258.167 [8,] 1630.167 2158.167 [9,] 1497.750 2085.750
IDlist
[1] "7885_e" "7889_a" "7901b" "7905b" "7914b" "7922b"
head(outline_7885)
V1 V21 1372 2051 2 1393 2054 3 1414 2057 4 1428 2061 5 1448 2066 6 1460 2070
Thanks so much for your time, and, once again, thanks for the software.
Best,
P
Hi Pietro,
Coupleof questions:
-
Did you download the most up to date version through GitHub?
-
You’ll want to indeed use a target rather than meanshape if you want to compare groups of samples. Is the sample '7885_e' in your landmark list (I see at the end it is)? Otherwise, you could also try to provide the argument transformRef with the landmark matrix object for that sample.
-
I also more recently wrote some code to perform a mask before the k-means clustering happens. It works as follows:
note that here target is the landmarks matrix of the target sample
in this example, there will be three areas maskes (mask1, mask2, and mask3). For mask1, everything outside of the outline will be masked, for mask2 and mask3 the inside of the outline will be masked
imageList_aligned <- alignLan(imageList, landmarkList, transformRef = target, adjustCoords = TRUE, plotTransformed = T, resampleFactor = 5, cartoonID = '7885_e', maskOutline = list(mask1,mask2,mask3), inverse = list(FALSE,TRUE,TRUE))
kmeansOnAll means that it will perform the kmeans on the pixels of all images combined.
rasterList_lanK <- patK(imageList_aligned, k=3, plot = T, maskToNA = 0, kmeansOnAll = TRUE)
Maybe this could be a better option for you?
If you run stuck, please share me a dropbox with a couple of images, outlines and your scripts.
Steven
From: Pietro de Mellomailto:[email protected] Sent: Tuesday, August 18, 2020 9:13 PM To: StevenVB12/patternizemailto:[email protected] Cc: Subscribedmailto:[email protected] Subject: [StevenVB12/patternize] maskOutline: min = max = maskColor (#18)
Hi there Steven,
Thanks so much for Patternize. I appreciate the software.
Steven, I've been having minor issues - mostly probably due to my images - here and there with Patternize. The images I have are of lizards with extended throatfans. Here's how the pictures usually look like: To extend throatfans we need to hold the lizards and use forceps to extent the dewlaps (throatfans); as a consequence for every picture in addition in addition to the animal and the ColorChecker passport, there are two human hands and a forceps. Furthermore, as these pictures were taken by different people, there's not much consistency regarding where in the photo the animal is.
My idea was to originally use patRegK to try to obtain some patterning information on the dewlaps. patRegK tends to fail, and I am guessing this is because of the many other things, the fact that the animals are not in the same place, and the fact that other things (i.e. human hands and forceps) are also in the picture.
That said, I figured that maybe using landmarks could work, so I moved on to using patLatK. This function ran well when I used "transformRef = 'meanshape'" rasterList_lan <- patLanK(imageList, landmarkList, k = 6, resampleFactor = 3, transformRef = 'meanshape', transformType = 'tps', adjustCoords = TRUE, crop = TRUE, plot = TRUE) However, when I tried following more closely your examples and used "transformRef = 'target'": rasterList_lan <- patLanK(imageList, landmarkList, k = 6, resampleFactor = 3, transformRef = '7885_e', transformType = 'tps', adjustCoords = TRUE, crop = TRUE, plot = TRUE) I got the following error message:
Error in rowSums(x) : 'x' must be an array of at least two dimensions
As I moved forward using the results from patLanK with "transformRef = 'meanshape'" things went well up to the point where I needed to crop images with a mask. I summed the rasters: summedRaster_lan<-sumRaster(rasterList_lan, IDlist, type = 'k')
I was able to plot heatmaps for all k-values, as well as for single k-values (figures were upside down, but my understanding is that you account for that when using the function 'flipOutline' down the stretch). colfunc <- inferno(100) plotHeat(summedRaster[[1]], IDlist, colpalette = colfunc)
Here is how the first element of the summedRaster list looked like:
class : RasterLayer dimensions : 300, 300, 90000 (nrow, ncol, ncell) resolution : 0.003087886, 0.001440682 (x, y) extent : -0.4419477, 0.484418, -0.259982, 0.1722226 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs source : memory names : layer values : 0, 6 (min, max)
maskOutline ran without any major problems summedRaster_outline <- maskOutline(summedRaster[[1]], outline=outline_7885, refShape = 'mean', landList = landmarkList, adjustCoords = TRUE, cartoonID = "7885_e", IDlist = IDlist, flipOutline = 'y', imageList = imageList, maskColor = 0)
However, plotHeat would produce an output that was entirely black. Here's how I tried running it: plotHeat(summedRaster_outline, IDlist = IDlist, colpalette = colfunc)
And, if I tried running a 'fancier' version of the plot, I would get an error message:
plotHeat(summedRaster_outline, IDlist = IDlist, colpalette = colfunc, plotCartoon = TRUE, cartoonID = '7885_e', refShape = 'mean', outline = outline_7885, adjustCoords = TRUE, landList = landmarkList, flipOutline = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black')
Error in lanArray[, , indx] : object of type 'closure' is not subsettable
Because of that, I thought something could be off with the way I ran maskOutline. By going back to the maskOutline raster, I noticed that the min and max value were the same, and they were equal to zero.
class : RasterLayer dimensions : 300, 300, 90000 (nrow, ncol, ncell) resolution : 0.003087886, 0.001440682 (x, y) extent : -0.4419477, 0.484418, -0.259982, 0.1722226 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs source : memory names : layer values : 0, 0 (min, max)
Could you help me understand why this is so? I'm happy to share some of the data with you. I drew the outlines in Fiji, as you usually do.
Just so that you have a feel, here are how some of the files looked like: landmarkList$"7885_e"
[,1] [,2]
[1,] 1370.167 2047.167 [2,] 1639.833 1993.500 [3,] 1710.833 1904.167 [4,] 2169.000 2058.500 [5,] 2105.000 2219.000 [6,] 1943.500 2290.500 [7,] 1791.167 2258.167 [8,] 1630.167 2158.167 [9,] 1497.750 2085.750
IDlist
[1] "7885_e" "7889_a" "7901b" "7905b" "7914b" "7922b"
head(outline_7885)
V1 V2
1 1372 2051 2 1393 2054 3 1414 2057 4 1428 2061 5 1448 2066 6 1460 2070
Thanks so much for your time, and, once again, thanks for the software.
Best,
P
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/18, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4YVSPDVYUWDO5YD7LTSBMRLXANCNFSM4QEMEQAQ.