Skip to content
Snippets Groups Projects
Commit fe69da08 authored by Hugo chauvet's avatar Hugo chauvet
Browse files

WTF, when their is a visible channel in the White, try to add that option

parent 91891f60
No related branches found
No related tags found
No related merge requests found
...@@ -72,7 +72,7 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' , ...@@ -72,7 +72,7 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' ,
white = mmzarr_read(str(whitein)) white = mmzarr_read(str(whitein))
meta_white = read_mmzarr_metadata(str(whitein)) meta_white = read_mmzarr_metadata(str(whitein))
dofwhite = mmzarr_read(str(darkofwhitein)) dofwhite = mmzarr_read(str(darkofwhitein))
white_ch_names = get_channel_names(meta_white)
images = mmzarr_read(str(imagesin)) images = mmzarr_read(str(imagesin))
meta = read_mmzarr_metadata(str(imagesin)) meta = read_mmzarr_metadata(str(imagesin))
...@@ -286,8 +286,16 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' , ...@@ -286,8 +286,16 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' ,
if version == 2: if version == 2:
print('Two steps normalisation: Spectral power from the mean, then spatial variation of the white') print('Two steps normalisation: Spectral power from the mean, then spatial variation of the white')
assert original_white is not None, "Please provide a non-smoothed white" assert original_white is not None, "Please provide a non-smoothed white"
# Estimation of the power # Estimation of the power
owhite = mmzarr_read(str(original_white))[0, 0, :, zpos].map_blocks(img_as_float) owhite = mmzarr_read(str(original_white))[0, 0, :, zpos].map_blocks(img_as_float)
# Fin the position of the white
i_viswhite = [i for i, wchname in enumerate(white_ch_names) if 'vis' in wchname]
if len(i_viswhite) > 0:
print("Their is a visible channel in white, I remove it !")
owhite = dask.array.delete(owhite, i_viswhite[0])
whiteMean = owhite.mean(axis=(-2,-1)) whiteMean = owhite.mean(axis=(-2,-1))
powerEstimation = whiteMean / whiteMean.max() powerEstimation = whiteMean / whiteMean.max()
powerEstimation = powerEstimation.compute() powerEstimation = powerEstimation.compute()
...@@ -359,7 +367,11 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' , ...@@ -359,7 +367,11 @@ def correct_dark_white(images: str, dark: str = '', white: str = '' ,
diff_im_darks[diff_im_darks < 0 ] = 0 diff_im_darks[diff_im_darks < 0 ] = 0
if version == 2: if version == 2:
# Need to find the visible to put it's power to one powerEallfilter = np.copy(powerEstimation)
# Check if the white has the same number of filter that the images
if diff_im_darks.shape[2] != len(powerEstimation):
# If not Need to find the visible to put it's power to one
i_vis=0 i_vis=0
for chan in range(diff_im_darks.shape[2]): for chan in range(diff_im_darks.shape[2]):
if 'vis' in img_ch_names[chan].lower(): if 'vis' in img_ch_names[chan].lower():
......
...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" ...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "DITB" name = "DITB"
version = "20250115rc3" version = "20250115rc4"
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"
authors = [{ name = "Hugo Chauvet", email = "hugo.chauvet@synchrotron-soleil.fr" }] authors = [{ name = "Hugo Chauvet", email = "hugo.chauvet@synchrotron-soleil.fr" }]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment