BAAI-DCAI / SegVol

The official code for "SegVol: Universal and Interactive Volumetric Medical Image Segmentation".
MIT License
208 stars 21 forks source link

DICOM FILE #3

Closed JoshuaYang0926 closed 9 months ago

JoshuaYang0926 commented 9 months ago

I encountered a problem when running the demo.... zzzz "File is missing DICOM File Meta Information header or the 'DICM' " Traceback (most recent call last): File "inference_demo.py", line 221, in main(args) File "inference_demo.py", line 208, in main data_item = process_ct_gt(ct_path, gt_path, categories, args.spatial_size) # keys: image, label

"File is missing DICOM File Meta Information header or the 'DICM' "

pydicom.errors.InvalidDicomError: File is missing DICOM File Meta Information header or the 'DICM' pre
fix is missing from the header. Use force=True to force reading.

Yuxin-Du-Lab commented 9 months ago

Thanks for your support!

Could you please show more information about your setting of config_demo.json and your demo case file? Our data loading process is default to load nii.gz files(DICM file is also supported by MONAI with some simple modify).

JoshuaYang0926 commented 9 months ago

{ "dataset_name": "AbdomenCT-1k", "categories": ["liver", "kidney", "spleen", "pancreas"], "demo_case": { "ct_path": "/home/SegVol-main/path/to/Case_image", "gt_path": "/home/SegVol-main/path/to/Case_label" } } Thanks for your reply!Maybe I need to add the absolute path to the data? Like this "/home/SegVol-main/path/to/Case_image/Case_image_00001_0000.nii.gz"

After setting it up like this, I encountered a data normalization problem. Is monai's data normalization only suitable for tensor data? ct_voxel_ndarray = ct_narray.copy() AttributeError: 'MetaTensor' object has no attribute 'copy'

Yuxin-Du-Lab commented 9 months ago

'MetaTensor' is the special tensor type of MONAI. In SegVol code, we discard the meta_dict temporally in ct_voxel_ndarray, _ = img_loader(case_path). Maybe you have edited the transform pipeline?

JoshuaYang0926 commented 9 months ago

Well, I did not modify the transform code. I check both of them "ct_voxelndarray, = img_loader(case_path)",it displays all <class 'monai.data.meta_tensor.MetaTensor'> types. Maybe the question is about "img_loader = transforms.LoadImage()", and my "demo_case": { "ct_path": "/home/SegVol-main/path/to/Case_image/Case_image_00001_0000.nii.gz", "gt_path": "/home/SegVol-main/path/to/Case_label/Case_label_00001.nii.gz" is right? Thank you.

Yuxin-Du-Lab commented 9 months ago

Firstly, the demo_case config is right if you set the right '/path/to' of image and label paths of nii.gz files.

Then, ct_voxel_ndarray, _ = img_loader(case_path) seems behave different from our expection. I think you can modify the pipline based on your MONAI environment:

  1. load the nii.gz file into memory
  2. extract its array and translate it into numpy array
  3. input the numpy array to the follow pipeline: raw data here and ground truth here

I think this is equivalent to the original code.

JoshuaYang0926 commented 9 months ago

I solved the bugs that MONAI brought to me, and now the test demo can be used normally. The effect of organ segmentation is really good! Also, I would like to try out the effect of lesion segmentation and I would like to know how to use text prompt words, can you provide some suggestions?! Thank you! 😄

Yuxin-Du-Lab commented 9 months ago

It's exciting to see that you can run the code!

For the text prompt group, you can edit it here for a new case in new dataset. Notice that the order of the categories should be corresponding to the Ground Truth index of the new dataset and please ignore the background category.

For a single text prompt, you can delete the for loop to just inference a specific category. At the same time, you should assign your text prompt word to text_single. You can use 'lung tumor', 'colon cancer' or 'liver tumor' etc. as your lesion text prompt word.

Finally, I strongly recommend you to try the web demo first. You can just upload your case and try any possible prompt to play with SegVol.😋

JoshuaYang0926 commented 9 months ago

Looking forward to your follow-up work and thanks for your help! 🥳