Skip to content

Instantly share code, notes, and snippets.

@rekalantar
Created May 30, 2023 10:14
Show Gist options
  • Select an option

  • Save rekalantar/9054999cefb1d18957dc9015e429cb2a to your computer and use it in GitHub Desktop.

Select an option

Save rekalantar/9054999cefb1d18957dc9015e429cb2a to your computer and use it in GitHub Desktop.
# Initialize dictionary for storing image and label paths
data_paths = {}
# Create directories and print the number of images and masks in each
for dataset in datasets:
for data_type in data_types:
# Construct the directory path
dir_path = os.path.join(base_dir, f'{dataset}_{data_type}')
# Find images and labels in the directory
files = sorted(glob.glob(os.path.join(dir_path, "*.nii.gz")))
# Store the image and label paths in the dictionary
data_paths[f'{dataset}_{data_type.split("_")[1]}'] = files
print('Number of training images', len(data_paths['train_images']))
print('Number of validation images', len(data_paths['val_images']))
print('Number of test images', len(data_paths['test_images']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment