From cfb111434edbacbc79a21fb88993a709cb58d96c Mon Sep 17 00:00:00 2001 From: Akis Linardos Date: Thu, 11 Jul 2024 19:29:47 -0400 Subject: [PATCH] Add files via upload a script to create the necessary testing csv and a README to make sure the future organizer finds the instructions easily --- Task_1/fets_challenge/README.md | 5 +++++ Task_1/fets_challenge/create_test_csv.py | 26 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Task_1/fets_challenge/README.md create mode 100644 Task_1/fets_challenge/create_test_csv.py diff --git a/Task_1/fets_challenge/README.md b/Task_1/fets_challenge/README.md new file mode 100644 index 0000000..a22d3cf --- /dev/null +++ b/Task_1/fets_challenge/README.md @@ -0,0 +1,5 @@ +Instructions for challenge organizer (Participants, ignore this) + +During testing phase: +- first generate a csv file for the testing set per the "create_test_csv.py" script +- use "generate_predictions.py" to run inference using the generated csv (final_test.csv) diff --git a/Task_1/fets_challenge/create_test_csv.py b/Task_1/fets_challenge/create_test_csv.py new file mode 100644 index 0000000..45214b2 --- /dev/null +++ b/Task_1/fets_challenge/create_test_csv.py @@ -0,0 +1,26 @@ +import os +import csv + +# This script generates a CSV file named 'final_test.csv' in the current directory. +# The CSV file has two columns: 'Partition_ID' and 'Subject_ID'. +# 'Partition_ID' is set to -1 for all rows. +# 'Subject_ID' is populated with the names of folders in the specified directory. +# This is intended to replicate the format of 'validation.csv' in the FeTS Challenge repository. +# The generated CSV file can be used to list all test samples in your data path. + +# Specify the directory containing the test data folders +data_dir = "/home/locolinux2/datasets/RSNA_ASNR_MICCAI_BraTS2021_TestingData" + +dir_list = [d for d in os.listdir(data_dir) if os.path.isdir(os.path.join(data_dir, d))] + +output_csv = '/home/locolinux2/.local/workspace/final_test.csv' + +# Write the CSV file +with open(output_csv, mode='w', newline='') as file: + writer = csv.writer(file) + writer.writerow(['Partition_ID', 'Subject_ID']) + + for directory in dir_list: + writer.writerow(['-1', directory]) + +print(f'CSV file "{output_csv}" has been created with the folder names.')