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

Commit

Permalink
Merge branch 'image-loader' into 'dev'
Browse files Browse the repository at this point in the history
Image loader

See merge request CMIC/NiftyNet!191
  • Loading branch information
wyli committed Mar 7, 2018
2 parents f2aeefb + 107b4ef commit 90941ee
Show file tree
Hide file tree
Showing 47 changed files with 682 additions and 210 deletions.
8 changes: 7 additions & 1 deletion doc/source/config_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ within each section.

- [csv_file](#csv-file) :: `string` :: `csv_file=file_list.csv` :: `''`
- [path_to_search](#path-to-search) :: `string` :: `path_to_search=my_data/fold_1` :: NiftyNet home folder
- [filename_contain](#filename-contain) :: `String` or `string array` :: `filename_contain=foo, bar` :: `''`
- [filename_contain](#filename-contain) :: `string` or `string array` :: `filename_contain=foo, bar` :: `''`
- [filename_not_contain](#filename-not-contain) :: `string` or `string array` :: `filename_not_contain=foo` :: `''`
- [interp_order](#interp-order) :: `integer` :: `interp_order=0` :: `3`
- [pixdim](#pixdim) :: `float array` :: `pixdim=1.2, 1.2, 1.2` :: `''`
- [axcodes](#axcodes) :: `string array` :: `axcodes=L, P, S` :: `''`
- [spatial_window_size](#spatial-window-size) :: `integer array` :: `spatial_window_size=64, 64, 64` :: `''`
- [loader](#loader) :: `string` :: `loader=simpleitk` :: `None`

###### `csv_file`
A file path to a list of input images. If the file exists, input image name
Expand Down Expand Up @@ -160,6 +161,11 @@ before fed into the network.
Array of three integers specifies the input window size.
Setting it to single slice, e.g., `spatial_window_size=64, 64, 1`, yields a 2-D slice window.

###### `loader`
Specify the loader to be used to load the files in the input section.
Some loaders require additional Python packages.
Default value `None` indicates trying all available loaders.

This section will be used by [ImageReader](./niftynet.io.image_reader.html)
to generate a list of [input images objects](./niftynet.io.image_type.html).
For example:
Expand Down
4 changes: 2 additions & 2 deletions niftynet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
from niftynet.io.misc_io import set_logger
set_logger()

from niftynet.utilities.util_import import check_module
check_module('blinker', descriptor='New dependency', mandatory=True)
from niftynet.utilities.util_import import require_module
require_module('blinker', descriptor='New dependency', mandatory=True)

import niftynet.utilities.util_common as util
import niftynet.utilities.user_parameters_parser as user_parameters_parser
Expand Down
Empty file modified niftynet/application/regression_application.py
100644 → 100755
Empty file.
Empty file modified niftynet/application/segmentation_application.py
100644 → 100755
Empty file.
Empty file modified niftynet/contrib/evaluation/__init__.py
100644 → 100755
Empty file.
Empty file modified niftynet/contrib/evaluation/classification_evaluations.py
100644 → 100755
Empty file.
Empty file modified niftynet/contrib/evaluation/regression_evaluations.py
100644 → 100755
Empty file.
8 changes: 6 additions & 2 deletions niftynet/contrib/evaluation/segmentation_evaluations.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import os

from scipy import ndimage
import numpy as np
import pandas as pd
from scipy import ndimage

from niftynet.evaluation.base_evaluations import BaseEvaluation
from niftynet.evaluation.segmentation_evaluations import \
Expand All @@ -18,15 +19,17 @@ class com_ref(PerComponentEvaluation):
"""
Computes the centers of mass of each component in the reference standard
"""

def metric_from_binarized(self, seg, ref):
"""
:param seg: numpy array with binary mask from inferred segmentation
:param ref: numpy array with binary mask from reference segmentation
:return: dict of centers of mass in each axis
"""
return {d: 'com_ref_'+x
return {d: 'com_ref_' + x
for d, x in zip('XYZ', ndimage.center_of_mass(ref))}


class ErrorMapsCC(BaseEvaluation):
"""
Create 3 maps of connected component detection:
Expand All @@ -36,6 +39,7 @@ class ErrorMapsCC(BaseEvaluation):
fpc_map shows all seg ccs that did not overlap any ref ccs
Note we currently arbitrarily limit image generation to binary problems
"""

def layer_op(self, subject_id, data):
analyses = self.app_param.evaluation_units.split(',')
if 'label' not in analyses and 'foreground' not in analyses:
Expand Down
6 changes: 3 additions & 3 deletions niftynet/contrib/layer/rand_elastic_deform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@


from __future__ import absolute_import, print_function
from niftynet.utilities.util_import import check_module
check_module('SimpleITK')

import warnings

import numpy as np
import SimpleITK as sitk

from niftynet.layer.base_layer import RandomisedLayer
from niftynet.utilities.util_import import require_module

sitk = require_module('SimpleITK')

warnings.simplefilter("ignore", UserWarning)
warnings.simplefilter("ignore", RuntimeWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(7, 10, 2)
spatial_window_size=(7, 10, 2),
loader=None
),
'FLAIR': ParserNamespace(
csv_file=os.path.join('testing_data', 'FLAIRsampler.csv'),
Expand All @@ -70,7 +71,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(7, 10, 2)
spatial_window_size=(7, 10, 2),
loader=None
),
'Label': ParserNamespace(
csv_file=os.path.join('testing_data', 'lesion.csv'),
Expand All @@ -80,7 +82,8 @@ def check_constraint(data, constraint):
interp_order=1,
pixdim=None,
axcodes=None,
spatial_window_size=(7, 10, 2)
spatial_window_size=(7, 10, 2),
loader=None
)
}
LABEL_TASK = {
Expand All @@ -92,7 +95,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(7, 10, 2)
spatial_window_size=(7, 10, 2),
loader=None
)
}
MULTI_MOD_TASK = ParserNamespace(image=('T1', 'FLAIR'), label=('Label',))
Expand All @@ -106,7 +110,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(10, 9, 1)
spatial_window_size=(10, 9, 1),
loader=None
),
}
MOD_2D_TASK = ParserNamespace(image=('ultrasound',))
Expand All @@ -120,7 +125,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(8, 2)
spatial_window_size=(8, 2),
loader=None
),
'FLAIR': ParserNamespace(
csv_file=os.path.join('testing_data', 'FLAIRsampler.csv'),
Expand All @@ -130,7 +136,8 @@ def check_constraint(data, constraint):
interp_order=3,
pixdim=None,
axcodes=None,
spatial_window_size=(8, 2)
spatial_window_size=(8, 2),
loader=None
),
'Label': ParserNamespace(
csv_file=os.path.join('testing_data', 'labels.csv'),
Expand All @@ -140,7 +147,8 @@ def check_constraint(data, constraint):
interp_order=1,
pixdim=None,
axcodes=None,
spatial_window_size=(8, 2)
spatial_window_size=(8, 2),
loader=None
)
}

Expand Down
Empty file modified niftynet/engine/application_driver.py
100644 → 100755
Empty file.
Empty file modified niftynet/engine/application_factory.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/base_evaluations.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/base_evaluator.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/classification_evaluations.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/classification_evaluator.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/evaluation_application_driver.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/regression_evaluations.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/regression_evaluator.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/segmentation_evaluations.py
100644 → 100755
Empty file.
Empty file modified niftynet/evaluation/segmentation_evaluator.py
100644 → 100755
Empty file.

0 comments on commit 90941ee

Please sign in to comment.