-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrunMU-Net.py
41 lines (33 loc) · 2.17 KB
/
runMU-Net.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 31 15:17:06 2019
@author: riccardo
"""
import sys
if len(sys.argv)==1: # Helper message
print('This script runs inference on MRI volumes for MU-Net:\nMulti-task U-Net for the simultaneous segmentation and skull-stripping of mouse brain MRI\n'+
'This network is optimized to run on 2D coronal slices.\nHow to run:\n\n'+
'python3 runMU-Net.py [options] [list of volumes]\n\n'+
'[list of volumes] is a list of paths to nifti volumes separated by spaces\n'+
'If a folder path is specified, all .nii and .nii.gz files will be added recursvely\n'+
'Options:'+
'\n--overwrite [True/False]:\n'+
' Overwrite outputs if file already exists (default: False)\n'+
'--N3 [True/False]:\n Load model weights for N3 corrected volumes (default False)\n'+
'--multinet [True/False]:\n use networks trained on all folds and apply majority voting. (default True)\n'+
'--netid:\n if using one single network, which one (between 0 and 4, default 0)\n'+
'--probmap [True/False]:\n output unthresholded probability maps rather than the segmented volumes (default False)\n'+
'--boundingbox [True/False]:\n automatically estimate bounding box using auxiliary network (default True)\n'+
'--useGPU [True/False]:\n run on GPU, requires installed GPU support for pytorch with a CUDA enabled GPU (default True)\n'+
'--namemask:\n only include files containing this string (case sensitive). Example: --namemask MySeq.nii\n'+
'--depth:\n max directory depth for recursive search (default 99)\n'+
'--nameignore: exclude all files containing this string (case sensitive). Example: --nameignore NotThisSeq.nii\n',
'--out: output name, added to each output file\n',
'Note: we assume the first two indices in the volume are contained in the same coronal section, so that the third index would refer to different coronal sections')
exit()
import funcs
torch=funcs.torch
#Extract options and MRI volumes list
VolumeList, opt = funcs.GetFilesOptions(sys.argv[1:])
funcs.Segment(VolumeList,opt)