From 46e1e6ec8de7833dc21b8880bf99aed8b67c3012 Mon Sep 17 00:00:00 2001 From: aliceeeeeeeeee Date: Fri, 21 Feb 2025 20:17:04 +0100 Subject: [PATCH 1/2] pb saving channels separately on mac --- src/tapenade/reconstruction/_reconstruct.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tapenade/reconstruction/_reconstruct.py b/src/tapenade/reconstruction/_reconstruct.py index cf9f5f8..f7bd16f 100644 --- a/src/tapenade/reconstruction/_reconstruct.py +++ b/src/tapenade/reconstruction/_reconstruct.py @@ -149,14 +149,22 @@ def create_folders( os.mkdir(os.path.join(Path(folder_sample) / "weights", "before_trsf")) os.mkdir(os.path.join(Path(folder_sample) / "weights", "after_trsf")) - image_ref = io.imread(Path(folder_experiment) / f"{filename_ref}.tif") - image_float = io.imread( + # image_ref = io.imread(Path(folder_experiment) / f"{filename_ref}.tif") + # image_float = io.imread( + # Path(folder_experiment) / f"{filename_float}.tif" + # ) + image_ref = tifffile.imread(Path(folder_experiment) / f"{filename_ref}.tif") + image_float = tifffile.imread( Path(folder_experiment) / f"{filename_float}.tif" ) + + if len(channels) > 1: for ind_ch, ch in enumerate(channels): - imref = image_ref[:, :, :, ind_ch] - imfloat = image_float[:, :, :, ind_ch] + # imref = image_ref[:, :, :, ind_ch] + # imfloat = image_float[:, :, :, ind_ch] + imref=image_ref[:,ind_ch,:,:] + imfloat=image_float[:,ind_ch,:,:] io.imsave( Path(folder_sample) / "raw" / f"{filename_ref}_{ch}.tif", imref, ##CAREFUL needs to be float32 or uint16 orint16 otherwise the blockmatching does not compute/save the result From 88ce0dfea534c1bb2cfc74708c0829f9f1a7a2ca Mon Sep 17 00:00:00 2001 From: aliceeeeeeeeee Date: Wed, 25 Jun 2025 17:48:38 +0200 Subject: [PATCH 2/2] from Jules --- src/tapenade/preprocessing/_intensity_normalization.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tapenade/preprocessing/_intensity_normalization.py b/src/tapenade/preprocessing/_intensity_normalization.py index 00d1cf5..801c8bf 100644 --- a/src/tapenade/preprocessing/_intensity_normalization.py +++ b/src/tapenade/preprocessing/_intensity_normalization.py @@ -142,6 +142,14 @@ def _normalize_intensity( array_norm[sl_norm] ) / np.nanmedian(array[sl]) + if np.isnan(array_normalization_factor) or array_normalization_factor == 0 or np.isinf(array_normalization_factor): + print( + "Normalization factor is NaN or inf or zero. " + "Check whether the signals are not saturated by 0s." + ) + + array_normalization_factor = np.nanmean(array_norm[sl_norm]) / np.nanmean(array[sl]) + array_norm = array_norm / array_normalization_factor return array_norm