I'm currently working on a project involving the BraTS20
dataset for brain tumor analysis. I'm facing an issue when trying to retrieve the shape of the calculated features in the getListAgeDays
function.
Here is the code : # create only age: category data
# id: age, categories
def getListAgeDays(id_list):
x_val = []
y_val = []
for i in id_list:
if (i not in age_dict):
continue
masks = getMaskSizesForVolume(nib.load(TRAIN_DATASET_PATH + f'BraTS20_Training_{i[-3:]}/BraTS20_Training_{i[-3:]}_seg.nii').get_fdata())
brain_vol = getBrainSizeForVolume(nib.load(TRAIN_DATASET_PATH + f'BraTS20_Training_{i[-3:]}/BraTS20_Training_{i[-3:]}_t1.nii').get_fdata())
masks[1] = masks[1]/brain_vol
masks[2] = masks[2]/brain_vol
masks[3] = masks[3]/brain_vol
merged=[age_dict[i],masks[1],masks[2],masks[3]] ## add segments
x_val.append(merged)
if (days_dict[i] < 250):
y_val.append([1,0,0])
elif (days_dict[i] >= 250 and days_dict[i] < 450):
y_val.append([0,1,0])
else:
y_val.append([0,0,1])
return np.array(x_val), np.array(y_val)
X_all, y_all = getListAgeDays(train_and_test_ids)
print(f'X_test: {X_all.shape}')
df = pd.DataFrame(np.concatenate((X_all, y_all), axis=1) , columns = ["age",f"{SEGMENT_CLASSES[1]}",f"{SEGMENT_CLASSES[2]}",f"{SEGMENT_CLASSES[3]}","short","medium","long"])
df.head()
The expected output is below:
But the ouput is:
(array([], dtype=float64), array([], dtype=float64))
X_test: (0,)
Spyder variable explored image is here: enter image description here
I have verified that the inputs to the function (train_and_test_ids, age_dict, days_dict, etc.)
are correctly defined and contain data. However, the shape of X_all
is not as expected.
I would appreciate any insights or suggestions on why the shape of X_all is not being correctly calculated. Thank you!