Skip to content
Snippets Groups Projects
Commit 5904dfd8 authored by tpylak's avatar tpylak
Browse files

LMS-2027 sanofi dropbox - extended thumbnails generation parameters, delete...

LMS-2027 sanofi dropbox - extended thumbnails generation parameters, delete tiff overlays, workaround the bug in transaction handling

SVN: 19875
parent 489298c7
No related branches found
No related tags found
No related merge requests found
...@@ -42,13 +42,24 @@ RECOGNIZED_IMAGES_EXTENSIONS = ["tiff", "tif", "png", "gif", "jpg", "jpeg"] ...@@ -42,13 +42,24 @@ RECOGNIZED_IMAGES_EXTENSIONS = ["tiff", "tif", "png", "gif", "jpg", "jpeg"]
""" should thumbnails be generated? """ """ should thumbnails be generated? """
GENERATE_THUMBNAILS = True GENERATE_THUMBNAILS = True
""" the maximal width and height of the generated thumbnails """
MAX_THUMNAIL_WIDTH_AND_HEIGHT = 256
"""
number of threads that are used for thumbnail generation will be equal to:
this constant * number of processor cores
"""
ALLOWED_MACHINE_LOAD_DURING_THUMBNAIL_GENERATION = 1.0
""" should all dataset in one experiment use the same channels? """ """ should all dataset in one experiment use the same channels? """
STORE_CHANNELS_ON_EXPERIMENT_LEVEL = True STORE_CHANNELS_ON_EXPERIMENT_LEVEL = False
""" should the original data be stored in the original form or should we pack them into one container? """ """ should the original data be stored in the original form or should we pack them into one container? """
ORIGINAL_DATA_STORAGE_FORMAT = OriginalDataStorageFormat.UNCHANGED ORIGINAL_DATA_STORAGE_FORMAT = OriginalDataStorageFormat.UNCHANGED
# --------- # ---------
""" name of the color which should be treated as transparent in overlays """
OVERLAYS_TRANSPARENT_COLOR = "black"
""" sample type code of the plate, needed if a new sample is registered automatically """ """ sample type code of the plate, needed if a new sample is registered automatically """
PLATE_TYPE_CODE = "PLATE" PLATE_TYPE_CODE = "PLATE"
""" project and experiment where new plates will be registered """ """ project and experiment where new plates will be registered """
...@@ -243,7 +254,11 @@ def set_image_dataset_storage_config(image_dataset): ...@@ -243,7 +254,11 @@ def set_image_dataset_storage_config(image_dataset):
config.setStoreChannelsOnExperimentLevel(STORE_CHANNELS_ON_EXPERIMENT_LEVEL) config.setStoreChannelsOnExperimentLevel(STORE_CHANNELS_ON_EXPERIMENT_LEVEL)
config.setOriginalDataStorageFormat(ORIGINAL_DATA_STORAGE_FORMAT) config.setOriginalDataStorageFormat(ORIGINAL_DATA_STORAGE_FORMAT)
if GENERATE_THUMBNAILS: if GENERATE_THUMBNAILS:
config.switchOnThumbnailsGeneration() thumbnailsStorageFormat = ThumbnailsStorageFormat()
thumbnailsStorageFormat.setAllowedMachineLoadDuringGeneration(ALLOWED_MACHINE_LOAD_DURING_THUMBNAIL_GENERATION)
thumbnailsStorageFormat.setMaxWidth(MAX_THUMNAIL_WIDTH_AND_HEIGHT)
thumbnailsStorageFormat.setMaxHeight(MAX_THUMNAIL_WIDTH_AND_HEIGHT)
config.setThumbnailsStorageFormat(thumbnailsStorageFormat)
image_dataset.setImageStorageConfiguraton(config) image_dataset.setImageStorageConfiguraton(config)
""" """
...@@ -397,11 +412,17 @@ def create_overlay_dataset_details(overlays_dir, image_dataset, img_dataset_code ...@@ -397,11 +412,17 @@ def create_overlay_dataset_details(overlays_dir, image_dataset, img_dataset_code
overlay_dataset = overlay_dataset_details.getDataSetInformation() overlay_dataset = overlay_dataset_details.getDataSetInformation()
set_overlay_dataset(overlays_dir, image_dataset, img_dataset_code, overlay_dataset, extension) set_overlay_dataset(overlays_dir, image_dataset, img_dataset_code, overlay_dataset, extension)
set_dataset_details(overlay_dataset, overlay_dataset_details) set_dataset_details(overlay_dataset, overlay_dataset_details)
set_image_dataset_storage_config(image_dataset) set_image_dataset_storage_config(overlay_dataset)
config = ImageStorageConfiguraton.createDefault() config = overlay_dataset.getImageStorageConfiguraton()
# channels will be connected to the dataset # channels will be connected to the dataset
config.setStoreChannelsOnExperimentLevel(False) config.setStoreChannelsOnExperimentLevel(False)
if GENERATE_THUMBNAILS:
# overlay thumbnails should be generated with higher quality
thumbnailsStorageFormat = config.getThumbnailsStorageFormat()
thumbnailsStorageFormat.setHighQuality(True);
config.setThumbnailsStorageFormat(thumbnailsStorageFormat)
overlay_dataset.setImageStorageConfiguraton(config) overlay_dataset.setImageStorageConfiguraton(config)
return overlay_dataset_details return overlay_dataset_details
...@@ -464,9 +485,10 @@ def debug(*msg): ...@@ -464,9 +485,10 @@ def debug(*msg):
print "".join(msg) print "".join(msg)
def convert_to_png(dir, transparent_color): def convert_to_png(dir, transparent_color):
strategy = Tiff2PngConversionStrategy(transparent_color) delete_original_files = True
strategy = Tiff2PngConversionStrategy(transparent_color, 0, delete_original_files)
# Uses #cores * machineLoad threads for the conversion, but not more than maxThreads # Uses #cores * machineLoad threads for the conversion, but not more than maxThreads
machineLoad = 1 machineLoad = ALLOWED_MACHINE_LOAD_DURING_THUMBNAIL_GENERATION
maxThreads = 100 maxThreads = 100
errorMsg = FileConverter.performConversion(File(dir), strategy, machineLoad, maxThreads) errorMsg = FileConverter.performConversion(File(dir), strategy, machineLoad, maxThreads)
if errorMsg != None: if errorMsg != None:
...@@ -512,21 +534,25 @@ def register_images_with_overlays_and_analysis(incoming): ...@@ -512,21 +534,25 @@ def register_images_with_overlays_and_analysis(incoming):
# move overlays folder # move overlays folder
overlays_dir = find_dir(File(image_data_set_folder), OVERLAYS_DIR_PATTERN) overlays_dir = find_dir(File(image_data_set_folder), OVERLAYS_DIR_PATTERN)
if overlays_dir != None: if overlays_dir != None:
convert_to_png(overlays_dir.getPath(), "white") tr_overlays = service.transaction(overlays_dir, factory)
convert_to_png(overlays_dir.getPath(), OVERLAYS_TRANSPARENT_COLOR)
overlay_dataset_details = create_overlay_dataset_details(overlays_dir, overlay_dataset_details = create_overlay_dataset_details(overlays_dir,
image_dataset_details.getDataSetInformation(), img_dataset_code, "png") image_dataset_details.getDataSetInformation(), img_dataset_code, "png")
overlays_data_set = tr.createNewDataSet(overlay_dataset_details) overlays_data_set = tr_overlays.createNewDataSet(overlay_dataset_details)
tr.moveFile(overlays_dir.getPath(), overlays_data_set, "overlays") tr_overlays.moveFile(overlays_dir.getPath(), overlays_data_set, "overlays")
tr_overlays.commit()
# transform and move analysis file # transform and move analysis file
analysis_file = find_file_by_ext(File(image_data_set_folder), "xml") analysis_file = find_file_by_ext(File(image_data_set_folder), "xml")
if analysis_file != None: if analysis_file != None:
tr_analysis = service.transaction(analysis_file, factory)
analysis_registration_details = create_analysis_dataset_details(space_code, plate_code, img_dataset_code) analysis_registration_details = create_analysis_dataset_details(space_code, plate_code, img_dataset_code)
analysis_data_set = tr.createNewDataSet(analysis_registration_details) analysis_data_set = tr_analysis.createNewDataSet(analysis_registration_details)
analysis_data_set_file = tr.createNewFile(analysis_data_set, analysis_file.getName()) analysis_data_set_file = tr_analysis.createNewFile(analysis_data_set, analysis_file.getName())
GEExplorerImageAnalysisResultParser(analysis_file.getPath()).writeCSV(File(analysis_data_set_file)) GEExplorerImageAnalysisResultParser(analysis_file.getPath()).writeCSV(File(analysis_data_set_file))
tr_analysis.commit()
service.commit() service.commit()
notify(plate_code) notify(plate_code)
register_images_with_overlays_and_analysis(incoming) register_images_with_overlays_and_analysis(incoming)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment