Skip to content

Commit effcb4d

Browse files
committed
upload files both modalities
1 parent dfcbaab commit effcb4d

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ python mainHyperDenseNet.py
2727
## Preparing your data
2828
- To use your own data, you will have to specify the path to the folder containing this data (--root_dir).
2929
- Images have to be in nifti (.nii) format
30-
- You have to split your data into two folders: Training/Validation. Each folder will contain N sub-folders: N-1 subfolders that will contain each modality and GT, which contain the nifti files for the images and their corresponding ground truths.
30+
- You have to split your data into two folders: Training/Validation. Each folder will contain N sub-folders: N-1 subfolders that will contain each modality and GT, which contain the nifti files for the images and their corresponding ground truths. Then, for training, you only need to specify which subfolders you want to use in the command line. For example:
31+
```
32+
--modality_dirs T1 T2_FLAIR
33+
```
34+
3135
- In the runTraining function, you have to change the name of the subfolders to the names you have in your dataset (lines 128-131 and 144-147).
3236
- Image names should be the same across folders (e.g., )
3337
## Current version

mainHyperDenseNet.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ def runTraining(opts):
129129
print('~' * 50)
130130
print('~~~~~~~~~~~~~~~~~ PARAMETERS ~~~~~~~~~~~~~~~~')
131131
print('~' * 50)
132-
print(' - Image modalities: {}'.format(opts.numModal))
132+
print(' - Number of image modalities: {}'.format(opts.numModal))
133133
print(' - Number of classes: {}'.format(opts.numClasses))
134134
print(' - Directory to load images: {}'.format(opts.root_dir))
135+
for i in range(len(opts.modality_dirs)):
136+
print(' - Modality {}: {}'.format(i+1,opts.modality_dirs[i]))
135137
print(' - Directory to save results: {}'.format(opts.save_dir))
136138
print(' - To model will be saved as : {}'.format(opts.modelName))
137139
print('-' * 41)
@@ -155,11 +157,13 @@ def runTraining(opts):
155157
root_dir = opts.root_dir
156158
model_name = opts.modelName
157159

158-
moda_1 = root_dir + 'Training/T1'
159-
moda_2 = root_dir + 'Training/T2_FLAIR'
160+
if not (len(opts.modality_dirs)== opts.numModal): raise AssertionError
161+
162+
moda_1 = root_dir + 'Training/' + opts.modality_dirs[0]
163+
moda_2 = root_dir + 'Training/' + opts.modality_dirs[1]
160164

161165
if (opts.numModal == 3):
162-
moda_3 = root_dir + 'Training/T1_IR'
166+
moda_3 = root_dir + 'Training/' + opts.modality_dirs[2]
163167

164168
moda_g = root_dir + 'Training/GT'
165169

@@ -174,11 +178,11 @@ def runTraining(opts):
174178
else:
175179
raise Exception(' - {} does not exist'.format(moda_1))
176180

177-
moda_1_val = root_dir + 'Validation/T1'
178-
moda_2_val = root_dir + 'Validation/T2_FLAIR'
181+
moda_1_val = root_dir + 'Validation/' + opts.modality_dirs[0]
182+
moda_2_val = root_dir + 'Validation/' + opts.modality_dirs[1]
179183

180184
if (opts.numModal == 3):
181-
moda_3_val = root_dir + 'Validation/T1_IR'
185+
moda_3_val = root_dir + 'Validation/' + opts.modality_dirs[2]
182186
moda_g_val = root_dir + 'Validation/GT'
183187

184188
print(' --------------------')
@@ -312,6 +316,7 @@ def runTraining(opts):
312316
if __name__ == '__main__':
313317
parser = argparse.ArgumentParser()
314318
parser.add_argument('--root_dir', type=str, default='./Data/MRBrainS/DataNii/', help='directory containing the train and val folders')
319+
parser.add_argument('--modality_dirs', nargs='+', default=['T1','T2_FLAIR'], help='subdirectories containing the multiple modalities')
315320
parser.add_argument('--save_dir', type=str, default='./Results/', help='directory ot save results')
316321
parser.add_argument('--modelName', type=str, default='HyperDenseNet_2Mod', help='name of the model')
317322
parser.add_argument('--numModal', type=int, default=2, help='Number of image modalities')

0 commit comments

Comments
 (0)