Louisvh / cycle_consistent_INR

Code accompanying the 2023 paper 'Robust deformable image registration using cycle-consistent implicit representations' (IEEE Transactions on Medical Imaging)
12 stars 1 forks source link

Question about the mask #4

Open mlyang23 opened 5 months ago

mlyang23 commented 5 months ago

Thank you for your response. I still have some confusion. It seems that lungmask has requirements for the data range. The 4DCT dataset, such as case1_T00.img, is read as int16 data ranging from 0 to several thousand. I would like to know how you handle them to use the lungmask library. My results seem to be not good. Here is some of my code:

path = 'D:\data_dir\Case8pack\Images\case8_T00.img'

shape = [128, 512, 512] dtype = np.dtype(np.int16) with open(path, "rb") as f: data = np.fromfile(f, dtype) data = data.reshape(shape)

data_float32 = data.astype(np.float32) inferer = LMInferer(modelname="LTRCLobes")

data_normal = data_float32 / np.max(data) * 2048 - 1024 data_normal = sitk.GetImageFromArray(data_normal) segmentation = inferer.apply(data_normal)

Thanks for your patience :)

Louisvh commented 5 months ago

Lungmask expects HU values. It automatically clips values over 600 and scales the images by a factor 1624 before running the network. There are a few pixels in the high thousands in the DIRLab set (likely some sort of reconstruction artifacts), but these are automatically ignored by lungmask. Lungmask does not support operating on normalized images by default, so your normalization is causing your issues.

The DIRLAB data should just contain HU values; you can plot a histogram to see what's in there and check if anything goes wrong with your loading.