Skip to content

Commit de8ee04

Browse files
committed
ENH purged extra method purely based on nifty-seg and nifty-reg
1 parent 2ef1bb8 commit de8ee04

File tree

7 files changed

+17
-85
lines changed

7 files changed

+17
-85
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,11 @@ nis_app.manipulate_labels.relabel('my_input_folder_path/my_segm.nii.gz', 'my_out
5151

5252
### How to install (in development mode)
5353

54-
+ Install [NiftySeg](https://github.com/KCL-BMEIS/NiftySeg)
55-
+ Install [NiftyReg](https://github.com/KCL-BMEIS/niftyreg)
56-
+ Install [ITK-snap](http://www.itksnap.org/pmwiki/pmwiki.php?n=Downloads.SNAP3)
57-
58-
**Note:** NiftySeg, NiftyReg and ITK-Snap are required only for advanced functions.
5954

6055
+ Install python requirements in requirements.txt with
6156
`pip install -r requirements.txt`
6257
in a [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/).
58+
6359
+ Install NiLabels: the current version is not (yet) pip installable. It can be installed in development mode.
6460
To proceede, initialise a virtual environment and execute the following instructions:
6561
```
@@ -71,6 +67,12 @@ pip install -e .
7167
In development mode every change made to your local code will be directly affecting the libray installed in the python distribution
7268
without the need of reinstalling.
7369

70+
+ For advanced method `symmetrise_wit_registration`, extra examples and quick arrays visualisation with ITK-snap you must
71+
+ Install [NiftySeg](https://github.com/KCL-BMEIS/NiftySeg)
72+
+ Install [NiftyReg](https://github.com/KCL-BMEIS/niftyreg)
73+
+ Install [ITK-snap](http://www.itksnap.org/pmwiki/pmwiki.php?n=Downloads.SNAP3)
74+
75+
7476

7577
### Documentations
7678

examples/prototype_clean_a_segmentation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
pfi_differece_cleaned_non_cleaned = jph(pfo_output_folder, 'difference_half_cleaned_uncleaned.nii.gz')
4444

4545
# ---- PRE-PROCESS ---- Malice for real manual segmentation input. Keep commented for the provided phantom examples.
46+
# Based on NiftySeg.
4647

4748
cmd_ero = 'seg_maths {} -ero 1 {}'.format(pfi_input_segmentation_noisy, pfi_input_segmentation_noisy)
4849
cmd_dil = 'seg_maths {} -dil 1 {}'.format(pfi_input_segmentation_noisy, pfi_input_segmentation_noisy)

examples/simple_label_fusion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@
6565
list_pfi_segmentations = [jph(pfo_results_propagation, 'seg_nrig_ellipsoid' + str(k) + '_on_target.nii.gz') for k in range(1, 11)]
6666
list_pfi_warped = [jph(pfo_results_propagation, 'seg_nrig_ellipsoid' + str(k) + '_on_target.nii.gz') for k in range(1, 11)]
6767

68-
lm.fuse.seg_LabFusion('target.nii.gz', jph('results_label_fusion', 'output' + options_seg + '.nii.gz'),
69-
list_pfi_segmentations, options=options_seg)
68+
lm.fuse.create_stack_for_labels_fusion('target.nii.gz', jph('results_label_fusion', 'output' + options_seg + '.nii.gz'),
69+
list_pfi_segmentations, options=options_seg)
7070

7171
# If something more sophisticated needs to be done, it returns the paths to the stacks of images:
7272
options_seg = '_test2'
73-
list_paths = lm.fuse.seg_LabFusion('target.nii.gz', jph('results_label_fusion', 'output' + options_seg + '.nii.gz'),
74-
list_pfi_segmentations, list_pfi_warped, options=options_seg, prepare_data_only=True)
73+
list_paths = lm.fuse.create_stack_for_labels_fusion('target.nii.gz', jph('results_label_fusion', 'output' + options_seg + '.nii.gz'),
74+
list_pfi_segmentations, list_pfi_warped, options=options_seg, prepare_data_only=True)
7575

7676
print(list_paths)

nilabels/agents/agents_controller.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from nilabels.agents.intensities_manipulator import IntensitiesManipulator
66
from nilabels.agents.measurer import LabelsMeasure
77
from nilabels.agents.fuser import LabelsFuser
8-
from nilabels.agents.propagator import LabelsPropagator
98
from nilabels.agents.symmetrizer import SegmentationSymmetrizer
109
from nilabels.agents.checker import LabelsChecker
1110
from nilabels.agents.header_controller import HeaderController
@@ -48,7 +47,6 @@ def _set_attribute_agents(self):
4847
self.manipulate_shape = ShapeManipulator(self._pfo_in, self._pfo_out)
4948
self.measure = LabelsMeasure(self._pfo_in, self._pfo_out)
5049
self.fuse = LabelsFuser(self._pfo_in, self._pfo_out)
51-
self.propagate = LabelsPropagator(self._pfo_in, self._pfo_out)
5250
self.symmetrize = SegmentationSymmetrizer(self._pfo_in, self._pfo_out)
5351
self.check = LabelsChecker(self._pfo_in, self._pfo_out)
5452
self.header = HeaderController(self._pfo_in, self._pfo_out)

nilabels/agents/fuser.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ def __init__(self, input_data_folder=None, output_data_folder=None):
1515
self.pfo_in = input_data_folder
1616
self.pfo_out = output_data_folder
1717

18-
def seg_LabFusion(self, pfi_target, pfi_result, list_pfi_segmentations, list_pfi_warped=None, options='-MV',
19-
prepare_data_only=False, seg_output_name='res_4d_seg', warp_output_name='res_4d_warp',
20-
output_tag=''):
18+
def create_stack_for_labels_fusion(self, pfi_target, pfi_result, list_pfi_segmentations, list_pfi_warped=None,
19+
seg_output_name='res_4d_seg', warp_output_name='res_4d_warp', output_tag=''):
2120
"""
2221
Stack and fuse anatomical images and segmentations in a single command.
23-
Based on NiftySeg if prepare_data_only is False.
2422
:param pfi_target: path to file to the target of the segmentation
2523
:param pfi_result: path to file where to store the result.
2624
:param list_pfi_segmentations: list of the segmentations to fuse
2725
:param list_pfi_warped: list of the warped images to fuse
28-
:param options: simple option of NiftySeg, can be -MV -SBA or -STAPLE
29-
:param prepare_data_only: Return the paths to the stack images, and does not call seg_LabFusion.
30-
This can be set as True when some more sophistication on the methods is required.
3126
:param seg_output_name:
3227
:param warp_output_name:
3328
:param output_tag: additional tag output.
@@ -61,9 +56,5 @@ def seg_LabFusion(self, pfi_target, pfi_result, list_pfi_segmentations, list_pfi
6156
pfi_4d_warp = connect_path_tail_head(self.pfo_out, '{0}_{1}.nii.gz'.format(warp_output_name, output_tag))
6257
nib.save(im_4d_warp, pfi_4d_warp)
6358

64-
if not prepare_data_only:
65-
cmd = 'seg_LabFusion -in {0} -out {1} {2}'.format(pfi_4d_seg, pfi_result, options)
66-
os.system(cmd)
6759

68-
else:
69-
return pfi_target, pfi_result, pfi_4d_seg, pfi_4d_warp
60+
return pfi_target, pfi_result, pfi_4d_seg, pfi_4d_warp

nilabels/agents/propagator.py

Lines changed: 0 additions & 62 deletions
This file was deleted.

nilabels/agents/symmetrizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def symmetrise_with_registration(self,
6363
labels value, it will spare you some time when set to True.
6464
:param coord: coordinate of the registration: in RAS, 'z' will symmetrise Left on Right.
6565
:return: symmetrised segmentation.
66+
---
67+
NOTE: requires niftyreg.
6668
"""
6769

6870
pfi_in_anatomy = connect_path_tail_head(self.pfo_in, filename_anatomy)

0 commit comments

Comments
 (0)