Skip to content

Commit

Permalink
add new scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzjalen committed Feb 18, 2024
1 parent affd88c commit ff52cd9
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def plan_experiment(self):
'inherits_from': '3d_fullres',
'batch_size': 2,
"spacing": [1.0, 1.0, 1.0],
"patch_size": [128, 192, 192],
"patch_size": [192, 192, 192],
"UNet_base_num_features": 32,
"n_conv_per_stage_encoder": [
1,
Expand Down Expand Up @@ -635,15 +635,15 @@ def plan_experiment(self):
print(plans['configurations']['3d_fullres_mosaic_resenc'])
print()

plans['configurations']["3d_fullres_mosaic_resenc_192x192x192_bs3_1mm"]= {
plans['configurations']["3d_fullres_mosaic_resenc_192x192x192_bs2_1mm"]= {
"inherits_from": "3d_fullres_mosaic_resenc",
"spacing": [1.0, 1.0, 1.0],
"patch_size": [
192,
192,
192
],
"batch_size": 3
"batch_size": 2
}

print('3D fullres Mosaic ResEncUnet 192x192x192 bs3 1mm')
Expand Down
49 changes: 49 additions & 0 deletions scripts/del_npy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,55 @@
" os.remove(file_path)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1, 3, 4, 6, 6, 6]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = [\n",
" 1,\n",
" 3,\n",
" 4,\n",
" 6,\n",
" 6,\n",
" 6\n",
" ]\n",
"\n",
"a"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
7 changes: 3 additions & 4 deletions scripts/generate_json.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@
"from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json\n",
"import os\n",
"\n",
"dataset = \"/media/eolika/49755d50-5426-4672-87cc-2d1a5a3747ad/nnUNet/nnUNet_raw/Dataset201_renal_vessels\"\n",
"dataset = \"/media/eolika/49755d50-5426-4672-87cc-2d1a5a3747ad/nnUNet/nnUNet_raw/Dataset909_acute_ischemic_stroke\"\n",
"\n",
"generate_dataset_json(output_folder=dataset,\n",
" channel_names={0: \"CT\"},\n",
" labels={\n",
" \"background\": 0,\n",
" \"renal_artery\": 1,\n",
" \"renal_vein\": 2\n",
" \"acute_ischemic_stroke\": 1\n",
" },\n",
" num_training_cases=len(os.listdir(f'{dataset}/imagesTr')), \n",
" file_ending='.nii.gz',\n",
" dataset_name=dataset.split('/')[-1], \n",
" reference='none',\n",
" release='1.0.0',\n",
" overwrite_image_reader_writer='NibabelIOWithReorient',\n",
" description=\"renal_vessels\")"
" description=\"acute_ischemic_stroke\")"
]
},
{
Expand Down
6 changes: 6 additions & 0 deletions scripts/plot_prepocess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
read -p "Enter dataset id : " id
read -p "Enter train config (ex. 3d_fullres, 3d_fullres_mosaic_arch2, 3d_fullres_mosaic_resenc) : " conf
read -p "Enter output path: " output

nnUNetv2_plot_overlay_pngs -d $id -o $output -c $conf
2 changes: 1 addition & 1 deletion scripts/preprocess_resenc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

echo "Prepare target dataset on pretrained set."
read -p "Enter source dataset: " id
read -p "Enter train config (ex. 3d_fullres, 3d_fullres_mosaic_resenc, 3d_fullres_mosaic_resenc_192x192x192_bs3_1mm): " conf
read -p "Enter train config (ex. 3d_fullres, 3d_fullres_mosaic_resenc, 3d_fullres_mosaic_resenc_192x192x192_bs2_1mm): " conf
read -p "Enter a number of processors to use: " np

nnUNetv2_extract_fingerprint -d $id
Expand Down
6 changes: 4 additions & 2 deletions scripts/train.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

echo "Train model from scratch. Be sure that you have already created the dataset.json file!"
read -p "Enter dataset id: " id
read -p "Enter train config (ex. 3d_fullres or custom 3d_fullres_mosaic, 3d_fullres_mosaic_resenc, 3d_fullres_mosaic_resenc_192x192x192_bs3_1mm config): " conf
read -p "Enter train config (ex. 3d_fullres or custom 3d_fullres_mosaic, 3d_fullres_mosaic_resenc, 3d_fullres_mosaic_resenc_192x192x192_bs2_1mm config): " conf
read -p "Enter train fold ([0-4] or all usually): " fold
read -p "Enter trainer you would like to choose (nnUNetTrainer, nnUNetTrainerNoMirroring, nnUNetTrainer_Xepochs-where X could be in [100, 250, 2000, 4000, 8000], nnUNetTrainerDiceCELoss_noSmooth): " trainer


echo "Launching the train..."
nnUNetv2_train "$id" --c "$conf" "$fold" -tr "$trainer"
nnUNetv2_train "$id" --c "$conf" "$fold" -tr "$trainer"

# nnUNet_compile=T nnUNet_n_proc_DA=28 nnUNetv2_train 221 3d_fullres_mosaic_resenc_192x192x192_bs3_1mm 0 -num_gpus 8

0 comments on commit ff52cd9

Please sign in to comment.