upload .nii files to kaggle

280 Views Asked by At

I am working on some mri images that have .nii.gz form, and their respective masks that are .nrrd type. I ziped the folders containing the images and the masks and uploaded them on kaggle. The masks work file, but the the notebook does not seem to recognize the patient files, but you can see them on the file explorer on the right of the notebook, as empty folders instead of files. My guess is that kaggle tries to unzip the .gz resulting in empty directories.

here are the images in the file explore

the images

and here you can see the masks

the masks

when i copy file path for masks this works fine

os.path.isfile('/kaggle/input/arcin-data/resampled_masks/resampled_masks/segmentation101.nrrd')
True

but this prints out false

os.path.isdir('/kaggle/input/arcin-data/Acrin_data/Acrin_data')
False

even thought I can see that the folder at least exists

Finally, this is from the description of the dataset

enter image description here

2

There are 2 best solutions below

0
Iliasp On

I found the answer, the problem was that .nii files are actually compressed, they were .nii.gz so kaggle thought they were separate directories and not the actual files, so it tried to decompress them but found nothing inside. I solved it by reading them locally and creating a new dataset with .pt files for the images and read them as such.

1
SouhaAissou On

I found a workaround to this problem, I just put my dataset as a zip in Google Drive and I unzip it into the working directory in Kaggle, this doesn't work for a dataset bigger than 20Gb but it worked for me

here is the link to how to access google drive files in kaggle: https://www.kaggle.com/code/vignesh369/how-to-access-google-drive-contents-in-kaggle