ignaciorlando / fundus-vessel-segmentation-tbme

In this work, we present an extensive description and evaluation of our method for blood vessel segmentation in fundus images based on a discriminatively trained, fully connected conditional random field model. Standard segmentation priors such as a Potts model or total variation usually fail when dealing with thin and elongated structures. We overcome this difficulty by using a conditional random field model with more expressive potentials, taking advantage of recent results enabling inference of fully connected models almost in real-time. Parameters of the method are learned automatically using a structured output support vector machine, a supervised technique widely used for structured prediction in a number of machine learning applications. Our method, trained with state of the art features, is evaluated both quantitatively and qualitatively on four publicly available data sets: DRIVE, STARE, CHASEDB1 and HRF. Additionally, a quantitative comparison with respect to other strategies is included. The experimental results show that this approach outperforms other techniques when evaluated in terms of sensitivity, F1-score, G-mean and Matthews correlation coefficient. Additionally, it was observed that the fully connected model is able to better distinguish the desired structures than the local neighborhood based approach. Results suggest that this method is suitable for the task of segmenting elongated structures, a feature that can be exploited to contribute with other medical and biological applications.
47 stars 15 forks source link

how to configure the variable 'thereAreLabelsInTheTestData' in script experiments massive script? #4

Closed PapaMadeleine2022 closed 7 years ago

PapaMadeleine2022 commented 7 years ago

I arranged the data sets and modified the corresponding variables, as `% Root dir where the data sets are located rootDatasets = '/home/xxx/work/vessel/'; % Root folder where the results are going to be stored variables.The rest are not been changed. rootResults = '/home/xxx/work/vessel/results';' rootDatasets and rootResults are only modified Then I run the code.But it shows error:

`Segmenting image number 1/10 Segmenting image number 2/10 Segmenting image number 3/10 Segmenting image number 4/10 Segmenting image number 5/10 Segmenting image number 6/10 Segmenting image number 7/10 Segmenting image number 8/10 Segmenting image number 9/10 Segmenting image number 10/10 Reference to non-existent field 'se'.

Error in getAverageMeasures2 (line 9) averageQualityMeasures.se = mean(qualityMeasures.se);

Error in learnCRFPotentials>findBestC (line 74) averageMeasures = getAverageMeasures2(currentQualityMeasures);

Error in learnCRFPotentials (line 16) [bestModel, qualityOverValidation, bestParam, ~] = findBestC(config, trainingdata, validationdata, better);

Error in learnConfiguredCRF (line 42) [model, qualityOverValidation, config] = learnCRFPotentials(config, trainingdata, validationdata);

Error in runVesselSegmentation (line 36) [model, config.qualityOverValidation, config] = learnConfiguredCRF(trainingdata, validationdata, config);

Error in script_experiments_massive (line 65) results{experiment,crfver} = runVesselSegmentation(config);`

I check and trace the code and find the problem seems to come to the variable 'thereAreLabelsInTheTestData' in script_experiments_massive script? How I handle this problem and run your code correctly? Thank you very much! Looking forward to your reply.

ignaciorlando commented 7 years ago

Hi!

Your data set folder should have this structure:

where images contains all the images you want to segment, masks contains their corresponding FOV masks and labels has all their corresponding ground truth annotations. Be sure that every all images within each of the folder are sorted in the same way.

The variable thereAreLabelsInTheTestData is hardcoded (yes, I know, that's terrible, I promise I will fix it soon). If your test data has a labels folder, then you can remove that line and replace it by:

thereAreLabelsInTheTestData = 1

That should fix the bug.

Good luck!

PapaMadeleine2022 commented 7 years ago

@ignaciorlando It works as you said above. Now another error occurs `ptimization finished. Best C=100.fMeasure=7.662812e-01 Best quality values se: 0.7015 sp: 0.9805 acc: 0.9432 precision: 0.8468 recall: 0.7015 fMeasure: 0.7663 matthews: 0.7392 dice: 0.7663 arias: 0.6813 scores: [2265875x1 single] auc: 0.9314 auc_pr: 0.8281 unaryPotentials: [] aucUP: NaN aucUP_pr: NaN qualities: [8x1 double] segs: {1x10 cell}

Loading labels from/home/congleng/work/vessel/DRIVE-MESSIDORsmall/training/labels Loading labels

Loading finished Extracting features from 1/20 Reference to non-existent field 'downsample_factor'.

Error in runVesselSegmentationUsingExistingModel (line 33) new_size_factor = config.downsample_factor;

Error in runVesselSegmentation (line 43) [results] = runVesselSegmentationUsingExistingModel(config, model);

Error in script_experiments_massive (line 67) results{experiment,crfver} = runVesselSegmentation(config); ` I check the code and can not find the field 'downsample_factor' for the variale 'config'. How to solve this peroblem?

ignaciorlando commented 7 years ago

I've just commited runVesselSegmentationUsingExistingModel with that bug solved. I used that parameter to work with images that differed in their size with respect to the training set for another paper, but this is not the case so it should work.

PapaMadeleine2022 commented 7 years ago

@ignaciorlando oops. Another same error `Loading labels from/home/congleng/work/vessel/DRIVE-MESSIDORsmall/training/labels Loading labels

Loading finished Extracting features from 1/20 Computing unary features Computing pairwise features Reference to non-existent field 'masks'.

Error in getBunchSegmentations2 (line 13) segmentations = cell(size(data.masks));

Error in runVesselSegmentationUsingExistingModel (line 75) [results.segmentations, results.qualityMeasures] = getBunchSegmentations2(config, testdata, model);

Error in runVesselSegmentation (line 43) [results] = runVesselSegmentationUsingExistingModel(config, model);`
Help me.

ignaciorlando commented 7 years ago

When I removed that piece of code that introduced the bug I forgot to save the mask on the testdata structure.

Try the new version now!

PapaMadeleine2022 commented 7 years ago

@ignaciorlando Another error occurs`Loading finished Extracting features from 1/20 Computing unary features Computing pairwise features Segmenting image number 1/1 Undefined function or variable 'original_size'.

Error in runVesselSegmentationUsingExistingModel (line 80) results.segmentations{i_s} = imresize(results.segmentations{i_s}, original_size, 'nearest');

Error in runVesselSegmentation (line 43) [results] = runVesselSegmentationUsingExistingModel(config, model);

Error in script_experiments_massive (line 67) results{experiment,crfver} = runVesselSegmentation(config);`

ignaciorlando commented 7 years ago

Try now!

PapaMadeleine2022 commented 7 years ago

@ignaciorlando another error `Loading finished Loading labels from/home/congleng/work/vessel/DRIVE/validation/labels Loading labels

Loading finished Extracting features from 1/20 Index exceeds matrix dimensions.

Error in extractFeatures (line 39) mask = imread(strcat(masksPath, filesep, mskNames{i})) > 0;

Error in runVesselSegmentation (line 14) [allfeatures, numberOfDeviations, ~, ~, ~] = extractFeatures(strcat(config.training_data_path, filesep, 'images'), ...

Error in script_experiments_massive (line 67) results{experiment,crfver} = runVesselSegmentation(config);`

And I organize the data set as you explained in the user_manual.pdf.

ignaciorlando commented 7 years ago

are you sure you have just 20 files inside the masks folder? If you have any other file there (or less files) if will blow, as the code assumes that the amount of images on each folder is the same.

PapaMadeleine2022 commented 7 years ago

@ignaciorlando The validation set must be necessary? Can we wipe off the validation set, and only use the test set to test. If the validation set is necessary,how to arrange it? As I do not know arrange the validation set, so I only copy the test set as validation set, and the name of image, labels,masks in validation directory is also same with the the name of image, labels,masks in test directory. What should I do?

ignaciorlando commented 7 years ago

If you see our TBME, the validation set is a subset extracted from the training set that is used to tune all the parameters of the model. If you put your test data in the validation folder, then the model you learn will underestimate the actual test error, because it is going to be adjusted with the same data that you will use for evaluation. What you should do is to remove some random images from the training set and put them on the validation set.

Despite of that, you should check that all folders (training, validation, test) have three folders inside (images, masks, labels) with the same amount of images inside (that is, e.g., 20 images, 20 masks and 20 labels, and no other files there except for the .mat files).

I couldn't reproduce your error so I guess that there might be some hidden fields in some of your folders. Please, control also the size of the mskNames array using the debugger and check if it is the same size than the imageNames array.

ignaciorlando commented 7 years ago

Did you manage to make this work? In that case, I will close the issue. Otherwise, let me know and I will see if I can help you :)

zhengxiaoxia717 commented 7 years ago

hi,I arranged the data sets and set config.thereAreLabelsInTheTestData = 1 as you said above. but Now another error occurs: Optimization finished. Best C=10.fMeasure=7.629845e-01 Best quality values se: 0.7373 sp: 0.9731 acc: 0.9434 precision: 0.7950 recall: 0.7373 fMeasure: 0.7630 matthews: 0.7329 dice: 0.7630 arias: 0.6931 scores: [2269632x1 single] auc: 0.9402 auc_pr: 0.8231 unaryPotentials: [] aucUP: NaN aucUP_pr: NaN qualities: [8x1 double] segs: {1x10 cell}

Field assignment to a non-structure array object.

Error in runVesselSegmentation (line 36) [model, config.qualityOverValidation, config] = learnConfiguredCRF(trainingdata, validationdata, config);

Error in script_experiments_massive (line 60) results{experiment,crfver} = runVesselSegmentation(config);

please help me,tanks very much!

zhengxiaoxia717 commented 7 years ago

please help me, thanks very much!

ignaciorlando commented 7 years ago

Hi @zhengxiaoxia717, I couldn't reproduce your issue, but I pushed a newer version of the segmentation method that works well (at least in my Macbook). Let me know if the error continues!

zhengxiaoxia717 commented 7 years ago

I will try to do it,thanks very much!

zhengxiaoxia717 commented 7 years ago

I tried to run your new version of the code, only changed two paths and run 'setup_segmentation_code.m'。but Now another error occurs,as a novice, I hope you can help me,thanks very much!

Field assignment to a non-structure array object.

Error in runVesselSegmentation (line 36) [model, config.qualityOverValidation, config] = learnConfiguredCRF(trainingdata, validationdata, config);

Error in script_experiments_massive (line 41) results{experiment,crfver} = runVesselSegmentation(config);

ignaciorlando commented 7 years ago

I'm sorry, I've just seen that you already had opened an issue here. Would you mind to open a new one? Your question is not related with this specific issue. I know it might be annoying to open a separate issue per each question, but that will help other people to easily find answers to common questions :)

Thanks a lot!