Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wyli committed Nov 24, 2017
1 parent 8d40aba commit 88c6fbf
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 6 deletions.
8 changes: 8 additions & 0 deletions niftynet/contrib/segmentation_selective_sampler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Training segmentation network with selective sampling of image windows

To run this application (from NiftyNet source code root folder)
with a config file (e.g., `niftynet/contrib/segmentation_selective_sampler/selective_seg.ini`)
```bash
python net_run.py train -a niftynet.contrib.segmentation_selective_sampler.ss_app.SelectiveSampling \
-c niftynet/contrib/segmentation_selective_sampler/selective_seg.ini
```
80 changes: 80 additions & 0 deletions niftynet/contrib/segmentation_selective_sampler/selective_seg.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
############################ input configuration sections
[modality1]
csv_file=
path_to_search = ./example_volumes/monomodal_parcellation
filename_contains = T1
filename_not_contains =
spatial_window_size = (20, 42, 42)
interp_order = 3
pixdim=(1.0, 1.0, 1.0)
axcodes=(A, R, S)

[label]
path_to_search = ./example_volumes/monomodal_parcellation
filename_contains = Label
filename_not_contains =
spatial_window_size = (20, 42, 42)
interp_order = 0
pixdim=(1.0, 1.0, 1.0)
axcodes=(A, R, S)

############################## system configuration sections
[SYSTEM]
cuda_devices = ""
num_threads = 2
num_gpus = 1
model_dir = ./models/model_monomodal_toy

[NETWORK]
name = toynet
activation_function = prelu
batch_size = 1
decay = 0.1
reg_type = L2

# volume level preprocessing
volume_padding_size = 21
# histogram normalisation
histogram_ref_file = ./example_volumes/monomodal_parcellation/standardisation_models.txt
norm_type = percentile
cutoff = (0.01, 0.99)
normalisation = False
whitening = False
normalise_foreground_only=True
foreground_type = otsu_plus
multimod_foreground_type = and

queue_length = 20


[TRAINING]
sample_per_volume = 32
rotation_angle = (-10.0, 10.0)
scaling_percentage = (-10.0, 10.0)
random_flipping_axes= 1
lr = 0.01
loss_type = Dice
starting_iter = 0
save_every_n = 100
max_iter = 10
max_checkpoints = 20

[INFERENCE]
border = (0, 0, 1)
#inference_iter = 10
save_seg_dir = ./output/toy
output_interp_order = 0
spatial_window_size = (0, 0, 3)

############################ custom configuration sections
[SEGMENTATION]
image = modality1
label = label
output_prob = False
num_classes = 160
label_normalisation = True

rand_samples=0
num_min_labels=1
proba_connect=True
compulsory_labels=0, 1
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
SUPPORTED_INPUT = set(['image', 'label', 'weight', 'sampler'])


class SegmentationApplication(BaseApplication):
class SelectiveSampling(BaseApplication):
REQUIRED_CONFIG_SECTION = "SEGMENTATION"

def __init__(self, net_param, action_param, is_training):
super(SegmentationApplication, self).__init__()
super(SelectiveSampling, self).__init__()
tf.logging.info('starting segmentation application')
self.is_training = is_training

Expand Down Expand Up @@ -155,7 +155,7 @@ def initialise_selective_sampler(self):
self.segmentation_param.min_ratio_sampling,
self.segmentation_param.num_min_labels,
self.segmentation_param.proba_connect)
self.sampler = [
self.sampler = [[
SelectiveSampler(
reader=reader,
data_param=self.data_param,
Expand All @@ -164,7 +164,7 @@ def initialise_selective_sampler(self):
constraint=selective_constraints,
random_windows_per_image=self.segmentation_param.rand_samples,
queue_length=self.net_param.queue_length)
for reader in self.readers]
for reader in self.readers]]

def initialise_grid_sampler(self):
self.sampler = [[GridSampler(
Expand All @@ -185,9 +185,9 @@ def initialise_grid_aggregator(self):

def initialise_sampler(self):
if self.is_training:
self.SUPPORTED_SAMPLING[self.net_param.window_sampling][0]()
self.SUPPORTED_SAMPLING['selective'][0]()
else:
self.SUPPORTED_SAMPLING[self.net_param.window_sampling][1]()
self.SUPPORTED_SAMPLING['selective'][1]()

def initialise_network(self):
w_regularizer = None
Expand Down

0 comments on commit 88c6fbf

Please sign in to comment.