Skip to content

Commit

Permalink
Merge pull request #14 from lldelisle/fix_time_when_big_names_and_sin…
Browse files Browse the repository at this point in the history
…gle_timepoint

fix get time when big names or single time point
  • Loading branch information
lldelisle authored Dec 21, 2023
2 parents aec2e2e + de44719 commit a37e263
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tool id="incucyte_stack_and_upload_omero" name="Stack Incucyte Plate" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.01" license="BSD-3">
<description>And upload to omero</description>
<macros>
<token name="@TOOL_VERSION@">20231219</token>
<token name="@TOOL_VERSION@">20231221</token>
<token name="@VERSION_SUFFIX@">0</token>
</macros>
<requirements>
Expand Down
21 changes: 13 additions & 8 deletions tools/incucyte_stack_and_upload_omero/stack_buildXml.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* and Lucille Delisle, EPFL - SV - UPDUB
* and Pierre Osteil, EPFL - SV - UPDUB
*
* Last modification: 2023-12-19
* Last modification: 2023-12-21
*
* = COPYRIGHT =
* © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, BioImaging And Optics Platform (BIOP), 2023
Expand Down Expand Up @@ -120,7 +120,7 @@ RELATIVE_ACQUISITION_HOUR = "relative_acquisition_hour"
LETTERS = new String("ABCDEFGHIJKLMNOP")

// Version number = date of last modif
VERSION = "20231219"
VERSION = "20231221"

/** Key-Value pairs namespace */
GENERAL_ANNOTATION_NAMESPACE = "openmicroscopy.org/omero/client/mapAnnotation"
Expand Down Expand Up @@ -322,13 +322,15 @@ def process_well(baseDir, input_wellId, n_image_per_well){ //, perform_bc, media
first_image_infos = Opener.getTiffFileInfo(files_matching[0].getAbsolutePath())
// We define the imageplus object
ImagePlus single_channel_imp
ImageStack stack
if (first_image_infos == null) {
// They are raw from incucyte
// We need to open images one by one and add them to the stack
ImageStack stack = new ImageStack(first_imp.width, first_imp.height);
stack = new ImageStack(first_imp.width, first_imp.height);
files_matching.each{
ImagePlus single_imp = (new Opener()).openUsingBioFormats(it.getAbsolutePath())
String new_title = single_imp.getTitle().split(" - ")[0]
String new_title = it.getName()
// println "Title of slice: " + new_title
stack.addSlice(new_title, single_imp.getProcessor())
}
single_channel_imp = new ImagePlus(FilenameUtils.getBaseName(folder_list.get(i).getAbsolutePath()), stack);
Expand All @@ -340,15 +342,18 @@ def process_well(baseDir, input_wellId, n_image_per_well){ //, perform_bc, media
// Phase are 8-bit and need to be changed to 16-bit
// Other are already 16-bit but it does not hurt
IJ.run(single_channel_imp, "16-bit", "")

// check frame size
if (nT == 0) {
// This is the first channel with images
nT = single_channel_imp.getNSlices()
first_channel = channels_list.get(i)
// Process all dates:
Pattern date_pattern = Pattern.compile(REGEX_FOR_DATE)
ImageStack stack = single_channel_imp.getStack()
// The IJ.run 16-bit seems to remove the name of the stack
// When there is only one stack
if (nT !=1 || stack == null) {
stack = single_channel_imp.getStack()
}
// Go to the first time (which is slice)
single_channel_imp.setSlice(1)
int currentSlice = single_channel_imp.getCurrentSlice()
Expand Down Expand Up @@ -844,7 +849,7 @@ def convertLetterToNumber(String letter){

// Returns a date from a label and a date_pattern
def getDate(String label, Pattern date_pattern){
// println "Trying to get date from " + label
// println "Trying to get date from " + label
Matcher date_m = date_pattern.matcher(label)
LocalDateTime dateTime
if (date_m.matches()) {
Expand All @@ -854,7 +859,7 @@ def getDate(String label, Pattern date_pattern){
dateTime = LocalDateTime.parse("1970-01-" + 1 + (date_m.group(1) as int) + "T" + date_m.group(2) + ":" + date_m.group(3))
}
}
// println "Found " + dateTime
// println "Found " + dateTime
return dateTime
}

Expand Down

0 comments on commit a37e263

Please sign in to comment.