now the hyperstack contains all the channels and enhances their contrast

This commit is contained in:
Guillaume Raffy 2019-03-29 11:57:52 +01:00
parent 7d116b4dca
commit 72011d47a4
1 changed files with 26 additions and 12 deletions

View File

@ -78,35 +78,45 @@ class Sequence(object):
def get_root_path(self):
return '/'.join(self.micro_manager_metadata_file_path.split('/')[:-1])
def get_image_file_path(self, channel_id, frame_index, z_index=0):
def get_image_file_path(self, channel_index, frame_index, z_index=0):
assert frame_index < self.num_frames
assert channel_index < self.num_channels
summary = self.mmm['Summary']
channel_index = summary['ChNames'].index(channel_id)
frame_info = self.mmm['FrameKey-%d-%d-%d' % (frame_index, channel_index, z_index) ]
rel_file_path = frame_info['FileName']
return self.get_root_path() + '/' + rel_file_path
def get_channel_index(self, channel_id):
summary = self.mmm['Summary']
channel_index = summary['ChNames'].index(channel_id)
return
def open_in_imagej(self):
#ip = IJ.createHyperStack(title=self.sequence_id, width=self.width, height= self.height, channels=1, slices=1, frames=self.get_num_frames(), bitdepth=16)
hyperstack = IJ.createHyperStack(self.sequence_id, self.width, self.height, self.num_channels, self.num_slices, self.num_frames, self.num_bits_per_pixels)
for channel_index in range(1): #self.num_channels):
for channel_index in range(self.num_channels):
for frame_index in range(self.num_frames):
slice_index = 0
src_image_file_path = self.get_image_file_path(channel_id='DM300_327-353_fluo', frame_index=frame_index)
src_image_file_path = self.get_image_file_path(channel_index=channel_index, frame_index=frame_index)
# print(src_image_file_path)
src_image = IJ.openImage(src_image_file_path)
hyperstack.setPosition(channel_index+1, slice_index+1, frame_index+1)
# print(src_image.getProperties())
hyperstack.setPositionWithoutUpdate(channel_index+1, slice_index+1, frame_index+1)
hyperstack.setProcessor(src_image.getProcessor())
hyperstack.show()
for channel_index in range(self.num_channels):
hyperstack.setPositionWithoutUpdate(channel_index+1, 1, 1)
IJ.run("Enhance Contrast", "saturated=0.35")
class ImageCatalog(object):
def __init__(self, raw_images_root):
self.raw_images_root = raw_images_root
self.sequences = { }
sequence_id = 'GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0'
micro_manager_metadata_file_path = raw_images_root + '/' + sequence_id + '/metadata.txt'
#micro_manager_metadata_file_path = '/tmp/toto.json'
self.sequences[ sequence_id ] = Sequence(self, sequence_id, micro_manager_metadata_file_path)
for sequence_id in ['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0', 'GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2']:
micro_manager_metadata_file_path = raw_images_root + '/' + sequence_id + '/metadata.txt'
#micro_manager_metadata_file_path = '/tmp/toto.json'
self.sequences[ sequence_id ] = Sequence(self, sequence_id, micro_manager_metadata_file_path)
def __str__(self):
for sequence_id, sequence in self.sequences.iteritems():
@ -121,9 +131,13 @@ def run_script():
catalog = ImageCatalog(raw_images_root)
print(catalog)
catalog.sequences['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0'].open_in_imagej()
catalog.sequences['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2'].open_in_imagej()
if False:
sequence = catalog.sequences['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0']
src_image_file_path = sequence.get_image_file_path(channel_index=sequence.get_channel_index('DM300_327-353_fluo'), frame_index=3)
src_image = IJ.openImage(src_image_file_path)
#src_image_file_path = catalog.sequences['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0'].get_image_file_path(channel_id='DM300_327-353_fluo', frame_index=3)
#src_image = IJ.openImage(src_image_file_path)
#dark_image = IJ.openImage(raw_images_root + '/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0/img_000000000_DM300_327-353_fluo_000.tif')
#src_image.show()
#assert src_image