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

Question about Vessel VTK #19

Open
braininahat opened this issue May 15, 2024 · 1 comment
Open

Question about Vessel VTK #19

braininahat opened this issue May 15, 2024 · 1 comment

Comments

@braininahat
Copy link

I tried replicating results from the paper on the DeepVesselNet synthetic dataset but my predictions look weird. Even what I'm assuming is the ground truth graph for a volume doesn't really seem to match when I visualize them. My first point of uncertainty with regard to data loading is as follows:

The VTK archive once unpacked looks like this:

vtk
    ├── 0
    │   ├── 1_arteries_final_1.vtk
    │   ├── 1_arteries_final_2.vtk
    │   ├── 1_arteries_final_3.vtk
    │   ├── 1_arteries_final_4.vtk
    │   ├── 1_arteries_final_5.vtk
    │   ├── 1_arteries_final_6.vtk
    │   ├── 1_arteries_final_7.vtk
    │   └── 1_arteries_final_8.vtk
    ├── 1
    │   ├── 1_arteries_final_10.vtk
    │   ├── 1_arteries_final_11.vtk
    │   ├── 1_arteries_final_12.vtk
    │   ├── 1_arteries_final_13.vtk
    │   ├── 1_arteries_final_14.vtk
    │   ├── 1_arteries_final_15.vtk
    │   ├── 1_arteries_final_16.vtk
    │   ├── 1_arteries_final_1.vtk
    │   ├── 1_arteries_final_2.vtk
    │   ├── 1_arteries_final_3.vtk
    │   ├── 1_arteries_final_4.vtk
    │   ├── 1_arteries_final_5.vtk
    │   ├── 1_arteries_final_6.vtk
    │   ├── 1_arteries_final_7.vtk
    │   ├── 1_arteries_final_8.vtk
    │   └── 1_arteries_final_9.vtk
    ├── 2
    │   ├── 1_arteries_final_10.vtk
    │   ├── 1_arteries_final_11.vtk
    │   ├── 1_arteries_final_12.vtk
    │   ├── 1_arteries_final_13.vtk
    │   ├── 1_arteries_final_14.vtk
    │   ├── 1_arteries_final_15.vtk
    │   ├── 1_arteries_final_16.vtk
    │   ├── 1_arteries_final_1.vtk
    │   ├── 1_arteries_final_2.vtk
    │   ├── 1_arteries_final_3.vtk
    │   ├── 1_arteries_final_4.vtk
    │   ├── 1_arteries_final_5.vtk
    │   ├── 1_arteries_final_6.vtk
    │   ├── 1_arteries_final_7.vtk
    │   ├── 1_arteries_final_8.vtk
    │   └── 1_arteries_final_9.vtk
    ├── 3
    │   ├── .
    │   ├── . 
    │   ├── .

The raw and seg files, however don't follow the same nested folder structure, instead being unpacked like this:

├── raw
│   ├── 100.nii.gz
│   ├── 101.nii.gz
│   ├── 102.nii.gz
│   ├── 103.nii.gz
│   ├── 104.nii.gz
│   ├── .
│   ├── . 
│   ├── .

Owing to this, the dataset preparation code in generate_data.py

    DATA_PATH = "./data/vessel_data/"

    img_folder = os.path.join(DATA_PATH, "raw")
    seg_folder = os.path.join(DATA_PATH, "seg")
    vtk_folder = os.path.join(DATA_PATH, "vtk")

    raw_files = []
    seg_files = []
    vtk_files = []

    for file_ in os.listdir(seg_folder):
        file_ = file_[:-7]
        raw_files.append(os.path.join(img_folder, file_+'.nii.gz'))
        seg_files.append(os.path.join(seg_folder, file_+'.nii.gz'))
        print(file_)
        vtk_files.append(os.path.join(vtk_folder, file_+'.vtk'))

fails for the VTK files since it doesn't account for the nested folder structure.

How I got around this is by doing:

    raw_files = natsorted(glob(f"{os.path.join(DATA_PATH, 'raw')}/*.nii.gz"))
    seg_files = natsorted(glob(f"{os.path.join(DATA_PATH, 'seg')}/*.nii.gz"))
    vtk_files = natsorted(
        glob(f"{os.path.join(DATA_PATH, 'vtk')}/*/*.vtk", recursive=True)
    )

What this gives me is:

[
    ('./data/vessel_data/raw/1.nii.gz', './data/vessel_data/seg/1.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_1.vtk'),
    ('./data/vessel_data/raw/2.nii.gz', './data/vessel_data/seg/2.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_2.vtk'),
    ('./data/vessel_data/raw/3.nii.gz', './data/vessel_data/seg/3.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_3.vtk'),
    ('./data/vessel_data/raw/4.nii.gz', './data/vessel_data/seg/4.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_4.vtk'),
    ('./data/vessel_data/raw/5.nii.gz', './data/vessel_data/seg/5.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_5.vtk'),
    ('./data/vessel_data/raw/6.nii.gz', './data/vessel_data/seg/6.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_6.vtk'),
    ('./data/vessel_data/raw/7.nii.gz', './data/vessel_data/seg/7.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_7.vtk'),
    ('./data/vessel_data/raw/8.nii.gz', './data/vessel_data/seg/8.nii.gz', './data/vessel_data/vtk/0/1_arteries_final_8.vtk'),
    ('./data/vessel_data/raw/9.nii.gz', './data/vessel_data/seg/9.nii.gz', './data/vessel_data/vtk/1/1_arteries_final_1.vtk'),
    ('./data/vessel_data/raw/10.nii.gz', './data/vessel_data/seg/10.nii.gz', './data/vessel_data/vtk/1/1_arteries_final_2.vtk'),
    .
    .
    .
]

I wanted to check if this is this is what the expected triplets of files would be?

@huangchieh
Copy link

At least the number of files in the vtk folder matches the raw folder. Did you figure it out? @braininahat Thank you.

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