-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_code_Madrid.R
More file actions
97 lines (83 loc) · 3.68 KB
/
Copy pathprocess_code_Madrid.R
File metadata and controls
97 lines (83 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
install.packages("devtools")
devtools::install_github("ajfedorec/plateR")
library(plateR)
install.packages("imager")
library(imager)
dir_path <- "C:/Users/Paula/Desktop/PhD/2025/Characterization OT-2/20260122_rep5"
output_path <- file.path(dir_path, "converted")
# List of images
files <- list.files(dir_path, pattern = "\\.png$", full.names = TRUE)
for (f in files) {
img <- load.image(f)
img <- mirror(img, "x")
# Decides the channel accroding to the name of the document, in this case Alexa is green Colorimetric is red channel"
if (grepl("Alexa", f, ignore.case = TRUE)) {
img_use <- as.cimg(img[,,,3]) # blue
} else if (grepl("Colorimetric", f, ignore.case = TRUE)) {
img_use <- as.cimg(img[,,,1]) # red
} else {
img_use <- grayscale(img)
}
# Save with new name
new_name <- file.path(output_path, paste0(basename(tools::file_path_sans_ext(f)), "_converted.png"))
save.image(img_use, new_name)
cat("Guardada:", new_name, "\n")
}
##### Second part of the code from Fedorec et al., 2024, plateR #####
dir_path <- "C:/Users/Paula/Desktop/PhD/2025/Characterization OT-2/20260218-not+not/converted/20h-plate2" # replace ... with img folder name (including /00000/)
plate_number = 2
replica = 1
t = 20
img_settings_list <- list(c(exposure=20000,
intensity=1,
panel="blue",
system="old",
plate_number = plate_number,
replica = replica,
t = t),
c(exposure=20000,
intensity=3,
panel="blue",
system="old",
plate_number = plate_number,
replica = replica,
t = t),
c(exposure=40000,
intensity=3,
panel="blue",
system="old",
plate_number = plate_number,
replica = replica,
t = t),
c(exposure=60000,
intensity=5,
panel="blue",
system="old",
plate_number = plate_number,
replica = replica,
t = t),
c(exposure=4000,
intensity=0.7,
panel="red",
system="old",
plate_number = plate_number,
replica = replica,
t = t))
## change these settings as you need.
plateR::process_img_dir(dir_path = dir_path,
img_settings_list = img_settings_list,
align_filename = '0004.png',
invert = F,
rotate = F,
experiment_type = 'colony',
normalise = F,
stencil_proportion = 0.5,
proportion_centered = T,
plate_type = '6-well',
num_wells = 384,
px_per_mm = 12.5, # if you already know the image alignment you don't have to go through the alignment process again
tl_corner = NA,
deg_rotation = NA,
well_ratio = 0.95,
in_parallel = TRUE, # process images in parallel, should speed up the process
blur = 3)