zl376 / segDGM_CNN

Segment Deep Gray Matter on QSM images using 3D CNN
https://medium.com/@zheliu
18 stars 12 forks source link

More information about the methodology #2

Open meyerzinn opened 5 years ago

meyerzinn commented 5 years ago

I am trying to use your model to segment a QSM and I have a few questions:

  1. Is the data used for training the model available somewhere? That would really help me reorient the data for inference.
  2. I get no output labels when running chi_cosmos from the 2016 QSM Challenge data (intensities in the range [-0.264, 0.39]). I tracked down the source of the problem to the scale function, which seems to map every number to either 127 or 128 (because adding 250 to n<1 and then dividing by 500 yields 0.5 plus or minus n/500), but the comment implies it should be mapping uniformly to 0-255 (or 256?).
def scale(img, window):
    val_min, val_max = window

    res = np.copy(img)
    res[res < val_min] = val_min
    res[res > val_max] = val_max

    res = (res - val_min) / (val_max - val_min)

    res = (res * 256).astype(int)
    res[res == 256] = 255

    return res

What is scale supposed to do, and what does window represent? I tried changing the function to do a true linear mapping:

def scale(img):
    res = img.copy().astype(np.float)
    val_min, val_max = img.min(), img.max()
    res = (res - val_min) / (val_max - val_min) * 255.0
    return res.astype(np.uint8)

which normalizes the data to the range [0, 255]. That gave me at least some output (which looks half-decent).

  1. Is there a reason that the built-in Keras convolution layers wouldn't work with the raw NIfTI image as an input? I noticed you wrote lots of code to split the image into slices to analyse and I was wondering if using a Conv3D layer could achieve the same effect.

Thank you for making your work public.

meyerzinn commented 5 years ago

I ran the model against the MEDI sample data and got good results, so I presume the window is referring to how 99.99% of the values are within [-250, 250] for MEDI. This does not generalize across datasets (especially if using another program for reconstruction), so I'm experimenting with using a zscore-thresholding mechanism to remove outliers.