Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Scan files are None, please check the data directory" #18

Closed
lraguiars opened this issue Feb 1, 2023 · 4 comments
Closed

"Scan files are None, please check the data directory" #18

lraguiars opened this issue Feb 1, 2023 · 4 comments

Comments

@lraguiars
Copy link

Hello Jia,

Congratulations on the package. It is fantastic!

I want to analyze some metrics (like dice coefficient and Hausdorff distance), but it is showing this error below:

Traceback (most recent call last):
  File "/home/brainsmclab/Desktop/Luan_Doctorate/Disconnection_MyDataset/lesionmasks_reliability/segmentation_metrics/script_metrics.py", line 24, in <module>
    metrics = sg.write_metrics(labels=labels[1:],  # exclude background
  File "/home/brainsmclab/anaconda3/lib/python3.9/site-packages/seg_metrics/seg_metrics.py", line 295, in write_metrics
    gdth_names, pred_names = get_gdth_pred_names(gdth_path, pred_path)
  File "/home/brainsmclab/anaconda3/lib/python3.9/site-packages/medutils/medutils.py", line 241, in get_gdth_pred_names
    gdth_files, pred_files = get_ct_pair_filenames(gdth_path, pred_path)
  File "/home/brainsmclab/anaconda3/lib/python3.9/site-packages/medutils/medutils.py", line 160, in get_ct_pair_filenames
    gdth_files = get_all_ct_names(gdth_path)
  File "/home/brainsmclab/anaconda3/lib/python3.9/site-packages/medutils/medutils.py", line 150, in get_all_ct_names
    raise Exception(f'Scan files are None, please check the data directory: {path}')
Exception: Scan files are None, please check the data directory: ~/Desktop/Luan_Doctorate/Disconnection_MyDataset/lesionmasks_reliability/segmentation_metrics/lesoes_milene/

My files are CT lesion masks from two examiners (".nii" format; n=20 patients per examiners).

My code:

# Import packages
import medpy
import medpy.metric
import numpy as np
import seg_metrics.seg_metrics as sg
import SimpleITK as sitk
import matplotlib.pyplot as plt
import copy
from skimage import measure, morphology
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import time
import gdown
import pandas as pd


labels = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

gdth_path = '~/Desktop/Luan_Doctorate/Disconnection_MyDataset/lesionmasks_reliability/segmentation_metrics/lesoes_milene/'

pred_path = '~/Desktop/Luan_Doctorate/Disconnection_MyDataset/lesionmasks_reliability/segmentation_metrics/lesoes_luan/'

csv_file = 'metrics.csv'

metrics = sg.write_metrics(labels=labels[1:],  # exclude background
                  gdth_path=gdth_path,
                  pred_path=pred_path,
                  csv_file=csv_file)

print(metrics)  # a list of dictionaries which includes the metrics for each pair of image.

Could you help me with this problem?

Many thanks,
Luan.
aguiar.luan@usp.br

@Jingnan-Jia
Copy link
Owner

Hi Luan,

Sorry for the late reply.

  1. Normally the reason of the issue is that the file names of two folders are different. So the program did not know which prediction corresponded to which ground truth. Please check if you set the file name correctly.
  2. It seems that you would like to calculate 20 pairs of cases, right? Then, you need to put 20 binary prediction to one folder, and put the other 20 binary ground truth to another folder. Note: the file names should be the same between the two folders. For instance, "prediction/1.nii, prediction/2.nii, ..." and "ground_truth/1.nii, ground_truth/2.nii, ..."
  3. labels = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] this line may be wrong. Because the labels should be [0,1] for binary image metrics calculation. 0 means backgournd and 1 means foreground if your ground truth and prediction is binarized with 0 and 1.

If you still have question please let me know.

@lraguiars
Copy link
Author

Hi Jingnan,

I did it !! That was the problem "~". (as you told me)
Thank you very much for everything.

Best,
Luan.

@Jingnan-Jia
Copy link
Owner

Hi Luan,

I fixed the issue. Now once you run “pip install seg-metrics --upgrade”, you can run you original code even you used the “~” sign in your path.

@lraguiars
Copy link
Author

Hi Jingnan,

Thank you very much !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants