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.37k stars 404 forks source link

Labels of multi-classes segmentation using holisticnet #46

Closed enzo-cin closed 6 years ago

enzo-cin commented 6 years ago

Dear all, I used holisticnet_config.ini for BRATS segmentation, but the output has 2 value: 0,1 ( for BG and Foreground). My histogram_ref_file file is : labellabelto 0 1 2 3 4 labellabelfrom 0 1 1 1 1 I would like to see the output with labels of each class. Do you know something wrong with my setup? Thanks.

Zach-ER commented 6 years ago

Hi there, It seems like you might have some settings wrong. Try:

num_classes=4

label_normalisation=True

Under the [SEGMENTATION] heading and see what happens?

enzo-cin commented 6 years ago

Thanks for your answer @Zach-ER.

I tried to change num_classes =4, but I doesn't work, here is the message: InvalidArgumentError (see above for traceback): indices[36977] = [36977,4] is out of bounds: need 0 <= index < [331776,4] [[Node: worker_0/loss_function/SparseToDense = SparseToDense[T=DT_FLOAT, Tindices=DT_INT64, validate_indices=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](worker_0/loss_function/stack, worker_0/loss_function/SparseTensor/dense_shape, worker_0/loss_function/ones, worker_0/loss_function/SparseToDense/default_value)]]

I think the num_classes = 5 is fine. I'm worry about the histogram_ref_file parameter.

Zach-ER commented 6 years ago

How did you generate that histogram reference file?

enzo-cin commented 6 years ago

I just copied the same file of Unet.

Zach-ER commented 6 years ago

I would delete the histogram reference file, and let the network generate its own, and see what happens then.

enzo-cin commented 6 years ago

If I remove only histogram_ref_file, every voxel = 0 in all of test cases.

If I remove other parameters of normalisation FG : _histogram_ref_file = normalisation = whitening =
normalise_foreground_only= foreground_type = multimod_foregroundtype = --->The output is 0,1 for BG and FG_

I'm worry about the fusion layer (line 181-190 in network/holisticnet.py) # FUSED SCALES merge_layer = MergeLayer('WEIGHTED_AVERAGE') soft_scores = [] for s in scores_instances: soft_scores.append(tf.nn.softmax(s)) fused_score = merge_layer(soft_scores) scores_instances.append(fused_score) if is_training: return scores_instances return fusedscore

Please tell me your experience, thanks.

wyli commented 6 years ago

I used these in histogram_ref_file for BRATS17 data

labellabelfrom 0 1 2 4 
labellabelto 0 1 2 3 

with num_classes = 4 and label_normalisation = True

enzo-cin commented 6 years ago

Thanks @wyli for your reply. In the case, I would to see all of 5 classes, I also try with:
labellabelfrom 0 1 2 3 4 labellabelto 0 1 2 3 4 but, It always give me the output .nii.gz with 0,1 values.

Can I ask other question? If I set output_prob = True, how can I get the probability maps of each class when the output is an 4d image .nii.gz? Thank you.

Zach-ER commented 6 years ago

You will get an output where the final dimension is the probability-dimensions (in this case, a 5-d nifti file). For some viewers, you may have to remove the singleton dimension in the image file for it to display properly (e.g. mrtrix).

andreasstefani commented 5 years ago

I used these in histogram_ref_file for BRATS17 data

labellabelfrom 0 1 2 4 
labellabelto 0 1 2 3 

with num_classes = 4 and label_normalisation = True

I am using the BraTS 2018 dataset with nearly the same content in histogram_ref_file. The difference is that my file maps [0] to 0, and [0, 1, 2, 4] to 1 (for whole tumour segmentation, so num_classes = 2 under [SEGMENTATION]). According to the documentation, the parameter histogram_ref_file will be not ignored when normalisation=True. However, when normalisation=True, the inference segmentation is worse. Therefore, I decided to set normalisation=False because it is better.

Does NiftyNet use the labels (from, to) in histogram_ref_file even when normalisation=False? According to the documentation, the parameter histogram_ref_file will be ignored.

Thank you.