Skip to content

Commit

Permalink
removed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
buddekai committed Apr 8, 2021
1 parent 1178609 commit 3c1aea6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: readCzi
Type: Package
Title: Read czi image files, convert them to tifs, and save metadata
Version: 0.1.1
Version: 0.1.2
Author: c(person("Kai", "Budde", email = "[email protected]",
role = c("aut", "cre"))
Maintainer: Kai Budde <[email protected]>
Expand Down
26 changes: 16 additions & 10 deletions R/readCzi.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ readCzi <- function(input_file = NULL) {
red_id <- ifelse(test = test_red, yes = which(wavelengths > lower_limit_red), no = 0)
if(length(red_id) > 1){print("More than one red channel!?")}

test_green <- all( (upper_limit_blue) <= wavelengths & (wavelengths <= lower_limit_red))
test_green <- any( (upper_limit_blue) <= wavelengths & (wavelengths <= lower_limit_red))
green_id <- ifelse(test = test_green, yes = which((upper_limit_blue <= wavelengths) & (wavelengths <= lower_limit_red)), no = 0)
if(length(green_id) > 1){print("More than one green channel!?")}

Expand Down Expand Up @@ -159,22 +159,28 @@ readCzi <- function(input_file = NULL) {
# not existing colors
copy_image_loaded <- image_loaded

image_loaded <- array(data = 0, dim = c(dim_x, dim_y, 3, dim_z))

# add missing channel(s)
if(number_of_channels != 3){
image_loaded <- array(data = 0, dim = c(dim_x, dim_y, 3, dim_z))
image_loaded[,,-which(rgb_layers == 0),] <- copy_image_loaded
}

if(rgb_layers[1] != 0){
image_loaded[,,1,] <- copy_image_loaded[,,rgb_layers[1],,,,,]
}
if(rgb_layers[2] != 0){
image_loaded[,,2,] <- copy_image_loaded[,,rgb_layers[2],,,,,]
}
if(rgb_layers[3] != 0){
image_loaded[,,3,] <- copy_image_loaded[,,rgb_layers[3],,,,,]
if(length(dim(copy_image_loaded)) == 8){
if(rgb_layers[1] != 0){
image_loaded[,,1,] <- copy_image_loaded[,,rgb_layers[1],,,,,]
}
if(rgb_layers[2] != 0){
image_loaded[,,2,] <- copy_image_loaded[,,rgb_layers[2],,,,,]
}
if(rgb_layers[3] != 0){
image_loaded[,,3,] <- copy_image_loaded[,,rgb_layers[3],,,,,]
}
}else{
print("The dimensions of the image does not fit.")
}


# Drop all arrays with dim=1 (except the channel, if C=1)
#image_loaded <- drop(image_loaded)

Expand Down
7 changes: 4 additions & 3 deletions inst/testscriptDevelop.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rm(list = ls())
# close all open plots in RStudio
graphics.off()

# Load packages #############################################################
# Load packages ############################################################

list.of.packages <- c("BiocManager", "reticulate")
#list.of.packages <- c("tiff", "dplyr", "devtools", "BiocManager", "xlsx", "zis", "reticulate")
Expand Down Expand Up @@ -54,7 +54,8 @@ load_all()

# Please adapt the following parameters ####################################
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
input_file <- "tests/EV52_6_links_63x_zstack_3 nur rot.czi"
input_file <- "tests/190815_EV38_2_Kollagen mit Asc u Dexa_63x_zstack_6.czi"
#input_file <- "tests/210301_EV38_Kollagen + WF_1_1024x1024_z-stack_1.czi"
input_folder <- "tests/"

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Expand All @@ -68,7 +69,7 @@ image_data <- readCzi(input_file <- input_file)
df_metadata <- readCziMetadata(input_file <- input_file)

# Test script for converting a czi file into a tif file --------------------
convertCziToTif(input_file <- input_file)
convertCziToTif(input_file <- input_file, convert_all_slices = FALSE)

### Test with files in folder ----------------------------------------------

Expand Down

0 comments on commit 3c1aea6

Please sign in to comment.