now the catalog automatically searches the sequences in the source inmage directory provided by the user

This commit is contained in:
Guillaume Raffy 2020-03-11 16:14:22 +01:00
parent ded2856619
commit ac93fb411f
1 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,5 @@
import os
import json
from imageengine import IHyperStack, IImageEngine, PixelType
@ -157,22 +158,25 @@ class Sequence(object):
stack.set_image(image=image, channel_index=channel_index, frame_index=frame_index, slice_index=slice_index)
return stack
def find_dirs_containing_file(file_name, root_dir):
"""
:param str file_name: the name of the searched files (eg 'metadata.txt')
:param str root_dir: the root directory where we search
"""
result = []
for root, dirs, files in os.walk(root_dir): # pylint: disable=unused-variable
if file_name in files:
result.append(root)
return result
class ImageCatalog(object):
def __init__(self, raw_images_root):
self.raw_images_root = raw_images_root
self.sequences = {}
sequence_paths = find_dirs_containing_file('metadata.txt', self.raw_images_root)
sequence_ids = [ sequence_path.replace(raw_images_root+'/', '') for sequence_path in sequence_paths ]
# nb : we use the path as sequence id because the "Comment" field in the summary section of the metadata file is not guaranteed to be unique (eg they are the same in res_soleil2018/white/white_24112018_1/Pos0 and in res_soleil2018/white/white_24112018_2/Pos0)
sequence_ids = []
sequence_ids.append('res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0')
sequence_ids.append('res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2')
sequence_ids.append('res_soleil2018/DARK/DARK_40X_60min_1 im pae min_1/Pos0')
sequence_ids.append('res_soleil2018/DARK/DARK_40X_zstack_vis_327-353_1/Pos0')
# sequence_ids.append('res_soleil2018/white/white_24112018_1/Pos0') # this sequence seems broken (only 5 images while there's supposed to be 201 frames)
sequence_ids.append('res_soleil2018/white/white_24112018_2/Pos0')
for sequence_id in sequence_ids:
micro_manager_metadata_file_path = raw_images_root + '/' + sequence_id + '/metadata.txt'
@ -182,7 +186,3 @@ class ImageCatalog(object):
def __str__(self):
for sequence_id, sequence in self.sequences.iteritems():
return str(sequence_id) + ':' + str(sequence)
# self.add_micromanager_metadata(raw_images_root + '/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0/metadata.txt')
# def add_micromanager_metadata(self, micro_manager_metadata_file_path):
# self.sequences[ micro_manager_metadata_file_path ] = Sequence(self, micro_manager_metadata_file_path)