NifTK / NiftyNet

[unmaintained] An open-source convolutional neural networks platform for research in medical image analysis and image-guided therapy
http://niftynet.io
Apache License 2.0
1.36k stars 404 forks source link

Niftynet window aggregator function for inferens - explaination needed #485

Open jamtheim opened 4 years ago

jamtheim commented 4 years ago

Dear Niftynet, I work as a Medical Physicist and is also a part time researcher I hope I could get some help from you to explain a couple of things for me. I am working on a medical segmentation problem in Niftynet using the highres3dnet_large model. Model training has been performed and inference is working fine. I use the argument output_prob = True to get probability values as output. My spatial_window_size for training is (96, 96, 32) and for inference it is (256, 256, 32) and the border is (36, 36, 0)

I have now been asked to provide details on my work for a paper in a scientific journal and have some problems with finding this information. I am specifically wondering how the window aggregator function is used to concatenate the (256, 256, 32) patches to get the full size output (which is the same as the input volume. The input can for example be a 512,512,34 volume.

Will the patches overlap (especially in slice direction, 32 vs 34?) and how will the voxel labels be assigned in this case? I dont really understand whats going on in the log, as it reports "yielding 27 locations from image, extended to 28 to be divisible by batch size 2". How does it calculate 27?

Thankful for clarificaion

This is my Network and Inference ini blocks

[NETWORK] window_sampling=balanced name=highres3dnet_large activation_function=relu batch_size=2 reg_type=L2 decay=0 volume_padding_size=(2,2,4) whitening=True normalisation=False queue_length=200

[INFERENCE] border = (36, 36, 0) output_interp_order = 3 save_seg_dir=./output/ spatial_window_size = (256, 256, 32)

This is my inferens log. Please observe that grid sampling image sizes has been adjusted with padding.

INFO:niftynet:2019-12-16 19:50:57,251: using HighRes3DNet INFO:niftynet:2019-12-16 19:50:57,255: Initialising dataset from generator... INFO:niftynet:2019-12-16 19:50:58,547: Restoring parameters from model.ckpt-40000 INFO:niftynet:2019-12-16 19:51:04,887: grid sampling image sizes: {'image': (516, 516, 39, 1, 8)} INFO:niftynet:2019-12-16 19:51:04,888: grid sampling window sizes: {'image': (256, 256, 32, 1, 8)} INFO:niftynet:2019-12-16 19:51:04,888: yielding 27 locations from image, extended to 28 to be divisible by batch size 2 INFO:niftynet:2019-12-16 19:51:12,211: inference iter 0, (13.027967s) INFO:niftynet:2019-12-16 19:51:13,310: grid sampling image sizes: {'image': (516, 516, 39, 1, 8)} INFO:niftynet:2019-12-16 19:51:13,310: grid sampling window sizes: {'image': (256, 256, 32, 1, 8)} INFO:niftynet:2019-12-16 19:51:13,310: yielding 27 locations from image, extended to 28 to be divisible by batch size 2 INFO:niftynet:2019-12-16 19:51:13,506: inference iter 1, (1.292637s) INFO:niftynet:2019-12-16 19:51:14,779: inference iter 2, (1.269639s) INFO:niftynet:2019-12-16 19:51:16,049: inference iter 3, (1.267508s) INFO:niftynet:2019-12-16 19:51:17,306: inference iter 4, (1.253983s) INFO:niftynet:2019-12-16 19:51:18,558: inference iter 5, (1.249202s) INFO:niftynet:2019-12-16 19:51:19,811: inference iter 6, (1.250639s) INFO:niftynet:2019-12-16 19:51:21,065: inference iter 7, (1.250881s) INFO:niftynet:2019-12-16 19:51:22,332: inference iter 8, (1.263058s) INFO:niftynet:2019-12-16 19:51:22,351: grid sampling image sizes: {'image': (516, 516, 41, 1, 8)} INFO:niftynet:2019-12-16 19:51:22,351: grid sampling window sizes: {'image': (256, 256, 32, 1, 8)} INFO:niftynet:2019-12-16 19:51:22,351: yielding 27 locations from image, extended to 28 to be divisible by batch size 2 INFO:niftynet:2019-12-16 19:51:23,626: inference iter 9, (1.291930s) INFO:niftynet:2019-12-16 19:51:24,899: inference iter 10, (1.270194s) INFO:niftynet:2019-12-16 19:51:26,170: inference iter 11, (1.267833s) INFO:niftynet:2019-12-16 19:51:27,422: inference iter 12, (1.249997s) INFO:niftynet:2019-12-16 19:51:28,685: inference iter 13, (1.259580s) INFO:niftynet:2019-12-16 19:51:30,490: inference iter 14, (1.267340s) INFO:niftynet:2019-12-16 19:51:31,424: grid sampling image sizes: {'image': (516, 516, 41, 1, 8)}