yaoppeng / U-Net_v2

202 stars 18 forks source link

MRI segmentation #5

Open zhangfeifei1-ab opened 7 months ago

zhangfeifei1-ab commented 7 months ago

I want to use this code to split the brain image, I want to enter a 2D slice and a 3D image, which part of the code should I change?

yaoppeng commented 7 months ago

For 3D, usually, the input is a 3D volume patch. You need to define your own 3D encoder, e.g., 3D UNet, obtain the hierarchical features, process the features with the SDI module, and send the processed features into the decoder, for instance:

f1, f2, f3, f4, f5, f6 = self.encoder(input)

... other process code

f61 = self.sdi_4([f1, f2, f3, f4, f5, f6], f6)
f51 = self.sdi_4([f1, f2, f3, f4, f5, f6], f5)
f41 = self.sdi_4([f1, f2, f3, f4, f5, f6], f4)
f31 = self.sdi_3([f1, f2, f3, f4, f5, f6], f3)
f21 = self.sdi_2([f1, f2, f3, f4, f5, f6], f2)
f11 = self.sdi_1([f1, f2, f3, f4, f5, f6], f1)

...

For 2D, you have two choices: 1) use all the resolutions, then you may need to change the encoder part to obtain all the resolutions; 2) use the 4× downsampled resolutions, no need to change to code. It depends on which will perform better on your own dataset.