now the code shows more clearly what it intends to do : attempts to find the white reference.
This commit is contained in:
parent
21c0fd56ad
commit
57b3f2e074
39
lipase.py
39
lipase.py
|
@ -287,6 +287,8 @@ class Lipase(object):
|
|||
src_median_value = self.get_image_median_value(src_image)
|
||||
normalized_src_processor = src_image.getProcessor().convertToFloat()
|
||||
normalized_src_processor.multiply(1.0 / src_median_value)
|
||||
best_diff = None
|
||||
best_z_index = None
|
||||
for z_index in range(white_sequence.num_slices):
|
||||
white_image_file_path = white_sequence.get_image_file_path(channel_index=0, frame_index=0, z_index=z_index)
|
||||
white_image = IJ.openImage(white_image_file_path)
|
||||
|
@ -306,8 +308,8 @@ class Lipase(object):
|
|||
difference_image = ic.run("sub create float", normalized_src, normalized_white)
|
||||
# self.debugger.on_image(imp3, 'diff')
|
||||
|
||||
self.debugger.on_image(normalized_white, 'normalized_white')
|
||||
self.debugger.on_image(difference_image, 'difference_image')
|
||||
# self.debugger.on_image(normalized_white, 'normalized_white')
|
||||
# self.debugger.on_image(difference_image, 'difference_image')
|
||||
|
||||
# imp2mat = ImagePlusMatConverter()
|
||||
# white_mat = imp2mat.toMat(white_image.getProcessor())
|
||||
|
@ -316,6 +318,10 @@ class Lipase(object):
|
|||
sqdiff_image = ic.run("mul create float", difference_image, difference_image)
|
||||
mean_sqdiff = self.get_image_mean_value(sqdiff_image)
|
||||
print('difference : ', mean_sqdiff)
|
||||
if best_diff is None or mean_sqdiff < best_diff:
|
||||
best_diff = mean_sqdiff
|
||||
best_z_index = z_index
|
||||
return best_z_index
|
||||
|
||||
def compute_sequence_median_image(self, sequence, channel_id='DM300_nofilter_vis'):
|
||||
''' computes for each pixel its median value along time, so that in the end we have a single image that only shows structures (things that don't move such as the traps)
|
||||
|
@ -336,27 +342,30 @@ class Lipase(object):
|
|||
background_image.show()
|
||||
return background_image
|
||||
|
||||
def test_uniformization(self, sequence):
|
||||
white_seq = sequence.get_white()
|
||||
channel_index = sequence.get_channel_index('DM300_327-353_fluo')
|
||||
src_image_file_path = sequence.get_image_file_path(channel_index=channel_index, frame_index=0, z_index=0)
|
||||
src_image = IJ.openImage(src_image_file_path)
|
||||
# src_image = IJ.openImage(src_image_file_path)
|
||||
self.find_depth_index(src_image, white_seq)
|
||||
|
||||
def process_sequence(self, sequence_id):
|
||||
'''
|
||||
:param str sequence_id:
|
||||
'''
|
||||
sequence = self.catalog.sequences[sequence_id]
|
||||
self.extract_background(sequence)
|
||||
raise NotImplementedError()
|
||||
|
||||
self.test_uniformization(sequence)
|
||||
|
||||
def test_find_white():
|
||||
lipase = Lipase(debugger=ImageLogger())
|
||||
sequence = lipase.catalog.sequences['res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2']
|
||||
white_seq = sequence.get_white()
|
||||
channel_index = sequence.get_channel_index('DM300_327-353_fluo')
|
||||
src_image_file_path = sequence.get_image_file_path(channel_index=channel_index, frame_index=0, z_index=0)
|
||||
src_image = IJ.openImage(src_image_file_path)
|
||||
# src_image = IJ.openImage(src_image_file_path)
|
||||
depth_index = lipase.find_depth_index(src_image, white_seq)
|
||||
|
||||
|
||||
def run_script():
|
||||
lipase = Lipase(debugger=ImageLogger())
|
||||
lipase.process_sequence('res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2')
|
||||
test_find_white()
|
||||
|
||||
if False:
|
||||
lipase = Lipase(debugger=ImageLogger())
|
||||
lipase.process_sequence('res_soleil2018/GGH/GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos2')
|
||||
|
||||
if False:
|
||||
sequence = lipase.catalog.sequences['GGH_2018_cin2_phiG_I_327_vis_-40_1/Pos0']
|
||||
|
|
Loading…
Reference in New Issue