4D N2V training - patch height + photobleaching


  1. Why does the Patch Shape need to be a multiple of 16 instead of 8 for the Fiji implementation?
    In ZeroCostDL4Mic, they allow the patch_height to be factors of 4 which lets me do 3D N2V on my z-stacks with less than 16 planes.
# Here we check that patch_size is divisible by 8
if not patch_size % 8 == 0:
    patch_size = ((int(patch_size / 8)-1) * 8)
    print (bcolors.WARNING + " Your chosen patch_size is not divisible by 8; therefore the patch_size chosen is now:",patch_size)

# Here we check that patch_height is smaller than the z dimension of the image 
if patch_height > Image_Z :
  patch_height = Image_Z
  print (bcolors.WARNING + " Your chosen patch_height is bigger than the z dimension of your image; therefore the patch_size chosen is now:",patch_height)

# Here we check that patch_height is divisible by 4
if not patch_height % 4 == 0:
    patch_height = ((int(patch_height / 4)-1) * 4)
    if patch_height == 0:
      patch_height = 4
    print (bcolors.WARNING + " Your chosen patch_height is not divisible by 4; therefore the patch_size chosen is now:",patch_height)
  1. If my 4D datasets feature photobleaching, what’s the best course of action?
    My gut instinct is to compensate for this by having my training set includes z-stacks from many different time points. I would not think that doing a bleach correction and then N2V would lead to good results.


Hi @WillGiang,

@frauzufall could you help with the first question?
If you still want to use the Fiji implementation you could extend the images until they fit.

Regarding the second question I would also suggest to use training images across the whole time-range. To train N2V the noise has to be zero-mean and pixel-wise independent. As long as the bleach correction does not violate these to conditions, N2V should still work after bleach correction.
Another approach would be to train multiple networks, all on different bleach levels. Then you could apply all networks to all images and aggregate the results.

1 Like

Hi @tibuch,

Thanks for reaching out and giving your thoughts. If I can’t get the learning curves to look good with some tweaking, I’ll test bleach correction methods.

I’ll switch up my training set (currently half the time points for one acquisition) to see if I can get better learning curves.

I forgot to mention that each image has a couple of cells and the protein expression levels vary per cell as a result of transient transfection. I was hoping this would be advantageous, but maybe it isn’t.


The loss curves look okay to me. Nothing seems to go wrong. Would you be able to share a before-after-comparison, this would make it simpler to judge if N2V is working properly.