JunMa11 / SegLossOdyssey

A collection of loss functions for medical image segmentation
Apache License 2.0
3.81k stars 602 forks source link

Dataset issue, can help! #13

Closed Sayantan17 closed 4 years ago

Sayantan17 commented 4 years ago

Hey Jun. @JunMa11 I hope you are fine. I thought I shall ask you as you have already tried the dataset conversion from Fabian's repo. So, I download the cardiac data from ACDC, they have training repo, but when I ran the code (for ACDC data-preparation) fromhis repo, it's throwing the error. I can't use the Hackathon data, as it has got only 30 set. Can you please clarify whether it's the right process? I just need to convert the data, ans strip the 4D to 3D.

JunMa11 commented 4 years ago

Hi @Sayantan17 ,

Unfortunately, I do not use the conversion function in nnUNet. I usually write the conversion function by myself.

If I understand your question right, you want to convert 4D data to 3D, right?

I usually extract one channel to obtain the 3D volume.

import nibabel as nib
img_4D = nib.load('path to 4D data').get_fdata()
img_3D = img_4D[:,:,:,0]
Sayantan17 commented 4 years ago

Thx Jun, That's what I tried. Can you please help me to write that for ACDC dataset, I am whole lot confused by its file & structure. We could upload that to the repo for users. I mean the 4D to 3D, and saving thr data, and GT. Let me know.

JunMa11 commented 4 years ago

Hi @Sayantan17 ,

I do not have the exact code for ACDC and I do not work with it this year.

However, it is easy to save the data

import nibabel as nib
img_4D_nii = nib.load('path to 4D data')
img_4D = img_4D_nii.get_fdata()
img_3D = img_4D[:,:,:,0]
nib.save(nib.Nifti1Image(img_3d, img_4D_nii.affine, img_4D_nii.header), 'path/save_name')