frankkramer-lab / MIScnn

A framework for Medical Image Segmentation with Convolutional Neural Networks and Deep Learning
GNU General Public License v3.0
402 stars 116 forks source link

ValueError when i use brain data #40

Closed ssean819 closed 3 years ago

ssean819 commented 4 years ago

Hi, I use another nii data, and set

sf_resample = Resampling((1 ,1, 1))
interface = NIFTI_interface(pattern="case_00[0-9]*", 
                            channels=1, classes=2)

After I run cross_validation, I receive ValueError: need at least one array to concatenate

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
 in 
      3 # Run cross-validation function
      4 cross_validation(validation_samples, model, k_fold=2, epochs=3, iterations=150,
----> 5                  evaluation_path="evaluation", draw_figures=True,run_detailed_evaluation=True, callbacks=[cb_lr],save_models=True,return_output=False )

~\AppData\Local\Programs\Python\Python37\lib\site-packages\miscnn\evaluation\cross_validation.py in cross_validation(sample_list, model, k_fold, epochs, iterations, evaluation_path, draw_figures, run_detailed_evaluation, callbacks, save_models, return_output)
     91         # Make a detailed validation of the current cv-fold
     92         if run_detailed_evaluation:
---> 93             detailed_validation(validation, model, subdir)
     94     # Return the validation results
     95     if return_output : return validation_results

~\AppData\Local\Programs\Python\Python37\lib\site-packages\miscnn\evaluation\detailed_validation.py in detailed_validation(validation_samples, model, evaluation_path)
     49     for sample_index in validation_samples:
     50         # Predict the sample with the provided model
---> 51         model.predict([sample_index], return_output=False)
     52         # Load the sample
     53         sample = model.preprocessor.data_io.sample_loader(sample_index,

~\AppData\Local\Programs\Python\Python37\lib\site-packages\miscnn\neural_network\model.py in predict(self, sample_list, return_output, activation_output)
    155                 pred_batch = self.model.predict_on_batch(batch)
    156                 pred_list.append(pred_batch)
--> 157             pred_seg = np.concatenate(pred_list, axis=0)
    158             # Postprocess prediction
    159             pred_seg = self.preprocessor.postprocessing(sample, pred_seg,

<__array_function__ internals> in concatenate(*args, **kwargs)

ValueError: need at least one array to concatenate

Does anyone know how to fix this error?

muellerdo commented 4 years ago

Hey @ssean819,

sounds like there are some kind of incorrect prediction output. It is quite interesting that the training process is working, but you will get an error in the detailed validation/prediction, afterwards.

There are several points which I would recommend having a look into:

Could you give us some insights on these questions?

Cheers, Dominik

ssean819 commented 3 years ago

Hi

After several tests, I still can't find the problem. I have tried 3D-UNET and it was a success. By the way, my data is channel-last, I don't know this cause problem or not.

Can you specify on which sample this error occurs? This error occurred after run first all epochs in k_fold0.

Other problems I need time to check. But I know my image shape is not all the same as below.

case_00000 (512, 512, 76)
case_00001 (512, 512, 86)
case_00002 (197, 197, 200)
case_00003 (512, 512, 86)
case_00004 (217, 217, 150)
case_00005 (217, 217, 168)
case_00006 (512, 512, 86)
case_00007 (512, 512, 86)
case_00008 (512, 512, 86)
case_00009 (512, 512, 82)
case_00010 (512, 512, 96)

My MIScnn version is 1.0.0

muellerdo commented 3 years ago

Hey @ssean819,

sorry for the late reply.

After several tests, I still can't find the problem. I have tried 3D-UNET and it was a success.

Did you had a successful cross-validation on your data, once?

By the way, my data is channel-last, I don't know this cause problem or not.

No, it's perfect. MIScnn, same as Tensorflow, are based on a channel-last structure.

Could you please try to reproduce the error by just running a prediction with model.predict(sample_list) instead of running the cross-validation? Tip: You can run the prediction function without previous training. The predictions are of course random/garbage, but we will get the insight that we can reproduce the error with a simple prediction, as well.

Other problems I need time to check.

No problem. Keep me updated, please. I'm optimistic that we can find the error and setup a working MIS pipeline for you! :)

Cheers, Dominik

ssean819 commented 3 years ago

Hi,

I finally found that the problem is my data list. I input the wrong data list, so cross_validation can't read the file. very sorry about that.